Ticket #8325 (closed defect: fixed)
Sphinx warning: 'Could not parse cython argspec'
| Reported by: | mpatel | Owned by: | |
|---|---|---|---|
| Priority: | minor | Milestone: | sage-4.3.4 |
| Component: | documentation | Keywords: | |
| Cc: | jhpalmieri | Work issues: | |
| Report Upstream: | N/A | Reviewers: | John Palmieri |
| Authors: | Mitesh Patel | Merged in: | sage-4.3.4.alpha1 |
| Dependencies: | Stopgaps: |
Description
Sphinx warnings from building the HTML reference manual include:
matrix/matrix_integer_dense.rst:6: (WARNING/2) error while formatting signature for sage.matrix.matrix_integer_dense.Matrix_integer_dense.LLL: Could not parse cython argspec plot/plot3d/base.rst:6: (WARNING/2) error while formatting signature for sage.plot.plot3d.base.Graphics3d.export_jmol: Could not parse cython argspec
Related: #8244.
Attachments
Change History
comment:1 Changed 3 years ago by mpatel
- Cc jhpalmieri added
- Status changed from new to needs_review
The patch should work for the cases in the description.
comment:2 Changed 3 years ago by jhpalmieri
- Status changed from needs_review to positive_review
- Reviewers set to John Palmieri
Should patches like this also come with a corresponding one to sagenb.misc.sageinspect, as in #8324?
Looks good, no warnings when building the reference manual for these two files, and the relevant pages look good. Nice solution.
comment:3 follow-up: ↓ 4 Changed 3 years ago by jhpalmieri
(Is it dangerous to use "exec" here? It looks okay to me, but I feel as though I should always be suspicious of using it.)
comment:4 in reply to: ↑ 3 Changed 3 years ago by mpatel
Replying to jhpalmieri:
(Is it dangerous to use "exec" here? It looks okay to me, but I feel as though I should always be suspicious of using it.)
I think you're right. The exec'd code could have bad side effects. I'm about to attach a patch that uses this AST code, instead.
Changed 3 years ago by mpatel
-
attachment
trac_8325-cython_argspec.2.patch
added
AST version. sage repo.
comment:6 Changed 3 years ago by mpatel
- Status changed from needs_work to needs_review
I've attached the AST version, which seems to work for me, although I have no formal training in computer science. If the patch looks good, I'll add a sagenb repository patch.
comment:7 Changed 3 years ago by jhpalmieri
On one hand, this seems to fix the two particular doctests in question. On the other, it's not perfect. I can see two problems, one of which I know how to fix:
- if the source has the (unlikely) form def f({(1,2,3): True}): ..., then this version (and all previous versions) will think that the arg spec ends after (1,2,3):. The function _sage_getargspec_from_ast can actually handle this kind of thing, though, so I think we should pass the entire source code to it, rather than truncate at the first ):. That is, delete line 470 and change line 471 from
proxy = 'def dummy' + source[beg:end] + '\n return'
toproxy = 'def dummy' + source[beg:] + '\n return'
- if the docstring has type information, it can't handle it. I don't know what to do about this, or if it's worth it.
Should we fix the first problem and then go ahead with this? I also notice that the methods for SageArgSpecVisitor don't have doctests. Is that possible for these sorts of things? I know nothing about ast.
Changed 3 years ago by mpatel
-
attachment
trac_8325-cython_argspec.3.patch
added
Another clause. More doctests. Apply only this patch. sage repo.
comment:8 Changed 3 years ago by mpatel
V3:
- Implements your idea to pass the entire source code. I've included the previous version as a fallback, since LLL has a Cython-only construct:
R = <Matrix_integer_dense>self.new_matrix(entries=map(ZZ,A.list()))
- Has extra, more direct doctests of SageArgSpecVisitor's methods.
I don't mind leaving the second problem for another day.
comment:9 Changed 3 years ago by jhpalmieri
- Status changed from needs_review to positive_review
Looks good. All doctests pass, fixes the two problems.
Changed 3 years ago by mpatel
-
attachment
sagenb_8325-cython_argspec.patch
added
For SageNB's sageinspect.py. sagenb repo.
comment:10 Changed 3 years ago by mpatel
- Status changed from positive_review to needs_work
I've attached a version for SageNB.
comment:12 Changed 3 years ago by jhpalmieri
- Status changed from needs_review to needs_work
Unless I'm misunderstanding, the sagenb patch needs work: all of the doctests in the patch import from sage.misc.sageinspect rather than from sagenb....
Changed 3 years ago by mpatel
-
attachment
sagenb_8325-cython_argspec.2.patch
added
Fix doctest imports. Replaces previous sagenb patch.
comment:13 Changed 3 years ago by mpatel
- Status changed from needs_work to needs_review
Oops. Sorry about that. V2 is up.
comment:15 Changed 3 years ago by mhansen
- Owner mvngu deleted
- Merged in set to sage-4.3.4.alpha1
I've merged the Sage library patch. When this is merged in the notebook, we can close this ticket.
comment:16 Changed 3 years ago by mpatel
- Status changed from positive_review to closed
- Resolution set to fixed
Merged sagenb patch V2 in sagenb-0.7.5.3, which will be at #8435.
