Skip to content

Calling CRT() with list of 1 python int results in error #40067

@shpark1104

Description

@shpark1104

Steps To Reproduce

CRT([1], [2]) # fine, 1
CRT([int(1), int(1)], [int(2), int(3)]) # fine, 1
CRT([int(1)], [int(2)]) # fine, 1
CRT([int(Integer(1))], [int(Integer(2))]) # error

Expected Behavior

should return either the only element in the first list or Zmod group element of it.

Actual Behavior

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'

Additional Information

from this question

Environment

  • OS: Ubuntu 24.04
  • Sage Version: 10.6

Checklist

  • I have searched the existing issues for a bug report that matches the one I want to file, without success.
  • I have read the documentation and troubleshoot guide

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions