Ask Your Question

help doesn't show function call

asked 2019-07-18 23:09:26 -0600

manojt gravatar image


When I look up matrix.add_multiple_of_row in Sage reference, I get:

add_multiple_of_column(i, j, s, start_row=0)

Add s times column j to column i.


If I do ?A.add_multiple_of_row in SageMath (in Jupyter, with the variable A = matrix(...)), I get


Add s times row j to row i.


Note the critical line add_multiple_of_column(i, j, s, start_row=0) missing. Is it possible to see the function arguments and usage when using the ? form of help?

Thanks, Manoj

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2019-07-19 17:57:06 -0600

dsejas gravatar image

updated 2019-07-19 18:03:34 -0600

Hello. One possible way to do this is using the double question sign operator (??). For example:


will show you something like

def add_multiple_of_row(self, Py_ssize_t i, Py_ssize_t j,    s,   Py_ssize_t start_col=0):
    Add s times row j to row i.

    EXAMPLES: We add -3 times the first row to the second row of an
    integer matrix, remembering to start numbering rows at zero::

        sage: a = matrix(ZZ,2,3,range(6)); a
        [0 1 2]
        [3 4 5]
        sage: a.add_multiple_of_row(1,0,-3)
        sage: a
        [ 0  1  2]
        [ 3  1 -1]


Unfortunately, as you might guess, this was intended to show not only the docstring, but the whole code. That is why you see strange data types like Py_ssize_t, which comes from Cython, acombination of C and Python, in which this particular subroutine is written. If you don't know the meaning of the keyword self, it is safe to ignore it.

However, this should not be a problem, since the docstring will guide you further, and it is difficult to run into Cython implementations in every-day use of SageMath. Just ignore strange data types and also self: consider the signature of the subroutine to be

def add_multiple_of_row(i, j, s, start_col=0):

You can also use help(A.add_multiple_of_row), which will show the same, except for the part of the code. (I have not experimented much with this command.)

edit flag offensive delete link more



Thank you for your reply. Hope the SageMath team will include the function signature in the ? form of help in a future release, which will make the output much more useful.

manojt gravatar imagemanojt ( 2019-07-21 22:32:16 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2019-07-18 23:09:26 -0600

Seen: 80 times

Last updated: Jul 19 '19