From: David G. <d_l...@ya...> - 2010-03-05 20:03:43
|
(Pierre GM: are you subscribed to this list? If so, sorry for cc-ing you.) --- On Fri, 3/5/10, Friedrich Romstedt <fri...@gm...> wrote: > From: Friedrich Romstedt <fri...@gm...> > Subject: Re: [Matplotlib-users] Mysterious "ValueError: zero-size array..." > To: "David Goldsmith" <d_l...@ya...> > Date: Friday, March 5, 2010, 10:46 AM > I can reproduce the error with: > > >>> argW = numpy.asarray([[0, 1, 2], [3, 4, 5], > [6, 7, 8], [9, 10, 11]]) > >>> argW > array([[ 0, 1, 2], > [ 3, 4, 5], > [ 6, 7, 8], > [ 9, 10, 11]]) > >>> argW[0:1, 0:0] > array([], shape=(1, 0), dtype=int32) > >>> d1.axes.imshow(argW[0:1, 0:0]) > Traceback (most recent call last): > File "<stdin>", line 1, in ? > File > "D:\Programme\Programmierung\python-2.4.1\lib\site-packages\matplotlib\axes.py", > line 5471, in imshow > im.autoscale_None() > File > "D:\Programme\Programmierung\python-2.4.1\lib\site-packages\matplotlib\cm.py", > line 148, in autoscale_None > self.norm.autoscale_None(self._A) > File > "D:\Programme\Programmierung\python-2.4.1\lib\site-packages\matplotlib\colors.py", > line 682, in autoscale_None > if self.vmin is None: self.vmin = > ma.minimum(A) > File > "D:\Programme\Programmierung\python-2.4.1\lib\site-packages\numpy\ma\core.py", > line 3042, in __call__ > return self.reduce(a) > File > "D:\Programme\Programmierung\python-2.4.1\lib\site-packages\numpy\ma\core.py", > line 3057, in reduce > t = self.ufunc.reduce(target, **kargs) > ValueError: zero-size array to ufunc.reduce without > identity > > So it seems to me that you pass in an array with shape < > 4 in at least > one of the dimensions? Thanks for your reply, Friedrich, and for creating the reproducing example! I think it's a bug in numpy.ma._extrema_operations.reduce (at least Pierre GM couldn't explain it away and instructed me to file a bug ticket on it over there, which I did; w/ your permission, I'll add your code to that ticket?) - at the very least, it should be able to handle zero-size arrays more robustly (i.e., w/out raising an exception) IMO. Of course, that doesn't mean that once it's been fixed, imshow (or cm, which is apparently what's really calling it) won't encounter some other problem on account of the fix, but I guess we'll have to cross that bridge when we come to it? > NB: You lose at most 3 pixels at the border of your image > when drawing > it the method you proposed, because the int floor'ing will > cause that. I was afraid of that (fancy index math has never been one of my strong suits) but ultimately I'm making ~5e3 x ~5e3 images (which is why I'm having to create the images that way in the first place - I was getting a memory error trying to imshow the whole full-resolution image w/ one call), so that loss is negligible (but if you can show me how to avoid it, I'd be much appreciative). > NB II: Something happened, you sent the last message four > times? Yeah, my apologies, I'm not sure why that happened; maybe was having connectivity issues and wasn't sure if I'd sent it successfully? Anyway, sorry 'bout that. :-( Thanks again! DG > > Friedrich > |
From: David G. <d_l...@ya...> - 2010-03-06 17:40:07
|
--- On Sat, 3/6/10, Friedrich Romstedt <fri...@gm...> wrote: > Note, that this is private discussion now and no longer on > the list > (accidentally?). If you want to put it back on the > list, please feel > free to do so. Yeah, my email client (yahoo!) showed your example submission email as being directly to me, not the list, so I assumed that you were sending it directly to me because you saw that I had cross-posted to the numpy list. Anyway, I'm returning this thread to this list, FWIW. > d1 is a diagram_cl.Diagram instance, holding a Sorry for being dense, but where do I get diagram_cl? >>> from matplotlib import diagram_cl as dc Traceback (most recent call last): File "<input>", line 1, in <module> ImportError: cannot import name diagram_cl and http://matplotlib.sourceforge.net/search.html?q=diagram_cl yields: Search Results Your search did not match any documents. DG > matplotlib.figure.Figure instance and an > matplotlib.axes.Axes instance > of that figure. I used it because I was too lazy to > create them on my > own. > > fwiw, diagram_cl is used to plot single-axes > diagrams. There are also > accompanying Layer2D (f(x) plots) and Layer3D > (xy-colorplots) classes. > They hide the internals of matplotlib completely and > provide a pure > data-oriented interface. > > Friedrich > |
From: Friedrich R. <fri...@gm...> - 2010-03-06 19:43:23
|
2010/3/6 David Goldsmith <d_l...@ya...>: > Yeah, my email client (yahoo!) showed your example submission email as being directly to me, not the list, so I assumed that you were sending it directly to me because you saw that I had cross-posted to the numpy list. Anyway, I'm returning this thread to this list, FWIW. Yeah, my e-mail client (gmail) chooses for e-mail from the matplotlib-users list as default recipient of the answer always the sender (maybe a misconfiguration?). I have to click "Answer All", and I sometimes fail to do so, and do not recognise. >> d1 is a diagram_cl.Diagram instance, holding a > > Sorry for being dense, but where do I get diagram_cl? All you tried won't work, diagram_cl is not included with matplotlib, and as I think it never will. Please clone or download from http://github.com/friedrichromstedt/diagram_cl . See also http://sourceforge.net/mailarchive/forum.php?thread_name=4B8443E2.9000506%40gmail.com&forum_name=matplotlib-users . Do you need advice with installing the package? I have not provided an setup.py so far. Friedrich |
From: David G. <d_l...@ya...> - 2010-03-06 20:13:16
|
--- On Sat, 3/6/10, Friedrich Romstedt <fri...@gm...> wrote: > >> d1 is a diagram_cl.Diagram instance, holding a > > > > Sorry for being dense, but where do I get diagram_cl? > > All you tried won't work, diagram_cl is not included with > matplotlib, > and as I think it never will. Please clone or > download from > http://github.com/friedrichromstedt/diagram_cl . See > also > http://sourceforge.net/mailarchive/forum.php?thread_name=4B8443E2.9000506%40gmail.com&forum_name=matplotlib-users > . Do you need advice with installing the package? I > have not provided > an setup.py so far. Ah, ok, not right now (perhaps later): for the purpose of adding your code to the numpy bug ticket, I think it's best if I use something a little more ubiquitous. ;-) But it looks useful, so I'll probably grab it and try it out myself; is it pure python, i.e., should I be able to just put it in a folder containing an init file in site-packages and then it should "just work"? Thanks again, DG DG > > Friedrich > |
From: Friedrich R. <fri...@gm...> - 2010-03-06 23:28:39
|
David Goldsmith: > Ah, ok, not right now (perhaps later): for the purpose of adding your code to the numpy bug ticket, I think it's best if I use something a little more ubiquitous. ;-) But it looks useful, so I'll probably grab it and try it out myself; is it pure python, i.e., should I be able to just put it in a folder containing an init file in site-packages and then it should "just work"? Yeah, simply have a look at diagram.py And yes, it should work out-of-the-box. The init file should be already included. Simply put it in a folder. It's tiny. Everything needed should be: import matplotlib.figure fig = matplotlib.figure.Figure() ax = fig.add_axes((0.2, 0.2, 0.6, 0.6)) ax.imshow(...) And would you mind if I put my opinion about the not-a-numpy-issue character on the numpy list too? I think it's a pure matplotlib problem, in my opinion numpy is behaving well, although they told you to fill in a ticket? Friedrich |
From: David G. <d_l...@ya...> - 2010-03-08 20:30:04
|
--- On Fri, 3/5/10, David Goldsmith <d_l...@ya...> wrote: > --- On Fri, 3/5/10, Friedrich Romstedt <fri...@gm...> > wrote: > > > NB: You lose at most 3 pixels at the border of your > image > > when drawing > > it the method you proposed, because the int floor'ing > will > > cause that. > > if you can show me how to avoid > it, I'd be much appreciative). Friedrich: thanks for all your help over on the NumPy list. For some reason I don't seem to be getting emails from this list, so if anyone replied to the query above, I didn't get it; perhaps you could reply off list? Thanks! DG |
From: Friedrich R. <fri...@gm...> - 2010-03-05 20:36:59
|
2010/3/5 David Goldsmith <d_l...@ya...>: > I think it's a bug in numpy.ma._extrema_operations.reduce (at least Pierre GM couldn't explain it away and instructed me to file a bug ticket on it over there, which I did; w/ your permission, I'll add your code to that ticket?) - at the very least, it should be able to handle zero-size arrays more robustly (i.e., w/out raising an exception) IMO. Of course, that doesn't mean that once it's been fixed, imshow (or cm, which is apparently what's really calling it) won't encounter some other problem on account of the fix, but I guess we'll have to cross that bridge when we come to it? Hmm, IMO it's correct to raise because the minimum of nothing isn't defined? Matplotlib tries to find a minimum. Anyway, you cannot draw ndarrays arr with 0 in arr.shape. So I think matplotlib should maybe silently skip attempting to draw it? Friedrich |