Opened 4 years ago

Last modified 4 years ago

#26014 new defect

creation of polynomial rings over Cartesian products of rings

Reported by: Dima Pasechnik Owned by:
Priority: major Milestone: sage-8.4
Component: commutative algebra Keywords:
Cc: Simon King Merged in:
Authors: Reviewers:
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges

Description

sage: R1 = IntegerModRing(5)
sage: R=R1.cartesian_product(R1) 
sage: R2.<t>=R[]
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-2-eaee2db77df4> in <module>()
----> 1 R2 = R['t']; (t,) = R2._first_ngens(1)

/home/dimpase/sagetrac-mirror/local/lib/python2.7/site-packages/sage/structure/parent.pyx in sage.structure.parent.Parent.__getitem__ (build/cythonized/sage/structure/parent.c:11450)()
   1221             except AttributeError:
   1222                 return self.list()[n]
-> 1223         return meth(n)
...
home/dimpase/sagetrac-mirror/local/lib/python2.7/site-packages/sage/sets/cartesian_product.pyc in _element_constructor_(self, x)
    114         """
    115         from builtins import zip
--> 116         x = tuple(x)
    117         if len(x) != len(self._sets):
    118             raise ValueError(

TypeError: 'int' object is not iterable

same with more than one variable.

Change History (4)

comment:1 Changed 4 years ago by Travis Scrimshaw

The problem is more fundamental:

sage: R = R1.cartesian_product(R1)
sage: R1 = IntegerModRing(5)
sage: R(1)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-11-10b1024e084e> in <module>()
----> 1 R(Integer(1))

/home/uqtscrim/sage/local/lib/python2.7/site-packages/sage/structure/parent.pyx in sage.structure.parent.Parent.__call__ (build/cythonized/sage/structure/parent.c:9679)()
    919         if mor is not None:
    920             if no_extra_args:
--> 921                 return mor._call_(x)
    922             else:
    923                 return mor._call_with_args(x, args, kwds)

/home/uqtscrim/sage/local/lib/python2.7/site-packages/sage/structure/coerce_maps.pyx in sage.structure.coerce_maps.DefaultConvertMap_unique._call_ (build/cythonized/sage/structure/coerce_maps.c:4574)()
    143                 print(type(C), C)
    144                 print(type(C._element_constructor), C._element_constructor)
--> 145             raise
    146 
    147     cpdef Element _call_with_args(self, x, args=(), kwds={}):

/home/uqtscrim/sage/local/lib/python2.7/site-packages/sage/structure/coerce_maps.pyx in sage.structure.coerce_maps.DefaultConvertMap_unique._call_ (build/cythonized/sage/structure/coerce_maps.c:4442)()
    138         cdef Parent C = self._codomain
    139         try:
--> 140             return C._element_constructor(x)
    141         except Exception:
    142             if print_warnings:

/home/uqtscrim/sage/local/lib/python2.7/site-packages/sage/sets/cartesian_product.pyc in _element_constructor_(self, x)
    114         """
    115         from builtins import zip
--> 116         x = tuple(x)
    117         if len(x) != len(self._sets):
    118             raise ValueError(

TypeError: 'sage.rings.integer.Integer' object is not iterable
sage: R.one()
(1, 1)

Contrast:

sage: R.coerce_map_from(ZZ)
sage: R.base_ring()
sage: R1.base_ring()
Ring of integers modulo 5
sage: R1.coerce_map_from(ZZ)
Natural morphism:
  From: Integer Ring
  To:   Ring of integers modulo 5

So one fix would be for this ring to have a coercion from ZZ. Another would be to do special case 1 and 0 in cartesian_product to return one and zero respectively and consider all other scalars as an action on 1.

comment:2 Changed 4 years ago by Vincent Delecroix

A coercion ZZ -> R for whatever ring R looks reasonable to me...

comment:3 in reply to:  2 ; Changed 4 years ago by Vincent Delecroix

Replying to vdelecroix:

A coercion ZZ -> R for whatever ring R looks reasonable to me...

Though, if we start provided something like this, we should pay a lot of attention to the shortcut in use in many rings right now in Sage (QQ, RR, etc). Many of them might be in _element_constructor_ and a generic coercion would bypass it.

comment:4 in reply to:  3 Changed 4 years ago by Travis Scrimshaw

Replying to vdelecroix:

Replying to vdelecroix:

A coercion ZZ -> R for whatever ring R looks reasonable to me...

Though, if we start provided something like this, we should pay a lot of attention to the shortcut in use in many rings right now in Sage (QQ, RR, etc). Many of them might be in _element_constructor_ and a generic coercion would bypass it.

That is a good point. Although I think a number of the critical ones have custom morphisms (e.g., QQ) for speed and better separations-of-concerns (i.e., no monolithic _element_constructor_ or __init__ with a billion cases).

Note: See TracTickets for help on using tickets.