Commit 926337d9 authored by Gerald Dalley's avatar Gerald Dalley

tweak to PyDataType_SHAPE: return () instead of None

This makes PyDataType_SHAPE more consistent with the Python API.
parent 7bd68089
...@@ -803,7 +803,7 @@ cdef inline tuple PyDataType_SHAPE(dtype d): ...@@ -803,7 +803,7 @@ cdef inline tuple PyDataType_SHAPE(dtype d):
if PyDataType_HASSUBARRAY(d): if PyDataType_HASSUBARRAY(d):
return <tuple>d.subarray.shape return <tuple>d.subarray.shape
else: else:
return None return ()
cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL: cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL:
# Recursive utility function used in __getbuffer__ to get format # Recursive utility function used in __getbuffer__ to get format
......
...@@ -32,6 +32,6 @@ def test_record_subarray(): ...@@ -32,6 +32,6 @@ def test_record_subarray():
assert <tuple>b_descr.subarray.shape == (3, 3) assert <tuple>b_descr.subarray.shape == (3, 3)
# Make sure the safe high-level helper function works # Make sure the safe high-level helper function works
assert np.PyDataType_SHAPE(descr) is None assert np.PyDataType_SHAPE(descr) == ()
assert np.PyDataType_SHAPE(a_descr) is None assert np.PyDataType_SHAPE(a_descr) == ()
assert np.PyDataType_SHAPE(b_descr) == (3, 3) assert np.PyDataType_SHAPE(b_descr) == (3, 3)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment