Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stricter types for dtype arguments #4

Open
dmoisset opened this issue Jul 26, 2016 · 0 comments
Open

Stricter types for dtype arguments #4

dmoisset opened this issue Jul 26, 2016 · 0 comments

Comments

@dmoisset
Copy link
Contributor

Many functions accept a dtype argument for type conversions. That argument can be an instance of numpy.dtype or anything that can be converted to those by the numpy.dtype constructor. That includes:

  • python types (like, int, float, str, MyCustomClass)
  • lists of field descriptions like [('f1', np.uint), ('f2', np.int32)]
  • strings with standard type names (int32), or dtype descriptions like <i2.
  • dicts with fields/formats of fields

More details available at http://docs.scipy.org/doc/numpy/reference/generated/numpy.dtype.html

Currently, those arguments are typed inconsistently as Any, object, or DtypeType which covers only the first case. The fix for this should probably cover:

  1. Giving all those arguments a DtypeSpec type
  2. change the numpy.dtype signature to accept a DtypeSpec argument
  3. Make DtypeSpec as close as possible to the description above.

For item 3, it's not necessary to cover everything that's possible but it should cover the most frequent uses.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant