#9976: Decorated functions/methods have generic signature in documentation
--------------------------------+-------------------------------------------
Reporter: jsrn | Owner: jsrn
Type: enhancement | Status: needs_work
Priority: major | Milestone: sage-4.7
Component: documentation | Keywords: sphinx, documentation, cython
inspection
Author: jsrn, Simon King | Upstream: N/A
Reviewer: | Merged:
Work_issues: |
--------------------------------+-------------------------------------------
Changes (by SimonKing):
* status: needs_review => needs_work
Comment:
Replying to [comment:94 jsrn]:
> I should have been more clear: the above example works with
sage_getargspec as it never reaches the statement in question. What I
meant was, that some object would reach the definition, then having that
_sage_src_ (or something like it) would cause the regular-expression to
fail.
Again, the regular expression is not directly extracting the arguments
from the source code, but it is only extracting the "head" of the
definition.
Perhaps the following convinces you: We create an object with a _sage_src_
method returning the source code you suggested.
{{{
sage: cython('''
....: cdef class MyClass:
....: def _sage_src_(self):
....: return "def monkey2(a={(1+2) : 'wee'}):\\n return a[3]"
....: def __call__(self, x,y):
....: return "something"
....: ''')
sage: O = MyClass()
sage: print O._sage_src_()
def monkey2(a={(1+2) : 'wee'}):
return a[3]
}}}
Let us test that the relevant part of sage_getargspec is really executed:
{{{
sage: callable(O)
True
sage: import inspect
sage: hasattr(O,'_sage_argspec_')
False
sage: inspect.isfunction(O)
False
sage: inspect.ismethod(O)
False
sage: sage.misc.sageinspect.isclassinstance(O)
True
sage: hasattr(O,'_sage_src_')
True
}}}
Now, we would expect that sage_getargspec relies on the (fake) source code
returned by O, not on the actual arguments of its `__call__` method. But
then, indeed something goes wrong:
{{{
sage: sage.misc.sageinspect.sage_getargspec(O)
ArgSpec(args=['a'], varargs=None, keywords=None, defaults=({None:
'wee'},))
}}}
Why is it `{None: 'wee'}`, not `{3: 'wee'}`?
I can not work on it right now, but I think that needs to be addressed.
So, needs, work...
> But now I'm pretty confused: which kind of objects did you envision are
classinstances, are callable and have _sage_src_ attribute set? decorators
which have not yet been applied to a function?
No. Decorators which ''have'' been applied to a function. For example
(without any patches applied):
{{{
sage: P.<x,y> = QQ[]
sage: I = P*[x,y]
sage: sage.misc.sageinspect.isclassinstance(I.groebner_basis)
True
sage: hasattr(I.groebner_basis,'_sage_src_')
True
}}}
So, "needs work" because of the monkeys.
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/9976#comment:96>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sage-trac?hl=en.