Skip to content

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

@eugenwintersberger

Description

@eugenwintersberger

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))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions