/
ak_is_valid.py
35 lines (24 loc) · 965 Bytes
/
ak_is_valid.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE
from __future__ import annotations
import awkward as ak
from awkward._dispatch import high_level_function
__all__ = ("is_valid",)
@high_level_function()
def is_valid(array, *, exception=False):
"""
Args:
array: Array-like data (anything #ak.to_layout recognizes).
exception (bool): If True, validity errors raise exceptions.
Returns True if there are no errors and False if there is an error.
Checks for errors in the structure of the array, such as indexes that run
beyond the length of a node's `content`, etc. Either an error is raised or
the function returns a boolean.
See also #ak.validity_error.
"""
# Dispatch
yield (array,)
# Implementation
return _impl(array, exception)
def _impl(array, exception):
out = ak.operations.validity_error(array, exception=exception)
return out in (None, "")