[Numpy-discussion] bug in ma.masked_all()?
Eric Firing
efiring@hawaii....
Tue Dec 2 03:26:35 CST 2008
Pierre GM wrote:
> Eric,
> That's quite a handful you have with this dtype...
Here is a simplified example of how I made it:
dt = np.dtype({'names': ['a','b'], 'formats': ['f', 'f'], 'titles':
['aaa', 'bbb']})
From page 132 in the numpy book:
The fields dictionary is indexed by keys that are the names of the
fields. Each entry in the dictionary is a tuple fully describing the
field: (dtype, offset[,title]). If present, the optional title can
actually be any object (if it is string or unicode then it will also be
a key in the fields dictionary, otherwise it’s meta-data).
--------
I put the titles in as a sort of additional documentation, and thinking
that they might be useful for labeling plots; but it is rather hard to
get the titles back out, since they are not directly accessible as an
attribute, like names. Probably I should just omit them.
Eric
> So yes, the fix I gave works with nested dtypes and flexible dtypes
> with a simple name (string, not tuple). I'm a bit surprised with
> numpy, here.
> Consider:
>
> >>> dt.names
> ('P', 'D', 'T', 'w', 'S', 'sigtheta', 'theta')
>
> So we lose the tuple and get a single string instead, corresponding to
> the right-hand element of the name..
> But this single string is one of the keys of dt.fields, whereas the
> tuple is not. Puzzling. I'm sure there must be some reference in the
> numpy book, but I can't look for it now.
>
> Anyway:
> Prior to version 6127, make_mask_descr was substituting the 2nd
> element of each tuple of a dtype.descr by a bool. Which failed for
> nested dtypes. Now, we check the field corresponding to a name, which
> fails in our particular case.
>
>
> I'll be working on it...
>
>
>
> On Dec 2, 2008, at 1:59 AM, Eric Firing wrote:
>
>> dt = np.dtype([((' Pressure, Digiquartz [db]', 'P'), '<f4'), (('
>> Depth [salt water, m]', 'D'), '<f4'), ((' Temperature [ITS-90, deg
>> C]', 'T'), '<f4'), ((' Descent Rate [m/s]', 'w'), '<f4'), (('
>> Salinity [PSU]', 'S'), '<f4'), ((' Density [sigma-theta, Kg/m^3]',
>> 'sigtheta'), '<f4'), ((' Potential Temperature [ITS-90, deg C]',
>> 'theta'), '<f4')])
>>
>> np.ma.zeros((2,2), dt)
>
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion@scipy.org
> http://projects.scipy.org/mailman/listinfo/numpy-discussion
More information about the Numpy-discussion
mailing list