Skip to content

Commit

Permalink
For isinstance tests, import Expression from sage.structure.element
Browse files Browse the repository at this point in the history
  • Loading branch information
mkoeppe committed Oct 19, 2021
1 parent 832dad7 commit 6b0fbda
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/sage/arith/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -4841,7 +4841,7 @@ def falling_factorial(x, a):
- Jaap Spies (2006-03-05)
"""
from sage.symbolic.expression import Expression
from sage.structure.element import Expression
x = py_scalar_to_element(x)
a = py_scalar_to_element(a)
if (isinstance(a, Integer) or
Expand Down Expand Up @@ -4935,7 +4935,7 @@ def rising_factorial(x, a):
- Jaap Spies (2006-03-05)
"""
from sage.symbolic.expression import Expression
from sage.structure.element import Expression
x = py_scalar_to_element(x)
a = py_scalar_to_element(a)
if (isinstance(a, Integer) or
Expand Down
2 changes: 1 addition & 1 deletion src/sage/matrix/matrix0.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -5832,7 +5832,7 @@ cdef class Matrix(sage.structure.element.Matrix):
[ 2*k + 2 -2*k - 1]
[ 2*k + 1 -2*k]
"""
from sage.symbolic.expression import Expression
from sage.structure.element import Expression

if not self.is_square():
raise ArithmeticError("self must be a square matrix")
Expand Down
2 changes: 1 addition & 1 deletion src/sage/matrix/matrix_integer_dense.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -963,7 +963,7 @@ cdef class Matrix_integer_dense(Matrix_dense):
try:
n = Integer(n)
except TypeError:
from sage.symbolic.expression import Expression
from sage.structure.element import Expression
if isinstance(n, Expression):
from sage.matrix.matrix2 import _matrix_power_symbolic
return _matrix_power_symbolic(self, n)
Expand Down
6 changes: 3 additions & 3 deletions src/sage/numerical/optimize.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ def minimize(func, x0, gradient=None, hessian=None, algorithm="default",
sage: minimize(rosen, [.1,.3,.4], gradient=rosen_der, algorithm="bfgs") # abs tol 1e-6
(1.0, 1.0, 1.0)
"""
from sage.symbolic.expression import Expression
from sage.structure.element import Expression
from sage.ext.fast_callable import fast_callable
import numpy
from scipy import optimize
Expand Down Expand Up @@ -505,7 +505,7 @@ def minimize_constrained(func,cons,x0,gradient=None,algorithm='default', **args)
sage: minimize_constrained(f, c, [100, 300])
(805.985..., 1005.985...)
"""
from sage.symbolic.expression import Expression
from sage.structure.element import Expression
from sage.ext.fast_callable import fast_callable
import numpy
from scipy import optimize
Expand Down Expand Up @@ -751,7 +751,7 @@ def find_fit(data, model, initial_guess = None, parameters = None, variables = N
if data.ndim != 2:
raise ValueError("data has to be a two dimensional table of floating point numbers")

from sage.symbolic.expression import Expression
from sage.structure.element import Expression

if isinstance(model, Expression):
if variables is None:
Expand Down
2 changes: 1 addition & 1 deletion src/sage/rings/asymptotic/asymptotic_ring.py
Original file line number Diff line number Diff line change
Expand Up @@ -1684,7 +1684,7 @@ def __pow__(self, exponent, precision=None):
else:
return self.__pow_number__(exponent, precision=precision)

from sage.symbolic.expression import Expression
from sage.structure.element import Expression
if isinstance(exponent, Expression) and exponent.is_constant():
return self.__pow_number__(exponent, precision=precision)

Expand Down
2 changes: 1 addition & 1 deletion src/sage/rings/complex_arb.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,7 @@ class ComplexBallField(UniqueRepresentation, sage.rings.abc.ComplexBallField):
# this is not implemented via an _acb_() method, because such a
# conversion method would also be called by things like
# CBF(re_expr, im_expr).
from sage.symbolic.expression import Expression
from sage.structure.element import Expression
if isinstance(x, Expression):
# Parse the expression. Despite the method name, the result
# will be a complex ball.
Expand Down
2 changes: 1 addition & 1 deletion src/sage/rings/finite_rings/integer_mod.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ cdef class IntegerMod_abstract(FiniteRingElement):
try:
z = integer_ring.Z(value)
except (TypeError, ValueError):
from sage.symbolic.expression import Expression
from sage.structure.element import Expression
if isinstance(value, Expression):
value = value.pyobject()
else:
Expand Down
4 changes: 2 additions & 2 deletions src/sage/rings/polynomial/laurent_polynomial_ring.py
Original file line number Diff line number Diff line change
Expand Up @@ -973,7 +973,7 @@ def _element_constructor_(self, x):
...
TypeError: fraction must have unit denominator
"""
from sage.symbolic.expression import Expression
from sage.structure.element import Expression
from sage.rings.fraction_field_element import FractionFieldElement
if isinstance(x, Expression):
return x.laurent_polynomial(ring=self)
Expand Down Expand Up @@ -1169,7 +1169,7 @@ def _element_constructor_(self, x, mon=None):
sage: R(sum(P.gens()), (-1,-1,-1))
y^-1*z^-1 + x^-1*z^-1 + x^-1*y^-1
"""
from sage.symbolic.expression import Expression
from sage.structure.element import Expression

if mon is not None:
return self.element_class(self, x, mon)
Expand Down
2 changes: 1 addition & 1 deletion src/sage/sets/real_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -1103,7 +1103,7 @@ def __classcall__(cls, *args, **kwds):
if kwds:
raise TypeError(f'unless manifold keywords {manifold_keywords} are given, RealSet constructors take no keyword arguments')

from sage.symbolic.expression import Expression
from sage.structure.element import Expression
if len(args) == 1 and isinstance(args[0], RealSet):
return args[0] # common optimization
intervals = []
Expand Down

0 comments on commit 6b0fbda

Please sign in to comment.