Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Closed
Milestone
Description
This came up when I tried to pass a third param topyplot.scatter()
, specifically a string to represent the marker shape, by analogy to the third param inpyplot.plot()
. It turned out that this is possible, but with themarker
named param, which doesnot come third. The third param in order iss
, which expects a sequence of numbers. The error that actually comes up when it's given a string (in this case'.'
) is not very helpful:
---------------------------------------------------------------------------TypeError Traceback (most recent call last)/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/IPython/core/formatters.pyc in __call__(self, obj) 337 pass 338 else:--> 339 return printer(obj) 340 # Finally look for special method names 341 method = _safe_get_formatter_method(obj, self.print_method)/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/IPython/core/pylabtools.pyc in <lambda>(fig) 224 225 if 'png' in formats:--> 226 png_formatter.for_type(Figure, lambda fig: print_figure(fig, 'png', **kwargs)) 227 if 'retina' in formats or 'png2x' in formats: 228 png_formatter.for_type(Figure, lambda fig: retina_figure(fig, **kwargs))/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/IPython/core/pylabtools.pyc in print_figure(fig, fmt, bbox_inches, **kwargs) 115 116 bytes_io = BytesIO()--> 117 fig.canvas.print_figure(bytes_io, **kw) 118 data = bytes_io.getvalue() 119 if fmt == 'svg':/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/backend_bases.pyc in print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, **kwargs) 2050 where the keys are a file type name, such as 'Joint Photographic 2051 Experts Group', and the values are a list of filename extensions used-> 2052 for that filetype, such as ['jpg', 'jpeg'].""" 2053 groupings = {} 2054 for ext, name in six.iteritems(cls.filetypes):/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/backends/backend_agg.pyc in print_png(self, filename_or_obj, *args, **kwargs) 489 self.renderer.clear() 490 return self.renderer--> 491 492 def tostring_rgb(self): 493 if __debug__: verbose.report('FigureCanvasAgg.tostring_rgb',/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/backends/backend_agg.pyc in draw(self) 437 """ 438 Create a new figure manager instance for the given figure.--> 439 """ 440 canvas = FigureCanvasAgg(figure) 441 manager = FigureManagerBase(canvas, num)/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/artist.pyc in draw_wrapper(artist, renderer, *args, **kwargs) 52 if artist.get_agg_filter() is not None: 53 renderer.stop_filter(artist.get_agg_filter())---> 54 55 if artist.get_rasterized(): 56 renderer.stop_rasterizing()/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/figure.pyc in draw(self, renderer) 997 else: 998 # Undocumented convenience behavior:--> 999 # subplot(111); subplot(111, projection='polar') 1000 # will replace the first with the second. 1001 # Without this, add_subplot would be simpler and/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/artist.pyc in draw_wrapper(artist, renderer, *args, **kwargs) 52 if artist.get_agg_filter() is not None: 53 renderer.stop_filter(artist.get_agg_filter())---> 54 55 if artist.get_rasterized(): 56 renderer.stop_rasterizing()/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/axes.pyc in draw(self, renderer, inframe)/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/artist.pyc in draw_wrapper(artist, renderer, *args, **kwargs) 52 if artist.get_agg_filter() is not None: 53 renderer.stop_filter(artist.get_agg_filter())---> 54 55 if artist.get_rasterized(): 56 renderer.stop_rasterizing()/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/collections.pyc in draw(self, renderer) 692 693 def get_linewidths(self):--> 694 return self._linewidths 695 get_linewidth = get_linewidths 696 TypeError: ufunc 'sqrt' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
It would be great if there was some sort of validation that happened early on, to make sure that e.g. params that expect a sequence of numbers complain if they get something like a string instead.