Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Error when calling CRT with list of 1 python int

I noticed that calling CRT with list of 1 python int causes error, while calling multiple python ints is allowed. Is it considered as a bug related to sage Integer and native int?

sage: CRT([1], [2])
1
sage: CRT([int(1), int(1)], [int(2), int(3)])
1
sage: CRT([int(1)], [int(2)])
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[7], line 1
----> 1 CRT([int(Integer(1))], [int(Integer(2))])

File ~/anaconda3/envs/sage/lib/python3.12/site-packages/sage/arith/misc.py:3476, in crt(a, b, m, n)
   3355 r"""
   3356 Return a solution to a Chinese Remainder Theorem problem.
   3357 
   (...)
   3473     58
   3474 """
   3475 if isinstance(a, list):
-> 3476     return CRT_list(a, b)
   3478 try:
   3479     f = (b - a).quo_rem

File ~/anaconda3/envs/sage/lib/python3.12/site-packages/sage/arith/misc.py:3624, in CRT_list(values, moduli)
   3622         return ZZ.zero()
   3623     if len(values) == 1:
-> 3624         return moduli[0].parent()(values[0])
   3626 # The result is computed using a binary tree. In typical cases,
   3627 # this scales much better than folding the list from one side.
   3628 from sage.arith.functions import lcm

AttributeError: 'int' object has no attribute 'parent'