sagemath/sage

sage.symbolic.function: Remove direct use of cimports from pynac

Closed this issue · 34 comments

Similar to what is done in #32391. Mechanical refactoring to use new helper functions defined in sage.symbolic.expression instead of directly cimporting from sage.libs.pynac

Preparation for #32386.

CC: @kliem @tscrim

Component: symbolics

Author: Matthias Koeppe

Branch/Commit: 06e8c31

Reviewer: Jonathan Kliem

Issue created by migration from https://trac.sagemath.org/ticket/32407

Branch pushed to git repo; I updated commit sha1. New commits:

50048aasage.symbolic.function.Function._register_function: Refactor through new function sage.symbolic.expression.register_or_update_function
a2f97a1sage.symbolic.function.GinacFunction._register_function: Refactor through sage.symbolic.expression.register_or_update_function

Changed commit from a2f97a1 to e81e6c7

Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:

4ac54dfsrc/sage/symbolic/function.pyx: Replace cimport * by more specific cimport
6f49aeesage.symbolic.function.Function.__call__: Refactor through new helper function sage.symbolic.expression.call_by_ginac_serial
2f92b90sage.symbolic.function.Function._register_function: Refactor through new function sage.symbolic.expression.register_or_update_function
e81e6c7sage.symbolic.function.GinacFunction._register_function: Refactor through sage.symbolic.expression.register_or_update_function

Branch pushed to git repo; I updated commit sha1. New commits:

d397ef1sage.symbolic.function: Remove unused imports, cimports

Changed commit from e81e6c7 to d397ef1

Branch pushed to git repo; I updated commit sha1. New commits:

1c43dbesage.symbolic.function.{GinacFunction,BuiltinFunction}._is_registered: Refactor through new function sage.symbolic.expression.find_registered_function; remove last pynac import

Changed commit from d397ef1 to 1c43dbe

Changed dependencies from #32391 to none

Author: Matthias Koeppe

Description changed:

--- 
+++ 
@@ -1,4 +1,4 @@
-Similar and in extension of #32391.
+Similar to what is done in #32391. Mechanical refactoring to use new helper functions defined in `sage.symbolic.expression` instead of directly `cimport`ing from `sage.libs.pynac`
 
 Preparation for #32386.
 

Branch pushed to git repo; I updated commit sha1. New commits:

9d4fe5fsage.symbolic.function: Remove unused cimport

Changed commit from 1c43dbe to 9d4fe5f

kliem commented

Reviewer: Jonathan Kliem

kliem commented
comment:8

The cpdef functions should have doctests for coverage.

Changed commit from 9d4fe5f to d680c35

Branch pushed to git repo; I updated commit sha1. New commits:

d680c35sage.symbolic.expression.call_registered_function: Rename from call_by_ginac_serial

Changed commit from d680c35 to 47adbcc

Branch pushed to git repo; I updated commit sha1. New commits:

1f761d8src/sage/symbolic/pynac_function_impl.pxi: Split out from src/sage/symbolic/expression.pyx
47adbccsrc/sage/symbolic/pynac_function_impl.pxi: Add doctests
kliem commented
comment:12
         sage: from sage.symbolic.function import BuiltinFunction
-        sage: from sage.symbolic.expression import register_or_update_function, call_registered_function
         sage: class Archosaurian(BuiltinFunction):
         ....:     def __init__(self):
         ....:         BuiltinFunction.__init__(self, 'archsaur', nargs=1)
         ....:     def _eval_(self, x):
         ....:         return x * exp(x)
         sage: archsaur = Archosaurian()  # indirect doctest
         sage: archsaur(2)
         2*e^2

The import isn't used.

Changed commit from 47adbcc to 7f1e5be

Branch pushed to git repo; I updated commit sha1. New commits:

7f1e5besrc/sage/symbolic/pynac_function_impl.pxi: Remove unused import in doctest
comment:15

patchbot is morally green (failures are from a missing docbuild on the patchbot)

kliem commented
comment:16

Actually this ticket leads to failure of docbuild and this should be fixed.

It is fixed in #32386 and can be somewhat cherry-picked from there.

The problem seems to be with

:class:`Expression`s

This doesn't seem to work, but you can do

:class:`Expression` (Expressions)

which supposedly has Expressions as the link text
(for some reason I have fixed it with Expression's in #32386, which is wrong grammar.

comment:17

Ah! Thanks for the explanation

Changed commit from 7f1e5be to 06e8c31

Branch pushed to git repo; I updated commit sha1. New commits:

06e8c31src/sage/symbolic/pynac_function_impl.pxi: Fix doc markup
comment:19

Replying to @kliem:

Actually this ticket leads to failure of docbuild and this should be fixed.

It is fixed in #32386 and can be somewhat cherry-picked from there.

The problem seems to be with

:class:`Expression`s

This doesn't seem to work, but you can do

:class:`Expression` (Expressions)

which supposedly has Expressions as the link text
(for some reason I have fixed it with Expression's in #32386, which is wrong grammar.

That is also not quite correct as I believe you want

:class:`Expressions <Expression>`

to show Expressions but link to the class Expression. Although you can also do something like :class:`Expression`-s or 's, but I won't worry too much about the grammar there...

comment:20

In the meantime (in 06e8c31) I have reworded it in a different way

kliem commented
comment:21

Replying to @tscrim:

Replying to @kliem:

Actually this ticket leads to failure of docbuild and this should be fixed.

It is fixed in #32386 and can be somewhat cherry-picked from there.

The problem seems to be with

:class:`Expression`s

This doesn't seem to work, but you can do

:class:`Expression` (Expressions)

which supposedly has Expressions as the link text
(for some reason I have fixed it with Expression's in #32386, which is wrong grammar.

That is also not quite correct as I believe you want

:class:`Expressions <Expression>`

to show Expressions but link to the class Expression. Although you can also do something like :class:`Expression`-s or 's, but I won't worry too much about the grammar there...

I see. I got confused by the documentation.

kliem commented
comment:22

LGTM.

comment:23

Thank you!