Skip to content

Commit fdcad3d

Browse files
committed
Found edge case in numpy subclassing.
1 parent 49184c3 commit fdcad3d

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

montepy/_check_value.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,17 @@ def check_np_type(e_type):
292292
except TypeError as e:
293293
raise_iter_err(e)
294294
else:
295-
if not issubclass(value.dtype.type, e_type):
295+
if isinstance(e_type, type):
296+
e_types = [e_type]
297+
else:
298+
buff = typing.get_args(e_type)
299+
e_types = []
300+
for typ in buff:
301+
if isinstance(typ, type):
302+
e_types.append(typ)
303+
else:
304+
e_types.append(typing.get_args(typ)[0])
305+
if not any((issubclass(dtype, typ) for typ in e_types)):
296306
raise_iter_err()
297307

298308
if isinstance(value, np.ndarray):

0 commit comments

Comments
 (0)