ASKSAGE: Sage Q&A Forum - Individual question feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sun, 21 Jul 2019 22:32:16 -0500help doesn't show function callhttps://ask.sagemath.org/question/47214/help-doesnt-show-function-call/ 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,
ManojThu, 18 Jul 2019 23:09:26 -0500https://ask.sagemath.org/question/47214/help-doesnt-show-function-call/Answer by dsejas for <p>Hi,</p>
<p>When I look up matrix.add_multiple_of_row in Sage reference, I get:</p>
<blockquote>
<p><strong>add_multiple_of_column(i, j, s, start_row=0)</strong> </p>
<p>Add s times column j to column i.</p>
<p>EXAMPLES: ...</p>
</blockquote>
<p>If I do ?A.add_multiple_of_row in SageMath (in Jupyter, with the variable A = matrix(...)), I get</p>
<blockquote>
<p>Docstring: </p>
<p>Add s times row j to row i.</p>
<p>EXAMPLES: ...</p>
</blockquote>
<p>Note the critical line <strong>add_multiple_of_column(i, j, s, start_row=0)</strong> missing. Is it possible to see the function arguments and usage when using the ? form of help? </p>
<p>Thanks,
Manoj</p>
https://ask.sagemath.org/question/47214/help-doesnt-show-function-call/?answer=47218#post-id-47218Hello. 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.)Fri, 19 Jul 2019 17:57:06 -0500https://ask.sagemath.org/question/47214/help-doesnt-show-function-call/?answer=47218#post-id-47218Comment by manojt for <p>Hello. One possible way to do this is using the double question sign operator (<code>??</code>). For example:</p>
<pre><code>A.add_multiple_of_row??
</code></pre>
<p>will show you something like</p>
<pre><code>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]
</code></pre>
<p>Etc...</p>
<p>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 <code>Py_ssize_t</code>, 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 <code>self</code>, it is safe to ignore it.</p>
<p>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 <code>self</code>: consider the signature of the subroutine to be</p>
<pre><code>def add_multiple_of_row(i, j, s, start_col=0):
</code></pre>
<p>You can also use <code>help(A.add_multiple_of_row)</code>, which will show the same, except for the part of the code. (I have not experimented much with this command.)</p>
https://ask.sagemath.org/question/47214/help-doesnt-show-function-call/?comment=47236#post-id-47236Thank 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.Sun, 21 Jul 2019 22:32:16 -0500https://ask.sagemath.org/question/47214/help-doesnt-show-function-call/?comment=47236#post-id-47236