@@ -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,7 @@ 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 (item , field_name , ndim , parent_class , min_itemsize = None , channel_num = None ):
1749
1751
"""
1750
1752
Check a numpy array's shape and dtype against required
1751
1753
specifications.
@@ -1786,6 +1788,15 @@ def check_np_array(item, field_name, ndim, parent_class, channel_num=None):
1786
1788
error_msg = ("Channel %d of f" % channel_num ) + error_msg [1 :]
1787
1789
raise TypeError (error_msg )
1788
1790
1791
+ if min_itemsize is not None and item .dtype .itemsize < min_itemsize :
1792
+ error_msg = "Field `%s` must have a bit depth of at least %d" % (
1793
+ field_name ,
1794
+ min_itemsize ,
1795
+ )
1796
+ if channel_num is not None :
1797
+ error_msg = ("Channel %d of f" % channel_num ) + error_msg [1 :]
1798
+ raise TypeError (error_msg )
1799
+
1789
1800
1790
1801
# ------------------------- Reading Records --------------------------- #
1791
1802
0 commit comments