[NeXus-code-tickets] [NeXusCode] #156: python: support '|S1' for string data
NeXus Data Format Library and Applications
noreply at nexusformat.org
Mon Jan 26 11:48:41 GMT 2009
#156: python: support '|S1' for string data
------------------------------+---------------------------------------------
Reporter: Cpascual | Owner: Unassigned
Type: defect | Status: new
Priority: minor | Milestone:
Component: bindings | Version: 4.2rc2
Keywords: numpy dtype char |
------------------------------+---------------------------------------------
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))
}}}
--
Ticket URL: <http://trac.nexusformat.org/code/ticket/156>
NeXus Data Format Library and Applications <http://www.nexusformat.org/>
NeXus Data Format Library and Applications
More information about the NeXus-code-tickets
mailing list