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: |

### 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

### comment:2 follow-up: 3 Changed 4 years ago by

A coercion `ZZ -> R`

for whatever ring `R`

looks reasonable to me...

### comment:3 follow-up: 4 Changed 4 years ago by

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 Changed 4 years ago by

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.

The problem is more fundamental:

Contrast:

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`

.