Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
sage.symbolic.expression: Merge new_Expression_from_pyobject and new_…
Browse files Browse the repository at this point in the history
…Expression_force_pyobject
  • Loading branch information
Matthias Koeppe committed Aug 25, 2021
1 parent 5d062ed commit 3f1ac2e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
3 changes: 1 addition & 2 deletions src/sage/symbolic/expression.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ cpdef bint is_Expression(x)
cpdef _repr_Expression(x)
cpdef _latex_Expression(x)
cpdef new_Expression(parent, x)
cpdef new_Expression_from_pyobject(parent, x)
cpdef new_Expression_force_pyobject(parent, x, bint force=?, bint recursive=?)
cpdef new_Expression_from_pyobject(parent, x, bint force=?, bint recursive=?)
cpdef new_Expression_wild(parent, unsigned int n=?)
cpdef new_Expression_symbol(parent, name=?, latex_name=?, domain=?)
19 changes: 12 additions & 7 deletions src/sage/symbolic/expression.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -13305,11 +13305,6 @@ cdef Expression new_Expression_from_GEx(parent, GEx juice):
return nex


cpdef new_Expression_from_pyobject(parent, x):
cdef GEx exp = x
return new_Expression_from_GEx(parent, exp)


cpdef new_Expression(parent, x):
r"""
Convert ``x`` into the symbolic expression ring ``parent``.
Expand Down Expand Up @@ -13394,7 +13389,7 @@ cpdef new_Expression(parent, x):
return new_Expression_from_GEx(parent, exp)


cpdef new_Expression_force_pyobject(parent, x, bint force=False, bint recursive=True):
cpdef new_Expression_from_pyobject(parent, x, bint force=True, bint recursive=True):
r"""
Wrap the given Python object in a symbolic expression even if it
cannot be coerced to the Symbolic Ring.
Expand All @@ -13405,7 +13400,7 @@ cpdef new_Expression_force_pyobject(parent, x, bint force=False, bint recursive=
- ``x`` - a Python object.
- ``force`` - bool, default ``False``, if True, the Python object
- ``force`` - bool, default ``True``, if True, the Python object
is taken as is without attempting coercion or list traversal.
- ``recursive`` - bool, default ``True``, disables recursive
Expand All @@ -13417,6 +13412,16 @@ cpdef new_Expression_force_pyobject(parent, x, bint force=False, bint recursive=
Rational Field
sage: type(t)
<type 'sage.symbolic.expression.Expression'>
sage: from sage.symbolic.expression import new_Expression_from_pyobject
sage: t = new_Expression_from_pyobject(SR, 17); t
sage: type(t)
sage: t2 = new_Expression_from_pyobject(SR, t, False); t2
sage: t2 is t
sage: tt = new_Expression_from_pyobject(SR, t, True); tt
sage: tt is t
"""
cdef GEx exp
cdef GExprSeq ex_seq
Expand Down
6 changes: 3 additions & 3 deletions src/sage/symbolic/ring.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ from sage.symbolic.expression cimport (
_repr_Expression,
new_Expression,
new_Expression_from_pyobject,
new_Expression_force_pyobject,
new_Expression_wild,
new_Expression_symbol,
)
Expand Down Expand Up @@ -440,7 +439,7 @@ cdef class SymbolicRing(CommutativeRing):
(Rational Field, (x, x + 1, x + 2), Complex Field with 53 bits
of precision)
"""
return new_Expression_force_pyobject(self, x, force, recursive)
return new_Expression_from_pyobject(self, x, force, recursive)

def wild(self, unsigned int n=0):
r"""
Expand Down Expand Up @@ -1235,7 +1234,8 @@ cdef class NumpyToSRMorphism(Morphism):
sage: SR(numpy.complex64(1jr)).pyobject().parent()
Complex Double Field
"""
return new_Expression_from_pyobject(self.codomain(), self._intermediate_ring(a))
return new_Expression_from_pyobject(self.codomain(), self._intermediate_ring(a), True)


cdef class UnderscoreSageMorphism(Morphism):
def __init__(self, t, R):
Expand Down

0 comments on commit 3f1ac2e

Please sign in to comment.