@@ -291,6 +291,10 @@ def is_typed_array_spec(v):
291
291
return isinstance (v , dict ) and "bdata" in v
292
292
293
293
294
+ def is_none_or_typed_array_spec (v ):
295
+ return v is None or is_typed_array_spec (v )
296
+
297
+
294
298
def is_simple_array (v ):
295
299
"""
296
300
Return whether a value is considered to be an simple array
@@ -485,11 +489,7 @@ def description(self):
485
489
486
490
def validate_coerce (self , v ):
487
491
488
- if v is None :
489
- # Pass None through
490
- pass
491
- elif is_typed_array_spec (v ):
492
- # Pass typed array spec through
492
+ if is_none_or_typed_array_spec (v ):
493
493
pass
494
494
elif is_homogeneous_array (v ):
495
495
v = to_typed_array_spec (v )
@@ -686,8 +686,7 @@ def in_values(self, e):
686
686
return False
687
687
688
688
def validate_coerce (self , v ):
689
- if v is None :
690
- # Pass None through
689
+ if is_none_or_typed_array_spec (v ):
691
690
pass
692
691
elif self .array_ok and is_array (v ):
693
692
v_replaced = [self .perform_replacemenet (v_el ) for v_el in v ]
@@ -847,8 +846,7 @@ def description(self):
847
846
return desc
848
847
849
848
def validate_coerce (self , v ):
850
- if v is None :
851
- # Pass None through
849
+ if is_none_or_typed_array_spec (v ):
852
850
pass
853
851
elif self .array_ok and is_homogeneous_array (v ):
854
852
np = get_module ("numpy" )
@@ -975,8 +973,7 @@ def description(self):
975
973
return desc
976
974
977
975
def validate_coerce (self , v ):
978
- if v is None :
979
- # Pass None through
976
+ if is_none_or_typed_array_spec (v ):
980
977
pass
981
978
elif self .array_ok and is_homogeneous_array (v ):
982
979
np = get_module ("numpy" )
@@ -1130,8 +1127,7 @@ def description(self):
1130
1127
return desc
1131
1128
1132
1129
def validate_coerce (self , v ):
1133
- if v is None :
1134
- # Pass None through
1130
+ if is_none_or_typed_array_spec (v ):
1135
1131
pass
1136
1132
elif self .array_ok and is_array (v ):
1137
1133
@@ -1432,8 +1428,7 @@ def description(self):
1432
1428
return valid_color_description
1433
1429
1434
1430
def validate_coerce (self , v , should_raise = True ):
1435
- if v is None :
1436
- # Pass None through
1431
+ if is_none_or_typed_array_spec (v ):
1437
1432
pass
1438
1433
elif self .array_ok and is_homogeneous_array (v ):
1439
1434
v = copy_to_readonly_numpy_array (v )
@@ -1577,8 +1572,7 @@ def description(self):
1577
1572
1578
1573
def validate_coerce (self , v ):
1579
1574
1580
- if v is None :
1581
- # Pass None through
1575
+ if is_none_or_typed_array_spec (v ):
1582
1576
pass
1583
1577
elif is_array (v ):
1584
1578
validated_v = [
@@ -1783,8 +1777,7 @@ def description(self):
1783
1777
return desc
1784
1778
1785
1779
def validate_coerce (self , v ):
1786
- if v is None :
1787
- # Pass None through
1780
+ if is_none_or_typed_array_spec (v ):
1788
1781
pass
1789
1782
elif self .array_ok and is_homogeneous_array (v ):
1790
1783
try :
@@ -1972,6 +1965,9 @@ def validate_coerce(self, v):
1972
1965
if v is None :
1973
1966
# Pass None through
1974
1967
pass
1968
+ if is_typed_array_spec (v ):
1969
+ # Pass typed array spec through
1970
+ pass
1975
1971
elif self .array_ok and is_array (v ):
1976
1972
1977
1973
# Coerce individual strings
@@ -2028,8 +2024,7 @@ def description(self):
2028
2024
return desc
2029
2025
2030
2026
def validate_coerce (self , v ):
2031
- if v is None :
2032
- # Pass None through
2027
+ if is_none_or_typed_array_spec (v ):
2033
2028
pass
2034
2029
elif self .array_ok and is_homogeneous_array (v ):
2035
2030
v = copy_to_readonly_numpy_array (v , kind = "O" )
@@ -2237,8 +2232,7 @@ def validate_element_with_indexed_name(self, val, validator, inds):
2237
2232
return val
2238
2233
2239
2234
def validate_coerce (self , v ):
2240
- if v is None :
2241
- # Pass None through
2235
+ if is_none_or_typed_array_spec (v ):
2242
2236
return None
2243
2237
elif not is_array (v ):
2244
2238
self .raise_invalid_val (v )
@@ -2301,7 +2295,7 @@ def validate_coerce(self, v):
2301
2295
return v
2302
2296
2303
2297
def present (self , v ):
2304
- if v is None :
2298
+ if is_none_or_typed_array_spec ( v ) :
2305
2299
return None
2306
2300
else :
2307
2301
if (
0 commit comments