Discussion:
[Numpy-discussion] Should dtypes have an ndim attribute?
Gerrit Holl
2015-12-10 11:13:26 UTC
Permalink
Hi,

I have made a modest proposal in issue #6752
<https://github.com/numpy/numpy/issues/6752>. Basically, the proposal
is to add an `ndim` attribute to dtypes. Currently, arrays have a
shape and an ndim attribute, where ndim equals len(shape). dtype
objects have a shape attribute, but no corresponding ndim.

An ndim attribute would help in immediately determining whether a
field in a structured dtype is multidimensional or not.

Thoughts?

Gerrit.
Andy Ray Terrel
2015-12-10 12:11:30 UTC
Permalink
That's essentially what datashape did over in the blaze ecosystem. It gets
a bit fancier to support ragged arrays and optional types.

http://datashape.readthedocs.org/en/latest/
Post by Gerrit Holl
Hi,
I have made a modest proposal in issue #6752
<https://github.com/numpy/numpy/issues/6752>. Basically, the proposal
is to add an `ndim` attribute to dtypes. Currently, arrays have a
shape and an ndim attribute, where ndim equals len(shape). dtype
objects have a shape attribute, but no corresponding ndim.
An ndim attribute would help in immediately determining whether a
field in a structured dtype is multidimensional or not.
Thoughts?
Gerrit.
_______________________________________________
NumPy-Discussion mailing list
https://mail.scipy.org/mailman/listinfo/numpy-discussion
Nathaniel Smith
2015-12-10 21:30:33 UTC
Permalink
Post by Andy Ray Terrel
That's essentially what datashape did over in the blaze ecosystem. It
gets a bit fancier to support ragged arrays and optional types.
Post by Andy Ray Terrel
http://datashape.readthedocs.org/en/latest/
IIUC this is a much more modest proposal, for numpy's existing dtypes that
represent subarrays.

It seems pretty harmless I guess. It's a little uncomfortable to be adding
yet another attribute to all dtypes that will only be used by one obscure
subset of dtypes, but it's no worse than a bunch of other already existing
attributes in that respect.

-n

Loading...