Opened 8 years ago

Last modified 5 years ago

#14037 new defect

plot of piecewise defined function raises UnboundLocalError

Reported by: slabbe Owned by: jason, was
Priority: major Milestone: sage-7.3
Component: graphics Keywords:
Cc: Merged in:
Authors: Reviewers:
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Description (last modified by mkoeppe)

This was reported to me by Mathieu Roux:

sage: f = Piecewise([[(0,1),1],[(1,2),x-1]],x) 
... DeprecationWarning: use lower-case piecewise instead
sage: plot(f,0,2)                                
verbose 0 (575: plot.py, plot) there were 4 extra arguments (besides <sage.ext.fast_eval.FastDoubleFunc object at 0xb912618>)
---------------------------------------------------------------------------
UnboundLocalError                         Traceback (most recent call last)

...

/Users/slabbe/Applications/sage-5.6.rc0/local/lib/python2.7/site-packages/sage/plot/plot.pyc in plot(funcs, *args, **kwds)
   1117             sage.misc.misc.verbose("there were %s extra arguments (besides %s)" % (n, funcs), level=0)
   1118 
-> 1119     G._set_extra_kwds(G_kwds)
   1120     if do_show:
   1121         G.show()

UnboundLocalError: local variable 'G' referenced before assignment

It seems related to a problem cited on sage-support in 2008.

Note that the following works:

sage: f.plot()

Change History (6)

comment:1 Changed 8 years ago by nthiery

Probably a variation on the same theme:

sage:  plot(exp, 0,10,x,(x,0,10),color='green')
verbose 0 (578: plot.py, plot) there were 4 extra arguments (besides exp)
---------------------------------------------------------------------------
UnboundLocalError                         Traceback (most recent call last)
<ipython-input-1-d893a3ab5a9f> in <module>()
----> 1 plot(exp, Integer(0),Integer(10),x,(x,Integer(0),Integer(10)),color='green')

...
/opt/sage-5.10.beta2/local/lib/python2.7/site-packages/sage/plot/plot.pyc in plot(funcs, *args, **kwds)
   1140             sage.misc.misc.verbose("there were %s extra arguments (besides %s)" % (n, funcs), level=0)
   1141 
-> 1142     G._set_extra_kwds(G_kwds)
   1143     if do_show:
   1144         G.show()

UnboundLocalError: local variable 'G' referenced before assignment

Reported by Isabelle Rouanet.

comment:2 Changed 7 years ago by jdemeyer

  • Milestone changed from sage-5.11 to sage-5.12

comment:3 Changed 7 years ago by vbraun_spam

  • Milestone changed from sage-6.1 to sage-6.2

comment:4 Changed 7 years ago by vbraun_spam

  • Milestone changed from sage-6.2 to sage-6.3

comment:5 Changed 6 years ago by vbraun_spam

  • Milestone changed from sage-6.3 to sage-6.4

comment:6 Changed 5 years ago by mkoeppe

  • Description modified (diff)
  • Milestone changed from sage-6.4 to sage-7.3

Description modified. This is a bug in the old (deprecated in #14801) Piecewise (capital P). Can close this bug when the old Piecewise is removed completely.

Note: See TracTickets for help on using tickets.