"TypeError: not a constant polynomial" when trying to fix `normalize_coordinates` in `projective_morphism.py`

45 views
Skip to first unread message

Jing Guo

unread,
Jun 25, 2023, 4:54:07 PM6/25/23
to sage-devel
Hello everyone,

As it is mentioned [here](https://github.com/sagemath/sage/issues/35797), we are trying to resolve this issue, which is mainly going on in this [PR](https://github.com/sagemath/sage/pull/35809).

One of the questions that we face is that when running the following example code (the last test of the docstring):

sage: R.<x> = QQ[]
sage: K.<a> = NumberField(3*x^2 + 1)
sage: P.<z,w> = ProjectiveSpace(K, 1)
sage: f = DynamicalSystem_projective([a*(z^2 + w^2), z*w])
sage: f.normalize_coordinates(); f

We obtain the following error:

> TypeError: not a constant polynomial

I did some search online but couldn't find anything helpful, so I was wondering if you could give me some hints or ideas?

Thank you!

Jing

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In [28], line 5
      3 P = ProjectiveSpace(K, Integer(1), names=('z', 'w',)); (z, w,) = P._first_ngens(2)
      4 f = DynamicalSystem_projective([a*(z**Integer(2) + w**Integer(2)), z*w])
----> 5 f.normalize_coordinates(); f

File ~/github/sage/src/sage/schemes/projective/projective_morphism.py:993, in SchemeMorphism_polynomial_projective_space.normalize_coordinates(self, **kwds)
    991         denom = lcm([self[i].denominator() for i in range(len(list(self)))])
    992     else:
--> 993         denom = R.ideal(list(self)).absolute_norm().denominator()
    995     self.scale_by(denom)
    997 # There are cases, such as the example above over GF(7),
    998 # where we want to compute GCDs, but NOT in the case
    999 # where R is a NumberField of class number > 1.

File ~/github/sage/src/sage/rings/number_field/number_field.py:3632, in NumberField_generic.ideal(self, *gens, **kwds)
   3607 """
   3608 Return a fractional ideal of the field, except for the
   3609 zero ideal, which is not a fractional ideal.
   (...)
   3629     Fractional ideal (1)
   3630 """
   3631 try:
-> 3632     return self.fractional_ideal(*gens, **kwds)
   3633 except ValueError:
   3634     return sage.rings.ring.Ring.ideal(self, gens, **kwds)

File ~/github/sage/src/sage/rings/number_field/number_field.py:3749, in NumberField_generic.fractional_ideal(self, *gens, **kwds)
   3747     else:
   3748         gens = I.gens()
-> 3749 return self._fractional_ideal_class_()(self, gens, **kwds)

File ~/github/sage/src/sage/rings/number_field/number_field_ideal.py:1814, in NumberFieldFractionalIdeal.__init__(self, field, gens, coerce)
   1812     gens = gens[0]
   1813 if misc.exists(gens,bool)[0]:
-> 1814     NumberFieldIdeal.__init__(self, field, gens)
   1815 else:
   1816     raise ValueError("gens must have a nonzero element (zero ideal is not a fractional ideal)")

File ~/github/sage/src/sage/rings/number_field/number_field_ideal.py:138, in NumberFieldIdeal.__init__(self, field, gens, coerce)
    136 if len(gens)==0:
    137     raise ValueError("gens must have length at least 1 (zero ideal is not a fractional ideal)")
--> 138 Ideal_generic.__init__(self, field, gens, coerce)
    139 if field.absolute_degree() == 2:
    140     self.quadratic_form = self._quadratic_form

File ~/github/sage/src/sage/rings/ideal.py:274, in Ideal_generic.__init__(self, ring, gens, coerce)
    272     gens = [gens]
    273 if coerce:
--> 274     gens = [ring(x) for x in gens]
    276 gens = tuple(gens)
    277 if len(gens) == 0:

File ~/github/sage/src/sage/rings/ideal.py:274, in <listcomp>(.0)
    272     gens = [gens]
    273 if coerce:
--> 274     gens = [ring(x) for x in gens]
    276 gens = tuple(gens)
    277 if len(gens) == 0:

File ~/github/sage/src/sage/structure/parent.pyx:901, in sage.structure.parent.Parent.__call__()
    899 if mor is not None:
    900     if no_extra_args:
--> 901         return mor._call_(x)
    902     else:
    903         return mor._call_with_args(x, args, kwds)

File ~/github/sage/src/sage/rings/polynomial/polynomial_element.pyx:12240, in sage.rings.polynomial.polynomial_element.ConstantPolynomialSection._call_()
  12238                 return <Element>((<Polynomial>x).constant_coefficient())
  12239         else:
> 12240             raise TypeError("not a constant polynomial")
  12241
  12242 cdef class PolynomialBaseringInjection(Morphism):

TypeError: not a constant polynomial

Ben Hutz

unread,
Jun 26, 2023, 8:51:30 AM6/26/23
to sage-devel
The issue is with this line of the PR:

denom = R.ideal(list(self)).absolute_norm().denominator()

list(self) is a list of polynomials. You want the ideal of the coefficients of those polynomials.
Reply all
Reply to author
Forward
0 new messages