from sage.rings.polynomial.infinite_polynomial_element import InfinitePolynomial_dense
is my friend! On Wednesday, 22 November 2023 at 11:40:12 UTC+1 Martin R wrote: > I need the variables of a polynomial c in InfinitePolynomialRing(SR) as an > element of that ring (rather than as an element of the PolynomialRing). > > I understand that polynomials are hard, but does anybody see a workaround? > > Martin > > sage: R.<a> = InfinitePolynomialRing(SR) > sage: c = 3*a[0] > sage: c.variables()[0].parent() > Multivariate Polynomial Ring in a_1, a_0 over Symbolic Ring > sage: R(c.variables()[0]) > --------------------------------------------------------------------------- > RuntimeError Traceback (most recent call last) > Cell In [9], line 1 > ----> 1 R(c.variables()[Integer(0)]) > > File ~/sage/src/sage/structure/parent.pyx:901, in > sage.structure.parent.Parent.__call__() > 899 if mor is not None: > 900 if no_extra_args: > --> 901 return mor._call_(x) > 902 else: > 903 return mor._call_with_args(x, args, kwds) > > File ~/sage/src/sage/structure/coerce_maps.pyx:163, in > sage.structure.coerce_maps.DefaultConvertMap_unique._call_() > 161 print(type(C), C) > 162 print(type(C._element_constructor), > C._element_constructor) > --> 163 raise > 164 > 165 cpdef Element _call_with_args(self, x, args=(), kwds={}) noexcept: > > File ~/sage/src/sage/structure/coerce_maps.pyx:158, in > sage.structure.coerce_maps.DefaultConvertMap_unique._call_() > 156 cdef Parent C = self._codomain > 157 try: > --> 158 return C._element_constructor(x) > 159 except Exception: > 160 if print_warnings: > > File ~/sage/src/sage/rings/polynomial/infinite_polynomial_ring.py:988, in > InfinitePolynomialRing_sparse._element_constructor_(self, x) > 985 # By now, x or self._P are not libsingular. Since > MPolynomialRing_polydict > 986 # is too buggy, we use string evaluation > 987 try: > --> 988 return sage_eval(repr(x), self.gens_dict()) > 989 except (ValueError, TypeError, NameError): > 990 raise ValueError("cannot convert %s into an element of %s - no > conversion into underlying polynomial ring" % (x, self)) > > File ~/sage/src/sage/misc/cachefunc.pyx:2329, in > sage.misc.cachefunc.CachedMethodCallerNoArgs.__call__() > 2327 if self.cache is None: > 2328 f = self.f > -> 2329 self.cache = f(self._instance) > 2330 return self.cache > 2331 > > File ~/sage/src/sage/rings/polynomial/infinite_polynomial_ring.py:1278, in > InfinitePolynomialRing_sparse.gens_dict(self) > 1263 @cached_method > 1264 def gens_dict(self): > 1265 """ > 1266 Return a dictionary-like object containing the infinitely many > 1267 ``{var_name:variable}`` pairs. > (...) > 1276 a_5 > 1277 """ > -> 1278 return GenDictWithBasering(self, InfiniteGenDict(self.gens())) > > File ~/sage/src/sage/rings/polynomial/infinite_polynomial_ring.py:560, in > GenDictWithBasering.__init__(self, parent, start) > 558 while hasattr(P, 'base_ring') and (P.base_ring() is not P): > 559 P = P.base_ring() > --> 560 D = P.gens_dict() > 561 if isinstance(D, GenDictWithBasering): > 562 self._D.extend(D._D) > > File ~/sage/src/sage/structure/category_object.pyx:287, in > sage.structure.category_object.CategoryObject.gens_dict() > 285 """ > 286 if copy: > --> 287 return dict(self.__gens_dict()) > 288 else: > 289 return self.__gens_dict() > > File ~/sage/src/sage/misc/cachefunc.pyx:2329, in > sage.misc.cachefunc.CachedMethodCallerNoArgs.__call__() > 2327 if self.cache is None: > 2328 f = self.f > -> 2329 self.cache = f(self._instance) > 2330 return self.cache > 2331 > > File ~/sage/src/sage/structure/category_object.pyx:261, in > sage.structure.category_object.CategoryObject._CategoryObject__gens_dict() > 259 def __gens_dict(self): > 260 cdef dict v = {} > --> 261 for x in self._defining_names(): > 262 v[str(x)] = x > 263 return v > > File ~/sage/src/sage/misc/cachefunc.pyx:2329, in > sage.misc.cachefunc.CachedMethodCallerNoArgs.__call__() > 2327 if self.cache is None: > 2328 f = self.f > -> 2329 self.cache = f(self._instance) > 2330 return self.cache > 2331 > > File ~/sage/src/sage/structure/category_object.pyx:407, in > sage.structure.category_object.CategoryObject._defining_names() > 405 ((1/2, 0, 0), (0, 1, 0)) > 406 """ > --> 407 return self.gens() > 408 > 409 > ################################################################################################# > > File ~/sage/src/sage/structure/parent_gens.pyx:119, in > sage.structure.parent_gens.ParentWithGens.gens() > 117 if self._gens is not None: > 118 return self._gens > --> 119 self._gens = tuple(self.gen(i) for i in range(self.ngens())) > 120 return self._gens > 121 > > File ~/sage/src/sage/structure/parent_gens.pyx:103, in > sage.structure.parent_gens.ParentWithGens.ngens() > 101 # Derived class *must* define ngens method. > 102 def ngens(self): > --> 103 check_old_coerce(self) > 104 raise NotImplementedError("Number of generators not known.") > 105 > > File ~/sage/src/sage/structure/parent_gens.pyx:78, in > sage.structure.parent_gens.check_old_coerce() > 76 cdef inline check_old_coerce(parent.Parent p) noexcept: > 77 if p._element_constructor is not None: > ---> 78 raise RuntimeError("%s still using old coercion framework" > % p) > 79 > 80 > > RuntimeError: Symbolic Ring still using old coercion framework -- 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/f0056bee-ece0-439f-b33f-4942cf8e7c9an%40googlegroups.com.