File tree Expand file tree Collapse file tree 1 file changed +10
-7
lines changed
src/sage/rings/polynomial Expand file tree Collapse file tree 1 file changed +10
-7
lines changed Original file line number Diff line number Diff line change @@ -2701,14 +2701,18 @@ cdef class MPolynomial(CommutativeRingElement):
2701
2701
[HMMS2019 ]_. The second reference gives the characterization of
2702
2702
Lorentzian polynomials applied in this implementation explicitly.
2703
2703
"""
2704
+ from sage.rings.imaginary_unit import I
2705
+
2704
2706
# function to handle return value when reason requested
2705
2707
def result (val , explanation = None ):
2706
- if explain:
2707
- return (val, explanation)
2708
- else :
2709
- return val
2708
+ return (val, explanation) if explain else val
2710
2709
2711
- if not self .base_ring().is_subring(RealField()):
2710
+ try :
2711
+ # this would better be handled by a category of RealFields()
2712
+ self .base_ring()(I)
2713
+ except (ValueError , TypeError ):
2714
+ pass
2715
+ else :
2712
2716
raise NotImplementedError (" is_lorentzian only implemented for real polynomials" )
2713
2717
2714
2718
if self .is_zero():
@@ -2811,8 +2815,7 @@ def _is_M_convex_(points):
2811
2815
points_set = set (map (tuple , points))
2812
2816
if not points_set:
2813
2817
return True
2814
- elt = next(islice(points_set, 0 , 1 )))
2815
- dim = len (elt)
2818
+ dim = len (next(iter (points_set)))
2816
2819
if any (len (p) != dim for p in points_set):
2817
2820
raise ValueError (" input points are not the same dimension" )
2818
2821
if any (entry not in ZZ for p in points_set for entry in p):
You can’t perform that action at this time.
0 commit comments