Opened 6 years ago

Closed 5 years ago

#15059 closed defect (fixed)

Morphisms cannot be applied to too-simple elements of a multivariate power series ring

Reported by: darij Owned by:
Priority: major Milestone: sage-6.3
Component: algebra Keywords: rings, power series, polynomials
Cc: SimonKing, niles Merged in:
Authors: Darij Grinberg Reviewers: Peter Bruin
Report Upstream: N/A Work issues:
Branch: 99a7fb6 (Commits) Commit: 99a7fb62fcabcf9babb5839df3c144f68cb918c8
Dependencies: Stopgaps:


sage: M.<u,v> = PowerSeriesRing(GF(5))
sage: s = M.hom([u, u+v])     
sage: s(
AttributeError                            Traceback (most recent call last)
<ipython-input-4-754f257583fc> in <module>()
----> 1 s(

/home/darij/sage-5.11.beta3/local/lib/python2.7/site-packages/sage/categories/ in (sage/categories/map.c:4018)()

/home/darij/sage-5.11.beta3/local/lib/python2.7/site-packages/sage/rings/ in sage.rings.morphism.RingHomomorphism_im_gens._call_ (sage/rings/morphism.c:7481)()

/home/darij/sage-5.11.beta3/local/lib/python2.7/site-packages/sage/rings/multi_power_series_ring_element.pyc in _im_gens_(self, codomain, im_gens)
    611             x + 2*y + 12*x*y^2 + O(x, y)^5
    612         """
--> 613         return codomain(self(*im_gens))
    615     def __getitem__(self,n):

/home/darij/sage-5.11.beta3/local/lib/python2.7/site-packages/sage/rings/multi_power_series_ring_element.pyc in __call__(self, *x, **kwds)
    462         else:
    463             newprec = self.prec()*min(valn_list)
--> 464         return self._value().subs(sub_dict).add_bigoh(newprec)
    466     def _subs_formal(self, *x, **kwds):

/home/darij/sage-5.11.beta3/local/lib/python2.7/site-packages/sage/structure/ in sage.structure.element.Element.__getattr__ (sage/structure/element.c:3871)()

/home/darij/sage-5.11.beta3/local/lib/python2.7/site-packages/sage/structure/ in sage.structure.misc.getattr_from_other_class (sage/structure/misc.c:1696)()

AttributeError: 'sage.rings.finite_rings.integer_mod.IntegerMod_int' object has no attribute 'add_bigoh'

(Alternatively, the same error can be caught by calling, [u,u+v]) without ever defining s.)

Note that s(u) and s(v) work fine.

Attachments (2)

trac_15059-multivariate_fix-dg.patch (1.5 KB) - added by darij 6 years ago.
trac_15059-multivariate_fix-dg.2.patch (1.5 KB) - added by darij 6 years ago.

Download all attachments as: .zip

Change History (11)

Changed 6 years ago by darij

Changed 6 years ago by darij

comment:1 Changed 6 years ago by darij

Fixed. The patch was uploaded twice due to connection issues; it's one and the same file nevertheless.

The issue at hand was that the __call__ method of class MPowerSeries (elements of multivariate power series rings) calls the subs method of polynomials, but this method behaves somewhat unpredictably as concerning the parent of its output: If the input is a constant polynomial, it does not change the base ring (even if the substitution should send polynomials from ZZ to polynomials from ZZ/5ZZ):

sage: K.<x,y> = PolynomialRing(ZZ)
sage: T.<u,v> = PolynomialRing(Integers(5))
sage: parent(x.subs(x=u, y=v))
Multivariate Polynomial Ring in u, v over Ring of integers modulo 5
sage: parent(, y=v))
Integer Ring

Note that this issue only appears with multivariate polynomials. Univariate ones substitute fine.

Is my fix misguided in that it fixes the symptom rather than the cause?


apply trac_15059-multivariate_fix-dg.patch​

comment:2 Changed 6 years ago by darij

  • Keywords polynomials added
  • Status changed from new to needs_review

comment:3 Changed 6 years ago by darij

  • Cc SimonKing nilesj added

comment:4 Changed 6 years ago by darij

  • Cc niles added; nilesj removed

comment:5 Changed 6 years ago by vbraun_spam

  • Milestone changed from sage-6.1 to sage-6.2

comment:6 Changed 5 years ago by pbruin

  • Authors set to Darij Grinberg
  • Branch set to u/pbruin/15059-MPowerSeries_call
  • Commit set to 99a7fb62fcabcf9babb5839df3c144f68cb918c8
  • Reviewers set to Peter Bruin
  • Status changed from needs_review to positive_review

Looks good; the patch applied without conflicts, I only converted it into a Git branch to delete trailing whitespace. It fixes the bug and passes all tests. I don't want to think about deciding where the result of subs() should live in general...

comment:7 Changed 5 years ago by darij

Thank you! I'm just hoping it doesn't conflict with the ongoing category revamp...

comment:8 Changed 5 years ago by vbraun_spam

  • Milestone changed from sage-6.2 to sage-6.3

comment:9 Changed 5 years ago by vbraun

  • Branch changed from u/pbruin/15059-MPowerSeries_call to 99a7fb62fcabcf9babb5839df3c144f68cb918c8
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.