Strip padding fields in dtypes, update the tests
diff --git a/example/example20.py b/example/example20.py
index e0a0018..85ea9ae 100644
--- a/example/example20.py
+++ b/example/example20.py
@@ -5,7 +5,8 @@
import numpy as np
from example import (
create_rec_simple, create_rec_packed, create_rec_nested, print_format_descriptors,
- print_rec_simple, print_rec_packed, print_rec_nested, print_dtypes, get_format_unbound
+ print_rec_simple, print_rec_packed, print_rec_nested, print_dtypes, get_format_unbound,
+ create_rec_partial, create_rec_partial_nested
)
@@ -23,6 +24,8 @@
'offsets': [0, 4, 8]})
packed_dtype = np.dtype([('x', '?'), ('y', 'u4'), ('z', 'f4')])
+elements = [(False, 0, 0.0), (True, 1, 1.5), (False, 2, 3.0)]
+
for func, dtype in [(create_rec_simple, simple_dtype), (create_rec_packed, packed_dtype)]:
arr = func(0)
assert arr.dtype == dtype
@@ -31,14 +34,30 @@
arr = func(3)
assert arr.dtype == dtype
- check_eq(arr, [(False, 0, 0.0), (True, 1, 1.5), (False, 2, 3.0)], simple_dtype)
- check_eq(arr, [(False, 0, 0.0), (True, 1, 1.5), (False, 2, 3.0)], packed_dtype)
+ check_eq(arr, elements, simple_dtype)
+ check_eq(arr, elements, packed_dtype)
if dtype == simple_dtype:
print_rec_simple(arr)
else:
print_rec_packed(arr)
+
+arr = create_rec_partial(3)
+print(arr.dtype)
+partial_dtype = arr.dtype
+assert '' not in arr.dtype.fields
+assert partial_dtype.itemsize > simple_dtype.itemsize
+check_eq(arr, elements, simple_dtype)
+check_eq(arr, elements, packed_dtype)
+
+arr = create_rec_partial_nested(3)
+print(arr.dtype)
+assert '' not in arr.dtype.fields
+assert '' not in arr.dtype.fields['a'][0].fields
+assert arr.dtype.itemsize > partial_dtype.itemsize
+np.testing.assert_equal(arr['a'], create_rec_partial(3))
+
nested_dtype = np.dtype([('a', simple_dtype), ('b', packed_dtype)])
arr = create_rec_nested(0)