[sage-devel] Re: bug in exquo?

2022-10-12 Thread 'Martin R' via sage-devel
Easy fix at https://trac.sagemath.org/ticket/34653, please review!

Martin

On Thursday, 13 October 2022 at 00:05:37 UTC+2 Martin R wrote:

> OK, I think now I am down to what's quite clearly a bug:
>
> sage: P. = PolynomialRing(SR)
> sage: R. = PolynomialRing(P, sparse=False); R
> Univariate Polynomial Ring in z over Multivariate Polynomial Ring in x, y 
> over Symbolic Ring
> sage: A = -x*z^2 + x*z
> sage: B = -x
> sage: A // B
> z^2 - z
> sage: P. = PolynomialRing(SR)
> sage: R. = PolynomialRing(P, sparse=True); R
> Sparse Univariate Polynomial Ring in z over Multivariate Polynomial Ring 
> in x, y over Symbolic Ring
> sage: A = -x*z^2 + x*z
> sage: B = -x
> sage: A // B
> ---
> TypeError Traceback (most recent call last)
> File 
> ~/sage-develop/src/sage/rings/polynomial/polynomial_element_generic.py:852, 
> in Polynomial_generic_sparse.quo_rem(self, other)
> 851 try:
> --> 852 c = R(rem.leading_coefficient() * ~other.leading_coefficient())
> 853 except TypeError:
>
> File ~/sage-develop/src/sage/structure/parent.pyx:897, in 
> sage.structure.parent.Parent.__call__()
> 896 if no_extra_args:
> --> 897 return mor._call_(x)
> 898 else:
>
> File ~/sage-develop/src/sage/structure/coerce_maps.pyx:161, in 
> sage.structure.coerce_maps.DefaultConvertMap_unique._call_()
> 160 print(type(C._element_constructor), C._element_constructor)
> --> 161 raise
> 162 
>
> File ~/sage-develop/src/sage/structure/coerce_maps.pyx:156, in 
> sage.structure.coerce_maps.DefaultConvertMap_unique._call_()
> 155 try:
> --> 156 return C._element_constructor(x)
> 157 except Exception:
>
> File ~/sage-develop/src/sage/rings/polynomial/polynomial_ring.py:456, in 
> PolynomialRing_general._element_constructor_(self, x, check, is_gen, 
> construct, **kwds)
> 455 else:
> --> 456 raise TypeError("denominator must be a unit")
> 457 elif isinstance(x, pari_gen):
>
> TypeError: denominator must be a unit
>
> During handling of the above exception, another exception occurred:
>
> ArithmeticError   Traceback (most recent call last)
> Input In [39], in ()
> > 1 A // B
>
> File ~/sage-develop/src/sage/structure/element.pyx:1840, in 
> sage.structure.element.Element.__floordiv__()
>1838 return (left)._floordiv_(right)
>1839 if BOTH_ARE_ELEMENT(cl):
> -> 1840 return coercion_model.bin_op(left, right, floordiv)
>1841 
>1842 try:
>
> File ~/sage-develop/src/sage/structure/coerce.pyx:1204, in 
> sage.structure.coerce.CoercionModel.bin_op()
>1202 self._record_exception()
>1203 else:
> -> 1204 return PyObject_CallObject(op, xy)
>1205 
>1206 if op is mul:
>
> File ~/sage-develop/src/sage/structure/element.pyx:1838, in 
> sage.structure.element.Element.__floordiv__()
>1836 cdef int cl = classify_elements(left, right)
>1837 if HAVE_SAME_PARENT(cl):
> -> 1838 return (left)._floordiv_(right)
>1839 if BOTH_ARE_ELEMENT(cl):
>1840 return coercion_model.bin_op(left, right, floordiv)
>
> File ~/sage-develop/src/sage/rings/polynomial/polynomial_element.pyx:2872, 
> in sage.rings.polynomial.polynomial_element.Polynomial._floordiv_()
>2870 # quite typical when removing gcds...
>2871 return self
> -> 2872 Q, _ = self.quo_rem(right)
>2873 return Q
>2874 
>
> File ~/sage-develop/src/sage/structure/element.pyx:4498, in 
> sage.structure.element.coerce_binop.new_method()
>4496 def new_method(self, other, *args, **kwargs):
>4497 if have_same_parent(self, other):
> -> 4498 return method(self, other, *args, **kwargs)
>4499 else:
>4500 a, b = coercion_model.canonical_coercion(self, other)
>
> File 
> ~/sage-develop/src/sage/rings/polynomial/polynomial_element_generic.py:854, 
> in Polynomial_generic_sparse.quo_rem(self, other)
> 852 c = R(rem.leading_coefficient() * ~other.leading_coefficient())
> 853 except TypeError:
> --> 854 raise ArithmeticError("Division non exact (consider coercing 
> to polynomials over the fraction field)")
> 855 e = rem.degree() - d
> 856 quo += c*R.one().shift(e)
>
> ArithmeticError: Division non exact (consider coercing to polynomials over 
> the fraction field)
> sage: 
>
> On Wednesday, 12 October 2022 at 23:50:04 UTC+2 Martin R wrote:
>
>> Possibly related:
>>
>> sage: P. = PolynomialRing(SR)
>> sage: R. = PolynomialRing(P); R
>> Univariate Polynomial Ring in z over Multivariate Polynomial Ring in x, y 
>> over Symbolic Ring
>> sage: num = -x*z^2 + x*z
>> sage: den = x*z^2 + (-x-1)*z + 1
>> sage: num.gcd(den)
>> z - 1
>> sage: P. = PolynomialRing(SR)
>> sage: R. = PolynomialRing(P, sparse=True); R
>> Sparse Univariate Polynomial Ring in z over Multivariate Polynomial Ring 
>> in x, y over Symbolic Ring
>> sage: num = -x*z^2 + x*z
>> sage: den = x*z^2 + (-x-1)*z + 1
>> sage: num.gcd(den)
>>

[sage-devel] Re: bug in exquo?

2022-10-12 Thread 'Martin R' via sage-devel
OK, I think now I am down to what's quite clearly a bug:

sage: P. = PolynomialRing(SR)
sage: R. = PolynomialRing(P, sparse=False); R
Univariate Polynomial Ring in z over Multivariate Polynomial Ring in x, y 
over Symbolic Ring
sage: A = -x*z^2 + x*z
sage: B = -x
sage: A // B
z^2 - z
sage: P. = PolynomialRing(SR)
sage: R. = PolynomialRing(P, sparse=True); R
Sparse Univariate Polynomial Ring in z over Multivariate Polynomial Ring in 
x, y over Symbolic Ring
sage: A = -x*z^2 + x*z
sage: B = -x
sage: A // B
---
TypeError Traceback (most recent call last)
File 
~/sage-develop/src/sage/rings/polynomial/polynomial_element_generic.py:852, 
in Polynomial_generic_sparse.quo_rem(self, other)
851 try:
--> 852 c = R(rem.leading_coefficient() * ~other.leading_coefficient())
853 except TypeError:

File ~/sage-develop/src/sage/structure/parent.pyx:897, in 
sage.structure.parent.Parent.__call__()
896 if no_extra_args:
--> 897 return mor._call_(x)
898 else:

File ~/sage-develop/src/sage/structure/coerce_maps.pyx:161, in 
sage.structure.coerce_maps.DefaultConvertMap_unique._call_()
160 print(type(C._element_constructor), C._element_constructor)
--> 161 raise
162 

File ~/sage-develop/src/sage/structure/coerce_maps.pyx:156, in 
sage.structure.coerce_maps.DefaultConvertMap_unique._call_()
155 try:
--> 156 return C._element_constructor(x)
157 except Exception:

File ~/sage-develop/src/sage/rings/polynomial/polynomial_ring.py:456, in 
PolynomialRing_general._element_constructor_(self, x, check, is_gen, 
construct, **kwds)
455 else:
--> 456 raise TypeError("denominator must be a unit")
457 elif isinstance(x, pari_gen):

TypeError: denominator must be a unit

During handling of the above exception, another exception occurred:

ArithmeticError   Traceback (most recent call last)
Input In [39], in ()
> 1 A // B

File ~/sage-develop/src/sage/structure/element.pyx:1840, in 
sage.structure.element.Element.__floordiv__()
   1838 return (left)._floordiv_(right)
   1839 if BOTH_ARE_ELEMENT(cl):
-> 1840 return coercion_model.bin_op(left, right, floordiv)
   1841 
   1842 try:

File ~/sage-develop/src/sage/structure/coerce.pyx:1204, in 
sage.structure.coerce.CoercionModel.bin_op()
   1202 self._record_exception()
   1203 else:
-> 1204 return PyObject_CallObject(op, xy)
   1205 
   1206 if op is mul:

File ~/sage-develop/src/sage/structure/element.pyx:1838, in 
sage.structure.element.Element.__floordiv__()
   1836 cdef int cl = classify_elements(left, right)
   1837 if HAVE_SAME_PARENT(cl):
-> 1838 return (left)._floordiv_(right)
   1839 if BOTH_ARE_ELEMENT(cl):
   1840 return coercion_model.bin_op(left, right, floordiv)

File ~/sage-develop/src/sage/rings/polynomial/polynomial_element.pyx:2872, 
in sage.rings.polynomial.polynomial_element.Polynomial._floordiv_()
   2870 # quite typical when removing gcds...
   2871 return self
-> 2872 Q, _ = self.quo_rem(right)
   2873 return Q
   2874 

File ~/sage-develop/src/sage/structure/element.pyx:4498, in 
sage.structure.element.coerce_binop.new_method()
   4496 def new_method(self, other, *args, **kwargs):
   4497 if have_same_parent(self, other):
-> 4498 return method(self, other, *args, **kwargs)
   4499 else:
   4500 a, b = coercion_model.canonical_coercion(self, other)

File 
~/sage-develop/src/sage/rings/polynomial/polynomial_element_generic.py:854, 
in Polynomial_generic_sparse.quo_rem(self, other)
852 c = R(rem.leading_coefficient() * ~other.leading_coefficient())
853 except TypeError:
--> 854 raise ArithmeticError("Division non exact (consider coercing to 
polynomials over the fraction field)")
855 e = rem.degree() - d
856 quo += c*R.one().shift(e)

ArithmeticError: Division non exact (consider coercing to polynomials over 
the fraction field)
sage: 

On Wednesday, 12 October 2022 at 23:50:04 UTC+2 Martin R wrote:

> Possibly related:
>
> sage: P. = PolynomialRing(SR)
> sage: R. = PolynomialRing(P); R
> Univariate Polynomial Ring in z over Multivariate Polynomial Ring in x, y 
> over Symbolic Ring
> sage: num = -x*z^2 + x*z
> sage: den = x*z^2 + (-x-1)*z + 1
> sage: num.gcd(den)
> z - 1
> sage: P. = PolynomialRing(SR)
> sage: R. = PolynomialRing(P, sparse=True); R
> Sparse Univariate Polynomial Ring in z over Multivariate Polynomial Ring 
> in x, y over Symbolic Ring
> sage: num = -x*z^2 + x*z
> sage: den = x*z^2 + (-x-1)*z + 1
> sage: num.gcd(den)
>
> ---
> TypeError Traceback (most recent call last)
> File 
> ~/sage-develop/src/sage/rings/polynomial/polynomial_element_generic.py:852, 
> in Polynomial_generic_sparse.quo_rem(self, other)
> 851 try:
> --> 852 c = R(rem.leading_coefficient() * 

[sage-devel] Re: bug in exquo?

2022-10-12 Thread 'Martin R' via sage-devel
Possibly related:

sage: P. = PolynomialRing(SR)
sage: R. = PolynomialRing(P); R
Univariate Polynomial Ring in z over Multivariate Polynomial Ring in x, y 
over Symbolic Ring
sage: num = -x*z^2 + x*z
sage: den = x*z^2 + (-x-1)*z + 1
sage: num.gcd(den)
z - 1
sage: P. = PolynomialRing(SR)
sage: R. = PolynomialRing(P, sparse=True); R
Sparse Univariate Polynomial Ring in z over Multivariate Polynomial Ring in 
x, y over Symbolic Ring
sage: num = -x*z^2 + x*z
sage: den = x*z^2 + (-x-1)*z + 1
sage: num.gcd(den)
---
TypeError Traceback (most recent call last)
File 
~/sage-develop/src/sage/rings/polynomial/polynomial_element_generic.py:852, 
in Polynomial_generic_sparse.quo_rem(self, other)
851 try:
--> 852 c = R(rem.leading_coefficient() * ~other.leading_coefficient())
853 except TypeError:

File ~/sage-develop/src/sage/structure/parent.pyx:897, in 
sage.structure.parent.Parent.__call__()
896 if no_extra_args:
--> 897 return mor._call_(x)
898 else:

File ~/sage-develop/src/sage/structure/coerce_maps.pyx:161, in 
sage.structure.coerce_maps.DefaultConvertMap_unique._call_()
160 print(type(C._element_constructor), C._element_constructor)
--> 161 raise
162 

File ~/sage-develop/src/sage/structure/coerce_maps.pyx:156, in 
sage.structure.coerce_maps.DefaultConvertMap_unique._call_()
155 try:
--> 156 return C._element_constructor(x)
157 except Exception:

File ~/sage-develop/src/sage/rings/polynomial/polynomial_ring.py:456, in 
PolynomialRing_general._element_constructor_(self, x, check, is_gen, 
construct, **kwds)
455 else:
--> 456 raise TypeError("denominator must be a unit")
457 elif isinstance(x, pari_gen):

TypeError: denominator must be a unit

During handling of the above exception, another exception occurred:

ArithmeticError   Traceback (most recent call last)
Input In [82], in ()
> 1 num.gcd(den)

File ~/sage-develop/src/sage/structure/element.pyx:4498, in 
sage.structure.element.coerce_binop.new_method()
   4496 def new_method(self, other, *args, **kwargs):
   4497 if have_same_parent(self, other):
-> 4498 return method(self, other, *args, **kwargs)
   4499 else:
   4500 a, b = coercion_model.canonical_coercion(self, other)

File 
~/sage-develop/src/sage/rings/polynomial/polynomial_element_generic.py:935, 
in Polynomial_generic_sparse.gcd(self, other, algorithm)
933 return S(g)
934 elif algorithm=="generic":
--> 935 return Polynomial.gcd(self,other)
936 else:
937 raise ValueError("Unknown algorithm '%s'" % algorithm)

File ~/sage-develop/src/sage/structure/element.pyx:4498, in 
sage.structure.element.coerce_binop.new_method()
   4496 def new_method(self, other, *args, **kwargs):
   4497 if have_same_parent(self, other):
-> 4498 return method(self, other, *args, **kwargs)
   4499 else:
   4500 a, b = coercion_model.canonical_coercion(self, other)

File ~/sage-develop/src/sage/rings/polynomial/polynomial_element.pyx:4918, 
in sage.rings.polynomial.polynomial_element.Polynomial.gcd()
   4916 raise NotImplementedError("%s does not provide a gcd 
implementation for univariate polynomials"%self._parent._base)
   4917 else:
-> 4918 return doit(self, other)
   4919 
   4920 @coerce_binop

File 
~/sage-develop/src/sage/categories/unique_factorization_domains.py:185, in 
UniqueFactorizationDomains.ParentMethods._gcd_univariate_polynomial(self, 
f, g)
182 break
184 d = a.gcd(b)
--> 185 A = A // a
186 B = B // b
187 g = h = 1

File ~/sage-develop/src/sage/structure/element.pyx:1840, in 
sage.structure.element.Element.__floordiv__()
   1838 return (left)._floordiv_(right)
   1839 if BOTH_ARE_ELEMENT(cl):
-> 1840 return coercion_model.bin_op(left, right, floordiv)
   1841 
   1842 try:

File ~/sage-develop/src/sage/structure/coerce.pyx:1204, in 
sage.structure.coerce.CoercionModel.bin_op()
   1202 self._record_exception()
   1203 else:
-> 1204 return PyObject_CallObject(op, xy)
   1205 
   1206 if op is mul:

File ~/sage-develop/src/sage/structure/element.pyx:1838, in 
sage.structure.element.Element.__floordiv__()
   1836 cdef int cl = classify_elements(left, right)
   1837 if HAVE_SAME_PARENT(cl):
-> 1838 return (left)._floordiv_(right)
   1839 if BOTH_ARE_ELEMENT(cl):
   1840 return coercion_model.bin_op(left, right, floordiv)

File ~/sage-develop/src/sage/rings/polynomial/polynomial_element.pyx:2872, 
in sage.rings.polynomial.polynomial_element.Polynomial._floordiv_()
   2870 # quite typical when removing gcds...
   2871 return self
-> 2872 Q, _ = self.quo_rem(right)
   2873 return Q
   2874 

File ~/sage-develop/src/sage/structure/element.pyx:4498, in 
sage.structure.element.coerce_binop.new_method()
   4496 def new_method(self, other, *args, **kwargs):
   4497 if 

Re: [sage-devel] missing coercion?

2022-10-12 Thread 'Martin R' via sage-devel
Ah, thank you!

On Wednesday, 12 October 2022 at 23:19:09 UTC+2 David Roe wrote:

> It's the difference between conversion and coercion.
>
> P = PolynomialRing(GF(2), "z", sparse=True); Q = PolynomialRing(ZZ, "z", 
> sparse=False)
> sage: P.convert_map_from(Q)
> Conversion map:
>   From: Univariate Polynomial Ring in z over Integer Ring
>   To:   Sparse Univariate Polynomial Ring in z over Finite Field of size 2
> sage: P.convert_map_from(Q)(Q.gen())
> z
>
> David
>
> On Wed, Oct 12, 2022 at 5:15 PM 'Martin R' via sage-devel <
> sage-...@googlegroups.com> wrote:
>
>> Sorry, I don't understand your last sentence.  We have
>>
>> sage: P = PolynomialRing(GF(2), "z", sparse=True); Q = 
>> PolynomialRing(ZZ, "z", sparse=False)  
>> sage: P.has_coerce_map_from(Q) 
>> False
>>
>> How does this fit with
>>
>> "And of course you can convert even when Q is not sparse."?
>>
>> Martin
>>
>> On Wednesday, 12 October 2022 at 23:04:38 UTC+2 David Roe wrote:
>>
>>> Yes, that's expected.
>>>
>>> sage: P = PolynomialRing(GF(2), "z", sparse=True); Q = 
>>> PolynomialRing(ZZ, "z", sparse=True)
>>> sage: P.has_coerce_map_from(Q)
>>> True
>>>
>>> And of course you can convert even when Q is not sparse.
>>> David
>>>
>>> On Wed, Oct 12, 2022 at 4:58 PM 'Martin R' via sage-devel <
>>> sage-...@googlegroups.com> wrote:
>>>
 I have no idea whether the following is to be expected:

 sage: P = PolynomialRing(GF(2), "z", sparse=False); Q = 
 PolynomialRing(ZZ, "z") 
 sage: P.has_coerce_map_from(Q) 
 True 

 sage: P = PolynomialRing(GF(2), "z", sparse=True); Q = 
 PolynomialRing(ZZ, "z")  
 sage: P.has_coerce_map_from(Q) 
 False

 Martin

 -- 
 You received this message because you are subscribed to the Google 
 Groups "sage-devel" group.
 To unsubscribe from this group and stop receiving emails from it, send 
 an email to sage-devel+...@googlegroups.com.
 To view this discussion on the web visit 
 https://groups.google.com/d/msgid/sage-devel/c585103b-9dfa-4e25-b36b-20f8fb937435n%40googlegroups.com
  
 
 .

>>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "sage-devel" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to sage-devel+...@googlegroups.com.
>>
> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/sage-devel/5d443b30-3171-4a6c-bfdc-c61100680cc9n%40googlegroups.com
>>  
>> 
>> .
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-devel/3f51dc5d-09fc-4809-b908-eec488d661e9n%40googlegroups.com.


Re: [sage-devel] missing coercion?

2022-10-12 Thread David Roe
It's the difference between conversion and coercion.

P = PolynomialRing(GF(2), "z", sparse=True); Q = PolynomialRing(ZZ, "z",
sparse=False)
sage: P.convert_map_from(Q)
Conversion map:
  From: Univariate Polynomial Ring in z over Integer Ring
  To:   Sparse Univariate Polynomial Ring in z over Finite Field of size 2
sage: P.convert_map_from(Q)(Q.gen())
z

David

On Wed, Oct 12, 2022 at 5:15 PM 'Martin R' via sage-devel <
sage-devel@googlegroups.com> wrote:

> Sorry, I don't understand your last sentence.  We have
>
> sage: P = PolynomialRing(GF(2), "z", sparse=True); Q = PolynomialRing(ZZ,
> "z", sparse=False)
> sage: P.has_coerce_map_from(Q)
> False
>
> How does this fit with
>
> "And of course you can convert even when Q is not sparse."?
>
> Martin
>
> On Wednesday, 12 October 2022 at 23:04:38 UTC+2 David Roe wrote:
>
>> Yes, that's expected.
>>
>> sage: P = PolynomialRing(GF(2), "z", sparse=True); Q = PolynomialRing(ZZ,
>> "z", sparse=True)
>> sage: P.has_coerce_map_from(Q)
>> True
>>
>> And of course you can convert even when Q is not sparse.
>> David
>>
>> On Wed, Oct 12, 2022 at 4:58 PM 'Martin R' via sage-devel <
>> sage-...@googlegroups.com> wrote:
>>
>>> I have no idea whether the following is to be expected:
>>>
>>> sage: P = PolynomialRing(GF(2), "z", sparse=False); Q =
>>> PolynomialRing(ZZ, "z")
>>> sage: P.has_coerce_map_from(Q)
>>> True
>>>
>>> sage: P = PolynomialRing(GF(2), "z", sparse=True); Q =
>>> PolynomialRing(ZZ, "z")
>>> sage: P.has_coerce_map_from(Q)
>>> False
>>>
>>> Martin
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "sage-devel" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to sage-devel+...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/sage-devel/c585103b-9dfa-4e25-b36b-20f8fb937435n%40googlegroups.com
>>> 
>>> .
>>>
>> --
> You received this message because you are subscribed to the Google Groups
> "sage-devel" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sage-devel+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sage-devel/5d443b30-3171-4a6c-bfdc-c61100680cc9n%40googlegroups.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-devel/CAChs6_m2adJrXP3%3Dhs%3D9AKCFcinFgGiOg_BHJ3%2BAOVVHPguERg%40mail.gmail.com.


Re: [sage-devel] missing coercion?

2022-10-12 Thread 'Martin R' via sage-devel
Sorry, I don't understand your last sentence.  We have

sage: P = PolynomialRing(GF(2), "z", sparse=True); Q = PolynomialRing(ZZ, 
"z", sparse=False)  
sage: P.has_coerce_map_from(Q) 
False

How does this fit with

"And of course you can convert even when Q is not sparse."?

Martin

On Wednesday, 12 October 2022 at 23:04:38 UTC+2 David Roe wrote:

> Yes, that's expected.
>
> sage: P = PolynomialRing(GF(2), "z", sparse=True); Q = PolynomialRing(ZZ, 
> "z", sparse=True)
> sage: P.has_coerce_map_from(Q)
> True
>
> And of course you can convert even when Q is not sparse.
> David
>
> On Wed, Oct 12, 2022 at 4:58 PM 'Martin R' via sage-devel <
> sage-...@googlegroups.com> wrote:
>
>> I have no idea whether the following is to be expected:
>>
>> sage: P = PolynomialRing(GF(2), "z", sparse=False); Q = 
>> PolynomialRing(ZZ, "z") 
>> sage: P.has_coerce_map_from(Q) 
>> True 
>>
>> sage: P = PolynomialRing(GF(2), "z", sparse=True); Q = 
>> PolynomialRing(ZZ, "z")  
>> sage: P.has_coerce_map_from(Q) 
>> False
>>
>> Martin
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "sage-devel" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to sage-devel+...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/sage-devel/c585103b-9dfa-4e25-b36b-20f8fb937435n%40googlegroups.com
>>  
>> 
>> .
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-devel/5d443b30-3171-4a6c-bfdc-c61100680cc9n%40googlegroups.com.


Re: [sage-devel] missing coercion?

2022-10-12 Thread David Roe
Yes, that's expected.

sage: P = PolynomialRing(GF(2), "z", sparse=True); Q = PolynomialRing(ZZ,
"z", sparse=True)
sage: P.has_coerce_map_from(Q)
True

And of course you can convert even when Q is not sparse.
David

On Wed, Oct 12, 2022 at 4:58 PM 'Martin R' via sage-devel <
sage-devel@googlegroups.com> wrote:

> I have no idea whether the following is to be expected:
>
> sage: P = PolynomialRing(GF(2), "z", sparse=False); Q =
> PolynomialRing(ZZ, "z")
> sage: P.has_coerce_map_from(Q)
> True
>
> sage: P = PolynomialRing(GF(2), "z", sparse=True); Q = PolynomialRing(ZZ,
> "z")
> sage: P.has_coerce_map_from(Q)
> False
>
> Martin
>
> --
> You received this message because you are subscribed to the Google Groups
> "sage-devel" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sage-devel+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sage-devel/c585103b-9dfa-4e25-b36b-20f8fb937435n%40googlegroups.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-devel/CAChs6_%3DJT8Fiaw-U%2BVch2nzb4-OQYa4LgUygOPNnXvEJtY_U%2Bg%40mail.gmail.com.


[sage-devel] missing coercion?

2022-10-12 Thread 'Martin R' via sage-devel
I have no idea whether the following is to be expected:

sage: P = PolynomialRing(GF(2), "z", sparse=False); Q = PolynomialRing(ZZ, 
"z") 
sage: P.has_coerce_map_from(Q) 
True 

sage: P = PolynomialRing(GF(2), "z", sparse=True); Q = PolynomialRing(ZZ, 
"z")  
sage: P.has_coerce_map_from(Q) 
False

Martin

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-devel/c585103b-9dfa-4e25-b36b-20f8fb937435n%40googlegroups.com.


[sage-devel] bug in exquo?

2022-10-12 Thread 'Martin R' via sage-devel
I am not sure whether the following is to be expected.

Martin

sage: R. = SR[]
sage: S. = R[]
sage: (x*z).quo_rem(S(x))
---
TypeError Traceback (most recent call last)
File ~/sage-develop/src/sage/rings/polynomial/polynomial_element.pyx:11713, 
in 
sage.rings.polynomial.polynomial_element.Polynomial_generic_dense.quo_rem()
  11712 try:
> 11713 q = R(q)
  11714 except TypeError:

File ~/sage-develop/src/sage/structure/parent.pyx:897, in 
sage.structure.parent.Parent.__call__()
896 if no_extra_args:
--> 897 return mor._call_(x)
898 else:

File ~/sage-develop/src/sage/categories/map.pyx:788, in 
sage.categories.map.Map._call_()
787 
--> 788 cpdef Element _call_(self, x):
789 """

File ~/sage-develop/src/sage/rings/fraction_field.py:1254, in 
FractionFieldEmbeddingSection._call_(self, x, check)
   1250 if check and not den.is_unit():
   1251 # This should probably be a ValueError.
   1252 # However, too much existing code is expecting this to throw a
   1253 # TypeError, so we decided to keep it for the time being.
-> 1254 raise TypeError("fraction must have unit denominator")
   1255 return num * den.inverse_of_unit()

TypeError: fraction must have unit denominator

During handling of the above exception, another exception occurred:

ArithmeticError   Traceback (most recent call last)
Input In [41], in ()
> 1 (x*z).quo_rem(S(x))

File ~/sage-develop/src/sage/structure/element.pyx:4498, in 
sage.structure.element.coerce_binop.new_method()
   4496 def new_method(self, other, *args, **kwargs):
   4497 if have_same_parent(self, other):
-> 4498 return method(self, other, *args, **kwargs)
   4499 else:
   4500 a, b = coercion_model.canonical_coercion(self, other)

File ~/sage-develop/src/sage/rings/polynomial/polynomial_element.pyx:11715, 
in 
sage.rings.polynomial.polynomial_element.Polynomial_generic_dense.quo_rem()
  11713 q = R(q)
  11714 except TypeError:
> 11715 raise ArithmeticError("division non exact (consider coercing to 
polynomials over the fraction field)")
  11716 for j from n+k-2 >= j >= k:
  11717 x[j] -= q * y[j-k]

ArithmeticError: division non exact (consider coercing to polynomials over 
the fraction field)
sage: 

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-devel/93849a51-966e-4f80-a85d-9f57c54a1578n%40googlegroups.com.