Ask Your Question
3

help doesn't show function call

asked 2019-07-19 06:09:26 +0100

manojt gravatar image

Hi,

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.

EXAMPLES: ...

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

Docstring:

Add s times row j to row i.

EXAMPLES: ...

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
3

answered 2019-07-20 00:57:06 +0100

dsejas gravatar image

updated 2019-07-20 01:03:34 +0100

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

A.add_multiple_of_row??

will show you something like

Source:
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]

Etc...

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

Comments

1

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-22 05:32:16 +0100 )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

Stats

Asked: 2019-07-19 06:09:26 +0100

Seen: 199 times

Last updated: Jul 20 '19