[Numpy-discussion] numpy.ma.flatnotmasked_contiguous error in slice.stop values?

Pierre GM pgmdevlist@gmail....
Sun Aug 8 21:47:00 CDT 2010


On Aug 8, 2010, at 10:37 PM, Geordie McBain wrote:

> The function numpy.ma.flatnotmasked_contiguous returns slices which
> miss the last element; for example, based on the example at
> http://docs.scipy.org/doc/numpy/reference/generated/numpy.ma.flatnotmasked_contiguous.html,

OK, mind opening a ticket ? I'll try to take care of that tmw and I don't want the bug report to fall between the cracks.
> 
> which isn't really what we're after; I would have expected [3 4] and
> [6 7 8]. Compare the similarly named
> matplotlib.mlab.contiguous_regions which does have the expected
> behaviour (although its output format is different)

Oh, I didn't know there was such an option in mpl. I wonder when it got introduced...

> import matplotlib.mlab
> segments1 = matplotlib.mlab.contiguous_regions (am)
> print 'contiguous_regions:', segments1
> print am[slice (*segments1[0])], am[slice (*segments1[1])]
> 
> which prints
> 
> contiguous_regions: [(3, 5), (6, 9)]

Mmh, tuples are nicer than slices... We'll see.

> [3 4] [6 7 8]
> 
> (I'm running Python 2.6.4 on 64-bit Linux Mint 8 `Helena', with NumPy
> from Ubuntu Karmic, which I think means I have NumPy version 1.3.0?)

print numpy.version.version



More information about the NumPy-Discussion mailing list