custom.py 文件源码

python
阅读 30 收藏 0 点赞 0 评论 0

项目:xarray-simlab 作者: benbovy 项目源码 文件源码
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))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号