Ticket #3655 (closed defect: fixed)

Opened 3 months ago

Last modified 1 month ago

[small patch attached, positive review] left multiplication in piecewise does not work

Reported by: wdj Assigned to: gfurnish
Priority: major Milestone: sage-3.1.2
Component: calculus Keywords:
Cc:

Description

This was reported by C Boncelet.

sage: x = PolynomialRing(QQ,'x').gen()
sage: f = Piecewise([[(0,1),1*x^0]])
sage: r = f*2
sage: r = 2*f
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call
last)
/Users/boncelet/<ipython console> in <module>()
/Users/boncelet/element.pyx in
sage.structure.element.RingElement.__mul__ (sage/structure/element.c:
8545)()
/Users/boncelet/coerce.pyx in
sage.structure.coerce.CoercionModel_cache_maps.bin_op_c (sage/
structure/coerce.c:5338)()
TypeError: unsupported operand parent(s) for '*': 'Integer Ring' and
'<type 'instance'>'

He then suggested simply defining rmul = mul:

sage: f.__rmul__ = f.__mul__
sage: r = f*2
sage: r = 2*f
sage: r
Piecewise defined function with 1 parts, [[(0, 1), 2]]

Attachments

10058.patch (1.9 kB) - added by wdj on 07/15/2008 03:48:19 AM.
based on 3.0.4
trac_3655.patch (0.8 kB) - added by mhansen on 08/26/2008 03:12:14 PM.

Change History

07/15/2008 03:48:19 AM changed by wdj

  • attachment 10058.patch added.

based on 3.0.4

07/15/2008 03:49:34 AM changed by wdj

I added a patch implementing the suggestion above. It is just a few lines. Passes sage -testall.

07/15/2008 03:58:02 AM changed by wdj

  • summary changed from left multiplication in piecewise does not work to [small patch attached, needs review] left multiplication in piecewise does not work.

08/26/2008 03:12:14 PM changed by mhansen

  • attachment trac_3655.patch added.

08/26/2008 03:12:49 PM changed by mhansen

  • summary changed from [small patch attached, needs review] left multiplication in piecewise does not work to [small patch attached, positive review] left multiplication in piecewise does not work.

Looks good to me. Apply both patches.

08/26/2008 03:54:16 PM changed by mabshoff

  • status changed from new to closed.
  • resolution set to fixed.

Merged both patches in Sage 3.1.2.alpha1