Re: [matplotlib-devel] [Python-modules-team] Bug#573179: "AttributeError: 'numpy.bool_' object has no attribute '_mask'" whenever imshow'ing masked array
Sandro Tosi wrote: > forwarded 573179 matplotlib-devel@lists.sourceforge.net > thanks > > Hello Matplotlib developers, > I'm forwarding this bug a Debian user reported some days ago. It would > be nice it you could give it a look Using svn trunk mpl and numpy 1.5.0.dev8042, I can't reproduce it; I get a blank figure and a blank colorbar, with no exception. I suspect the difference is in numpy.ma, not matplotlib. Eric > > Thanks in advance, > Sandro > > On Tue, Mar 9, 2010 at 17:05, Yaroslav Halchenko > wrote: >> Package: python-matplotlib >> Version: 0.99.1.2-3 >> Severity: normal >> >> >> throws an exception while comparing two masked arrays which have no values >> (all >> masked out)... sure thing it can't determine vmin/vmax to be used (unless >> clim >> is used explicitely), but the exception which is thrown is non-informative. >> I >> thought that upstream might want to make it more user-friendly -- please >> forward upstream. >> >> Here is the code to reproduce: >> import pylab as pl >> import numpy as np >> >> size = (5, 5) >> d = np.ones(size) >> mask = d.astype(bool) >> >> md = np.ma.masked_array(d, mask) >> pl.imshow(md) >> # explicit clim would eliminate the problem >> #pl.clim(0, 1) >> pl.colorbar() >> >> and here is the traceback: >> >> Traceback (most recent call last): >> File "/usr/lib/python2.5/lib-tk/Tkinter.py", line 1417, in __call__ >>return self.func(*args) >> File "/usr/lib/pymodules/python2.5/matplotlib/backends/backend_tkagg.py", >> line 212, in resize >>self.show() >> File "/usr/lib/pymodules/python2.5/matplotlib/backends/backend_tkagg.py", >> line 215, in draw >>FigureCanvasAgg.draw(self) >> File "/usr/lib/pymodules/python2.5/matplotlib/backends/backend_agg.py", >> line 314, in draw >>self.figure.draw(self.renderer) >> File "/usr/lib/pymodules/python2.5/matplotlib/artist.py", line 46, in >> draw_wrapper >>draw(artist, renderer, *kl) >> File "/usr/lib/pymodules/python2.5/matplotlib/figure.py", line 773, in draw >>for a in self.axes: a.draw(renderer) >> File "/usr/lib/pymodules/python2.5/matplotlib/artist.py", line 46, in >> draw_wrapper >>draw(artist, renderer, *kl) >> File "/usr/lib/pymodules/python2.5/matplotlib/axes.py", line 1701, in draw >>im.draw(renderer) >> File "/usr/lib/pymodules/python2.5/matplotlib/artist.py", line 46, in >> draw_wrapper >>draw(artist, renderer, *kl) >> File "/usr/lib/pymodules/python2.5/matplotlib/image.py", line 237, in draw >>im = self.make_image(renderer.get_image_magnification()) >> File "/usr/lib/pymodules/python2.5/matplotlib/image.py", line 182, in >> make_image >>x = self.to_rgba(self._A, self._alpha) >> File "/usr/lib/pymodules/python2.5/matplotlib/cm.py", line 166, in to_rgba >>x = self.norm(x) >> File "/usr/lib/pymodules/python2.5/matplotlib/colors.py", line 763, in >> __call__ >>elif vmin==vmax: >> File "/usr/lib/python2.5/site-packages/numpy/ma/core.py", line 3119, in >> __eq__ >>check._mask = mask >> AttributeError: 'numpy.bool_' object has no attribute '_mask' >> >> >> >> >> >> >> -- System Information: >> Debian Release: squeeze/sid >> APT prefers unstable >> APT policy: (901, 'unstable'), (900, 'testing'), (300, 'experimental') >> Architecture: amd64 (x86_64) >> >> Kernel: Linux 2.6.31-1-amd64 (SMP w/2 CPU cores) >> Locale: LANG=en_US, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8) >> Shell: /bin/sh linked to /bin/bash >> >> Versions of packages python-matplotlib depends on: >> ii libatk1.0-0 1.28.0-1 The ATK accessibility toolkit >> ii libc6 2.10.2-5 Embedded GNU C Library: Shared >> lib >> ii libcairo2 1.8.8-2 The Cairo 2D vector graphics >> libra >> ii libfontconfig1 2.8.0-2 generic font configuration >> library >> ii libfreetype62.3.11-1 FreeType 2 font engine, shared >> lib >> ii libgcc1 1:4.4.2-2GCC support library >> ii libglib2.0-02.22.4-1 The GLib library of C routines >> ii libgtk2.0-0 2.18.6-1 The GTK+ graphical user >> interface >> ii libpango1.0-0 1.26.0-1 Layout and rendering of >> internatio >> ii libpng12-0 1.2.40-1 PNG library - runtime >> ii libstdc++6 4.4.2-2 The GNU Standard C++ Library v3 >> ii python 2.5.4-9 An interactive high-level >> object-o >> ii python-cairo1.8.6-1 Python bindings for the Cairo >> vect >> ii python-dateutil 1.4.1-3 powerful extensions to the >> standar >> ii python-gobject 2.16.1-1 Python bindings for the GObject >> li >> ii python-matplotlib-data 0.99.1.2-3 Python based plotting system >> (data >> ii python-numpy1:1.3.0-3+b1 Numerical Python adds a fast >> array >> ii python-pyparsing1.5.2-1 Python parsing module >> ii python-s
Re: [matplotlib-devel] [Python-modules-team] Bug#573179: "AttributeError: 'numpy.bool_' object has no attribute '_mask'" whenever imshow'ing masked array
forwarded 573179 matplotlib-devel@lists.sourceforge.net thanks Hello Matplotlib developers, I'm forwarding this bug a Debian user reported some days ago. It would be nice it you could give it a look Thanks in advance, Sandro On Tue, Mar 9, 2010 at 17:05, Yaroslav Halchenko wrote: > Package: python-matplotlib > Version: 0.99.1.2-3 > Severity: normal > > > throws an exception while comparing two masked arrays which have no values > (all > masked out)... sure thing it can't determine vmin/vmax to be used (unless clim > is used explicitely), but the exception which is thrown is non-informative. I > thought that upstream might want to make it more user-friendly -- please > forward upstream. > > Here is the code to reproduce: > import pylab as pl > import numpy as np > > size = (5, 5) > d = np.ones(size) > mask = d.astype(bool) > > md = np.ma.masked_array(d, mask) > pl.imshow(md) > # explicit clim would eliminate the problem > #pl.clim(0, 1) > pl.colorbar() > > and here is the traceback: > > Traceback (most recent call last): > File "/usr/lib/python2.5/lib-tk/Tkinter.py", line 1417, in __call__ > return self.func(*args) > File "/usr/lib/pymodules/python2.5/matplotlib/backends/backend_tkagg.py", > line 212, in resize > self.show() > File "/usr/lib/pymodules/python2.5/matplotlib/backends/backend_tkagg.py", > line 215, in draw > FigureCanvasAgg.draw(self) > File "/usr/lib/pymodules/python2.5/matplotlib/backends/backend_agg.py", line > 314, in draw > self.figure.draw(self.renderer) > File "/usr/lib/pymodules/python2.5/matplotlib/artist.py", line 46, in > draw_wrapper > draw(artist, renderer, *kl) > File "/usr/lib/pymodules/python2.5/matplotlib/figure.py", line 773, in draw > for a in self.axes: a.draw(renderer) > File "/usr/lib/pymodules/python2.5/matplotlib/artist.py", line 46, in > draw_wrapper > draw(artist, renderer, *kl) > File "/usr/lib/pymodules/python2.5/matplotlib/axes.py", line 1701, in draw > im.draw(renderer) > File "/usr/lib/pymodules/python2.5/matplotlib/artist.py", line 46, in > draw_wrapper > draw(artist, renderer, *kl) > File "/usr/lib/pymodules/python2.5/matplotlib/image.py", line 237, in draw > im = self.make_image(renderer.get_image_magnification()) > File "/usr/lib/pymodules/python2.5/matplotlib/image.py", line 182, in > make_image > x = self.to_rgba(self._A, self._alpha) > File "/usr/lib/pymodules/python2.5/matplotlib/cm.py", line 166, in to_rgba > x = self.norm(x) > File "/usr/lib/pymodules/python2.5/matplotlib/colors.py", line 763, in > __call__ > elif vmin==vmax: > File "/usr/lib/python2.5/site-packages/numpy/ma/core.py", line 3119, in > __eq__ > check._mask = mask > AttributeError: 'numpy.bool_' object has no attribute '_mask' > > > > > > > -- System Information: > Debian Release: squeeze/sid > APT prefers unstable > APT policy: (901, 'unstable'), (900, 'testing'), (300, 'experimental') > Architecture: amd64 (x86_64) > > Kernel: Linux 2.6.31-1-amd64 (SMP w/2 CPU cores) > Locale: LANG=en_US, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8) > Shell: /bin/sh linked to /bin/bash > > Versions of packages python-matplotlib depends on: > ii libatk1.0-0 1.28.0-1 The ATK accessibility toolkit > ii libc6 2.10.2-5 Embedded GNU C Library: Shared > lib > ii libcairo2 1.8.8-2 The Cairo 2D vector graphics > libra > ii libfontconfig1 2.8.0-2 generic font configuration > library > ii libfreetype6 2.3.11-1 FreeType 2 font engine, shared > lib > ii libgcc1 1:4.4.2-2 GCC support library > ii libglib2.0-0 2.22.4-1 The GLib library of C routines > ii libgtk2.0-0 2.18.6-1 The GTK+ graphical user interface > ii libpango1.0-0 1.26.0-1 Layout and rendering of > internatio > ii libpng12-0 1.2.40-1 PNG library - runtime > ii libstdc++6 4.4.2-2 The GNU Standard C++ Library v3 > ii python 2.5.4-9 An interactive high-level > object-o > ii python-cairo 1.8.6-1 Python bindings for the Cairo > vect > ii python-dateutil 1.4.1-3 powerful extensions to the > standar > ii python-gobject 2.16.1-1 Python bindings for the GObject > li > ii python-matplotlib-data 0.99.1.2-3 Python based plotting system > (data > ii python-numpy 1:1.3.0-3+b1 Numerical Python adds a fast > array > ii python-pyparsing 1.5.2-1 Python parsing module > ii python-support 1.0.6.1 automated rebuilding support for > P > ii python-tz 2009l-1 Python version of the Olson > timezo > ii tcl8.5 8.5.7-1 Tcl (the Tool Command Language) > v8 > ii tk8.5 8.5.7-1 Tk toolkit for Tcl and X11, v8.5 > - > ii zlib1g 1:1.2.3.4.d
Re: [matplotlib-devel] Proposal for Broken Axes
> What would be great is if you could refactor the basic functionality > into a matplotlib.Axes.breaky method (and possibly breakx but most > people request a broken y axis), which would resize the "self" axes > and return the broken compliment which could be plotted onto. Then > you could provide a thin pyplot wrapper much like pyplot.twinx, so > that pyplot as well as API users could benefit. I can try to do this. I think I would prefer, however, not to resize the "self" axes and continue with my current approach of creating two new axes within the original axes. On the user end, I think it makes more sense to set the title and ylabel of the main axes, rather than setting them for the individual upper and lower axes. More on that below. >> The only real problems here is that you need to >> explicitly plot things on both the upper and lower axes, and then I haven't >> figured out how to push out the y-axis label of the main axes object so it >> doesn't overlap with the tick labels of the upper and lower axes. So, I >> instead moved the y-labels of the upper and lower axes so that they appear >> at the center of the axis, but this is problematic. Any thoughts on how to >> do that part better? > > klukas, I'm afraid I don't understand your issue... Can you explain using it > differently? In my approach, you end up with a main axes object that is invisible, and then two visible axes objects (upper and lower) within the main axes. I would ideally like to have the y label display in the middle of the main y-axis, independent of where the break lies. If I place a y label on the main axes (which has ticks or tick labels), though, it appears right up against the axis line. I'd like it to be placed further to the left, clear of the tick labels that appear on the upper and lower axes. So, I'd like to be able to access whatever algorithm is used to choose the offset of the axis label, and explicitly set the offset of the ylabel for the main axes so that it clears the tick labels. // Jeff -- Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev ___ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
Re: [matplotlib-devel] Contouring unstructured triangular grids
Replying to everyone at the same time: (spot the person in the UK!) Chris Barker wrote: > That would be better as (ntri, 3), to be compatible with the usual C > ordering of numpy arrays. Of course. John Hunter wrote: > I am a little concerned about the "hand wrapped python" part > because of the possibilities of introducing memory leaks and > difficulties it may pose in the matplotlib 2->3 transition. > It would probably be beneficial, but by no means required, to use > CXX to expose the C++ part to python so take a look if you are > inclined. I've taken a look at CXX and it looks like a much more pleasant solution, so I'm happy to use that instead. > I'm also a bit concerned by the maintenance aspect, since this > is a fairly sophisticated piece of code. We'd be looking for a > commitment to support it if we include it in mpl. Understood. I'm uneasy about making a major commitment at this stage as I'm new to open source contributions, so how about you ask me again when I've submitted the code and people have had the chance to review/correct/admire/destroy it? > Eric Firing wrote: > One possibility would be to develop the tri* functionality at least > initially as a module in lib/mpl_toolkits, like axes_grid and mplot3d; > or in a module in lib/matplotlib. This could still take advantage of > refactoring in contour.py. An advantage is that it would consolidate > the triangle functionality so it would be easier to find, track, and > document. I like the idea of putting it in its own directory under lib/matplotlib. > What sort of timeline do you have in mind? I am currently "between jobs", which leaves me plenty of spare time for interesting projects. I reckon I should have something worthy of consideration in 2 weeks time. Ian -- Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev ___ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
Re: [matplotlib-devel] Proposal for Broken Axes
Hi, > Date: Mon, 15 Mar 2010 13:16:59 -0700 (PDT) > From: klukas > > It's my understanding that there is no built-in method for generating a > "broken axis" (where you skip over some range of values, indicating this > with some graphical mark). I've fudged something similar recently, using a more hacky approach. I wanted to display a time series with potentially large gaps in its recording, so I figured out a way to remove the gaps from the plot by "compacting" the x data, but adjusting the x tick labels to reflect the original values of the data. Here is an example: Suppose I have two segments in my time series that are far apart in time. The segments typically have different lengths. Both the x and y data are stored as a sequence of 2 arrays (1 per segment), e.g. x = [ [3, 4, 5, 6, 7, 8, 9], [340, 342, 344, 346, 348] ] y = [ [ ... ], [ ... ] ] I only focus on the x (time) axis in this case. I compact the x values so that the minimum value of the first segment is 0, and the minimum value of each subsequent segment is equal to the maximum value of the segment to the left of it. This preserves the relative x-spacing between the points of the same segment, but shifts the segments to sit right next to each other. For the above example, I subtract an offset of 3 for the first segment and 334 for the second segment to get: compacted_x = [ [0, 1, 2, 3, 4, 5, 6], [6, 8, 10, 12, 14] ] I then plot the (compacted_x, y) segments as usual on a single Axes, in my case using a LineCollection. Afterwards, I define a new tick formatter derived from the standard mpl.ticker.ScalarFormatter that determines which segment contains the x-value it is called with and then adds back the appropriate offset before creating the tick label. I also add dashed vertical "break lines" to indicate the breaks between segments. This scheme works especially well for monotonically increasing ticks (such as time series). I can provide code if anyone is interested. I've extended it to x and y axes, and it will split image segments in the same way as line segments (for spectrograms, for example). The only major current downside is that the cursor displays the compacted x-value when hovering over the plot (maybe this could be fixed too?). Regards, Ludwig -- Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev ___ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel