#7570: Make plot methods accept 'empty' input to return empty Graphics object
------------------------+---------------------------------------------------
   Reporter:  chapoton  |       Owner:  was                
       Type:  defect    |      Status:  needs_work         
   Priority:  minor     |   Milestone:                     
  Component:  graphics  |    Keywords:  list_plot, beginner
     Author:            |    Upstream:  N/A                
   Reviewer:            |      Merged:                     
Work_issues:            |  
------------------------+---------------------------------------------------
Changes (by gagansekhon):

  * status:  needs_review => needs_work


Comment:

 sage/plot/point.py fails.

 When I passed an empty list I got an error.

 sage: point([])
 ERROR: An unexpected error occurred while tokenizing input
 The following traceback may be corrupted or invalid
 The error message is: ('EOF in multi-line statement', (273, 0))

 ---------------------------------------------------------------------------
 ValueError                                Traceback (most recent call
 last)

 /Applications/sage4.6/devel/sage-main/<ipython console> in <module>()

 /Applications/sage4.6/local/lib/python2.6/site-
 packages/IPython/Prompts.pyc in __call__(self, arg)
     549
     550             # and now call a possibly user-defined print mechanism
 --> 551             manipulated_val = self.display(arg)
     552
     553             # user display hooks can change the variable to be
 stored in

 /Applications/sage4.6/local/lib/python2.6/site-
 packages/IPython/Prompts.pyc in _display(self, arg)
     575             return IPython.generics.result_display(arg)
     576         except TryNext:
 --> 577             return self.shell.hooks.result_display(arg)
     578
     579     # Assign the default display method:

 /Applications/sage4.6/local/lib/python2.6/site-packages/IPython/hooks.pyc
 in __call__(self, *args, **kw)
     139             #print "prio",prio,"cmd",cmd #dbg
     140             try:
 --> 141                 ret = cmd(*args, **kw)
     142                 return ret
     143             except ipapi.TryNext, exc:

 /Applications/sage4.6/local/lib/python2.6/site-
 packages/sage/misc/displayhook.pyc in result_display(ip_self, obj)
     148     # IPython's default result_display() uses the
 IPython.genutils.Term.cout stream.
     149     # See also local/lib/python2.6/site-packages/IPython/hooks.py.
 --> 150     print_obj(IPython.genutils.Term.cout, obj)
     151
     152 def displayhook(obj):

 /Applications/sage4.6/local/lib/python2.6/site-
 packages/sage/misc/displayhook.pyc in print_obj(out_stream, obj)
     140             if _check_tall_list_and_print(out_stream, obj):
     141                 return
 --> 142     print >>out_stream, `obj`
     143
     144 def result_display(ip_self, obj):

 /Applications/sage4.6/local/lib/python2.6/site-
 packages/sage/structure/sage_object.so in
 sage.structure.sage_object.SageObject.__repr__
 (sage/structure/sage_object.c:1341)()

 /Applications/sage4.6/local/lib/python2.6/site-packages/sage/plot/plot.pyc
 in _repr_(self)
    1078         """
    1079         if SHOW_DEFAULT:
 -> 1080             self.show()
    1081             return ''
    1082         else:

 /Applications/sage4.6/local/lib/python2.6/site-packages/sage/plot/misc.pyc
 in wrapper(*args, **kwds)
      82             kwds[self.name + "options"] = suboptions
      83
 ---> 84             return func(*args, **kwds)
      85
      86         from sage.misc.sageinspect import sage_getsource

 /Applications/sage4.6/local/lib/python2.6/site-packages/sage/plot/plot.pyc
 in show(self, **kwds)
    1737             if options['filename'] is None:
    1738                 options['filename'] =
 sage.misc.misc.tmp_filename() + '.png'
 -> 1739             self.save(**options)
    1740             os.system('%s %s 2>/dev/null 1>/dev/null &' % \
    1741                 (sage.misc.viewer.browser(), options['filename']))

 /Applications/sage4.6/local/lib/python2.6/site-packages/sage/plot/plot.pyc
 in save(self, filename, dpi, savenow, *args, **kwds)
    2386             options=dict()
    2387             options['transparent']=kwds.pop('transparent',False)
 -> 2388             figure=self.matplotlib(*args, **kwds)
    2389             # You can output in PNG, PS, EPS, PDF, or SVG format,
 depending on the file extension.
    2390             # matplotlib looks at the file extension to see what
 the renderer should be.

 /Applications/sage4.6/local/lib/python2.6/site-packages/sage/plot/plot.pyc
 in matplotlib(self, filename, xmin, xmax, ymin, ymax, figsize, figure,
 sub, axes, axes_labels, fontsize, frame, verify, aspect_ratio, gridlines,
 gridlinesstyle, vgridlinesstyle, hgridlinesstyle, show_legend,
 legend_options, axes_pad, ticks_integer, tick_formatter, ticks)
    1954         #add all the primitives to the subplot
    1955         for g in self.__objects:
 -> 1956             g._render_on_subplot(subplot)
    1957
    1958         #add the legend if requested

 /Applications/sage4.6/local/lib/python2.6/site-
 packages/sage/plot/point.pyc in _render_on_subplot(self, subplot)
     271         scatteroptions={}
     272         if not faceted: scatteroptions['edgecolors'] = 'none'
 --> 273         subplot.scatter(self.xdata, self.ydata, s=s, c=c, alpha=a,
 zorder=z, label=options['legend_label'], **scatteroptions)
     274
     275

 /Applications/sage4.6/local/lib/python2.6/site-
 packages/matplotlib/axes.pyc in scatter(self, x, y, s, c, marker, cmap,
 norm, vmin, vmax, alpha, linewidths, faceted, verts, **kwargs)
    5811         temp_y = y
    5812
 -> 5813         minx = np.amin(temp_x)
    5814         maxx = np.amax(temp_x)
    5815         miny = np.amin(temp_y)

 /Applications/sage4.6/local/lib/python2.6/site-
 packages/numpy/core/fromnumeric.pyc in amin(a, axis, out)
    1641     except AttributeError:
    1642         return _wrapit(a, 'min', axis, out)
 -> 1643     return amin(axis, out)
    1644
    1645

 ValueError: zero-size array to ufunc.reduce without identity

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/7570#comment:7>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sage-trac?hl=en.

Reply via email to