[Numpy-discussion] parsing dtype descriptors

Ted Sandler ted.sandler at gmail.com
Thu Jul 3 17:53:51 EDT 2014


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.  This stackoverflow post is worth looking
at:


http://stackoverflow.com/questions/13997087/what-are-the-available-datatypes-for-dtype-with-numpys-loadtxt-an-genfromtxt

Thanks again,
Ted







On Thu, Jul 3, 2014 at 12:35 PM, Valentin Haenel <valentin at haenel.co> wrote:

> Dear Ted,
>
> * Ted Sandler <ted.sandler at gmail.com> [2014-07-03]:
> > Hi all, is there a spec or grammar for valid values of numpy dtype
> > descriptor strings?
> >
> > I am writing code to parse ".npy" files from Java and want to be able to
> > handle the range of ndarray descriptor strings. I came across this code:
> >
> >    dtype = numpy.dtype(d['descr'])
> >
> > at line 267 in format.py:
> >
> >    https://github.com/numpy/numpy/blob/master/numpy/lib/format.py
> >
> > However, I can't seem to find where it's implemented.
>
> Not sure exactly, what you are looking for, but maybe the following
> helps:
>
> https://github.com/numpy/numpy/blob/master/numpy/lib/format.py#L210
>
> best,
>
> V-
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20140703/cc8f82e9/attachment.html>


More information about the NumPy-Discussion mailing list