def dtype_validator(variable, expected_dtypes):
if not isinstance(expected_dtypes, (list, tuple)):
expected_dtypes = [expected_dtypes]
test_dtype = any([np.issubdtype(variable.dtype, dtype)
for dtype in expected_dtypes])
if not test_dtype:
raise ValidationError(
"invalid dtype, expected one between %s, found %r)"
% ([np.dtype(dtype) for dtype in expected_dtypes], variable.dtype))
评论列表
文章目录