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

python: support '|S1' for string data #1

Open
eugenwintersberger opened this issue Nov 30, 2015 · 1 comment
Open

python: support '|S1' for string data #1

eugenwintersberger opened this issue Nov 30, 2015 · 1 comment

Comments

@eugenwintersberger
Copy link
Contributor

Original reporter: Cpascual

It would be nice if '|S1' was accepted as a synonym of 'char' when passing dtype to napi functions.
See attached patch to 4.2rc2 napi.py

Rationale:
Currently one can use numpy.dtype objects wherever a napi function requires dtype except for the case of string data.
This is because the numpy-->nexus data type conversion is done through

_nxtype_code[str(type)]

In the case of numpy 1-character arrays, str(dtype) returns '|S1', so at least this case can be covered pretty easily by using the proposed patch.

Note that this only works for numpy 1-character arrays, not for python strings. But at least one can convert to an array using:

numpy.array(tuple(string))
@eugenwintersberger
Copy link
Contributor Author

This issue was transfered from the original NAPI repository. It was issue nexusformat/code#156

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