[Numpy-discussion] parsing dtype descriptors

Robert Kern robert.kern at gmail.com
Fri Jul 4 04:53:36 EDT 2014


On Thu, Jul 3, 2014 at 10:53 PM, Ted Sandler <ted.sandler at gmail.com> wrote:
> Thanks. No, it's not what I'm looking for.
>
> I'm looking for the code that parses the string "<i8" in the npy file array
> header's descriptor:
>
>   {'descr': '<i8', 'fortran_order': False, 'shape': (5,), }
>
> There are many different descriptor strings, e.g.:
>
>  '>f8'
>  '=f4'
>  'float32'
>  '>c16'
>  ...
>
> Ideally, I want the exhaustive list of valid input strings that describe
> standard ndarrays (i.e. ndarrays with simple entries as opposed to records
> or subarrays). Lacking an exhaustive list or spec, I'd like the source code
> that does the parsing for them.

https://github.com/numpy/numpy/blob/master/numpy/core/src/multiarray/descriptor.c#L1321
https://github.com/numpy/numpy/blob/master/numpy/core/src/multiarray/conversion_utils.c#L1000
https://github.com/numpy/numpy/blob/master/numpy/core/include/numpy/ndarraytypes.h#L97

-- 
Robert Kern



More information about the NumPy-Discussion mailing list