Open rwst opened 10 years ago
The error happens when (in Polyring_FpT_coerce._call_with_args
) the argument is converted to Polynomial_zmod_flint
. As the whole file fraction_field_FpT.pyx
is using flint, must we implement it completely via ntl, or does it suffice to fix that single conversion?
As no conversion seems possible, a better error message is displayed.
New commits:
7d0e789 | 15954: replace TypeError with more informative message |
Author: Ralf Stephan
Branch pushed to git repo; I updated commit sha1. New commits:
ded2b6d | Merge branch 'develop' into t/15954/polyring_fpt_coerce_cannot_handle_polynomial_modn_dense_ntl |
Reviewer: Karl-Dieter Crisman
I like this in general but it's really more than just the fractions, it's when you make the field, so it should also show up here, or maybe even when you make the fraction field, I don't know?
sage: R.<x> = PolynomialRing(Integers(101), implementation='ntl')
sage: R.fraction_field()
Fraction Field of Univariate Polynomial Ring in x over Ring of integers modulo 101 (using NTL)
sage: K = R.fraction_field()
sage: K
Fraction Field of Univariate Polynomial Ring in x over Ring of integers modulo 101 (using NTL)
sage: K(1)
1
sage: K(2)
2
sage: K(x)
TypeError: Cannot convert sage.rings.polynomial.polynomial_modn_dense_ntl.Polynomial_dense_mod_p to sage.rings.polynomial.polynomial_zmod_flint.Polynomial_zmod_flint
The issue was resolved independently. In 8.2.beta2 we now get:
sage: R.<x> = PolynomialRing(Integers(101), implementation='NTL')
sage: 1/x
...
NotImplementedError: Fraction fields not implemented for this type.
I get a failure already on the first line:
sage: R.<x> = PolynomialRing(Integers(101), implementation='ntl')
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-2-d6c1b40b741c> in <module>()
----> 1 R = PolynomialRing(Integers(Integer(101)), implementation='ntl', names=('x',)); (x,) = R._first_ngens(1)
/usr/local/src/sage-config/local/lib/python2.7/site-packages/sage/rings/polynomial/polynomial_ring_constructor.pyc in PolynomialRing(base_ring, *args, **kwds)
648 return _multi_variate(base_ring, names, **kwds)
649 else:
--> 650 return _single_variate(base_ring, names, **kwds)
651
652
/usr/local/src/sage-config/local/lib/python2.7/site-packages/sage/rings/polynomial/polynomial_ring_constructor.pyc in _single_variate(base_ring, name, sparse, implementation, order)
734 else:
735 constructor = polynomial_ring.PolynomialRing_commutative
--> 736 implementation_names = constructor._implementation_names(implementation, base_ring, sparse)
737 implementation = implementation_names[0]
738
/usr/local/src/sage-config/local/lib/python2.7/site-packages/sage/rings/polynomial/polynomial_ring.pyc in _implementation_names(cls, implementation, base_ring, sparse)
504 if names is NotImplemented:
505 raise ValueError("unknown implementation %r for %s polynomial rings over %r" %
--> 506 (implementation, "sparse" if sparse else "dense", base_ring))
507 assert isinstance(names, list)
508 assert implementation in names
ValueError: unknown implementation 'ntl' for dense polynomial rings over Ring of integers modulo 101
They changed the keyword to NTL
without matching lower case. With that I get an informative error message.
Description changed:
---
+++
@@ -1,28 +1,61 @@
-TypeError Traceback (most recent call last)
-
-/home/ralf/sage/local/lib/python2.7/site-packages/sage/structure/element.so in sage.structure.element.RingElement.div (sage/structure/element.c:15915)() +/usr/local/src/sage-config/src/sage/rings/integer.pyx in sage.rings.integer.Integer.div (build/cythonized/sage/rings/integer.c:13187)()
-/home/ralf/sage/local/lib/python2.7/site-packages/sage/structure/coerce.so in sage.structure.coerce.CoercionModel_cache_maps.bin_op (sage/structure/coerce.c:7514)() +/usr/local/src/sage-config/src/sage/structure/coerce.pyx in sage.structure.coerce.CoercionModel_cache_maps.bin_op (build/cythonized/sage/structure/coerce.c:9515)()
-/home/ralf/sage/local/lib/python2.7/site-packages/sage/structure/coerce.so in sage.structure.coerce.CoercionModel_cache_maps.bin_op (sage/structure/coerce.c:7459)() +/usr/local/src/sage-config/src/sage/rings/polynomial/polynomial_element.pyx in sage.rings.polynomial.polynomial_element.Polynomial.div (build/cythonized/sage/rings/polynomial/polynomial_element.c:23976)()
-/home/ralf/sage/local/lib/python2.7/site-packages/sage/rings/polynomial/polynomial_element.so in sage.rings.polynomial.polynomial_element.Polynomial.div (sage/rings/polynomial/polynomial_element.c:17669)() +/usr/local/src/sage-config/src/sage/rings/polynomial/polynomial_element.pyx in sage.rings.polynomial.polynomial_element.Polynomial.truediv (build/cythonized/sage/rings/polynomial/polynomial_element.c:23681)()
-/home/ralf/sage/local/lib/python2.7/site-packages/sage/structure/element.so in sage.structure.element.RingElement.div (sage/structure/element.c:15897)() +/usr/local/src/sage-config/src/sage/structure/element.pyx in sage.structure.element.RingElement.div (build/cythonized/sage/structure/element.c:17628)()
-/home/ralf/sage/local/lib/python2.7/site-packages/sage/structure/element.so in sage.structure.element.RingElement.div (sage/structure/element.c:16030)() +/usr/local/src/sage-config/src/sage/structure/parent.pyx in sage.structure.parent.Parent.call (build/cythonized/sage/structure/parent.c:9433)()
-/home/ralf/sage/local/lib/python2.7/site-packages/sage/structure/parent.so in sage.structure.parent.Parent.call (sage/structure/parent.c:8852)() +/usr/local/src/sage-config/src/sage/rings/fraction_field_FpT.pyx in sage.rings.fraction_field_FpT.Polyring_FpT_coerce._call_with_args (build/cythonized/sage/rings/fraction_field_FpT.cpp:12573)()
-TypeError: Cannot convert sage.rings.polynomial.polynomial_modn_dense_ntl.Polynomial_dense_mod_p to sage.rings.polynomial.polynomial_zmod_flint.Polynomial_zmod_flint +NotImplementedError: Fraction fields not implemented for this type.
This makes NTL modpolys unusable in fractions.
Replying to @rwst:
The issue was resolved independently.
Which issue was "solved"? It still doesn't work.
Well I opened the issue and after that decided to be satisfied with a good error. But hijack away...I don't claim ownership.
I don't personally care... but changing the error message does not fix the issue.
This makes NTL modpolys unusable in fractions.
Component: coercion
Author: Ralf Stephan
Branch/Commit: u/rws/polyring_fpt_coerce_cannot_handle_polynomial_modn_dense_ntl @
ded2b6d
Reviewer: Karl-Dieter Crisman
Issue created by migration from https://trac.sagemath.org/ticket/15954