@@ -405,6 +405,7 @@ def check_field(self, field, required_channels="all"):
405
405
parent_class = (
406
406
lambda f : np .integer if f == "d_signal" else np .floating
407
407
)(field ),
408
+ min_itemsize = 8 if field == "p_signal" else None ,
408
409
)
409
410
elif field in ["e_d_signal" , "e_p_signal" ]:
410
411
for ch in range (len (item )):
@@ -418,6 +419,7 @@ def check_field(self, field, required_channels="all"):
418
419
)
419
420
)(field ),
420
421
channel_num = ch ,
422
+ min_itemsize = 8 if field == "e_p_signal" else None ,
421
423
)
422
424
423
425
# Record specification fields
@@ -1745,7 +1747,9 @@ def _check_item_type(
1745
1747
)
1746
1748
1747
1749
1748
- def check_np_array (item , field_name , ndim , parent_class , channel_num = None ):
1750
+ def check_np_array (
1751
+ item , field_name , ndim , parent_class , min_itemsize = None , channel_num = None
1752
+ ):
1749
1753
"""
1750
1754
Check a numpy array's shape and dtype against required
1751
1755
specifications.
@@ -1786,6 +1790,15 @@ def check_np_array(item, field_name, ndim, parent_class, channel_num=None):
1786
1790
error_msg = ("Channel %d of f" % channel_num ) + error_msg [1 :]
1787
1791
raise TypeError (error_msg )
1788
1792
1793
+ if min_itemsize is not None and item .dtype .itemsize < min_itemsize :
1794
+ error_msg = "Field `%s` must have a dtype itemsize of at least %d" % (
1795
+ field_name ,
1796
+ min_itemsize ,
1797
+ )
1798
+ if channel_num is not None :
1799
+ error_msg = ("Channel %d of f" % channel_num ) + error_msg [1 :]
1800
+ raise TypeError (error_msg )
1801
+
1789
1802
1790
1803
# ------------------------- Reading Records --------------------------- #
1791
1804
0 commit comments