Skip to content

checks module

Utilities for validation during runtime.


assert_array_equal function

assert_array_equal(
    arg1,
    arg2
)

Raise exception if the first argument and the second argument have different metadata or values.


assert_columns_equal function

assert_columns_equal(
    arg1,
    arg2,
    check_names=True
)

Raise exception if the first argument and the second argument have different columns.


assert_dict_sequence_valid function

assert_dict_sequence_valid(
    arg,
    lvl_keys
)

Raise exception if a dict or any dict in a sequence of dicts has keys that are not in lvl_keys.


assert_dict_valid function

assert_dict_valid(
    arg,
    lvl_keys
)

Raise exception if dict the argument has keys that are not in lvl_keys.

lvl_keys must be a list of lists, each corresponding to a level in the dict.


assert_dtype function

assert_dtype(
    arg,
    dtype,
    arg_name=None
)

Raise exception if the argument is not of data type dtype.


assert_dtype_equal function

assert_dtype_equal(
    arg1,
    arg2
)

Raise exception if the first argument and the second argument have different data types.


assert_equal function

assert_equal(
    arg1,
    arg2,
    deep=False
)

Raise exception if the first argument and the second argument are different.


assert_in function

assert_in(
    arg1,
    arg2,
    arg_name=None
)

Raise exception if the first argument is not in the second argument.


assert_index_equal function

assert_index_equal(
    arg1,
    arg2,
    check_names=True
)

Raise exception if the first argument and the second argument have different index.


assert_instance_of function

assert_instance_of(
    arg,
    types,
    arg_name=None
)

Raise exception if the argument is none of types types.


assert_iterable function

assert_iterable(
    arg
)

Raise exception if the argument is not an iterable.


assert_len_equal function

assert_len_equal(
    arg1,
    arg2
)

Raise exception if the first argument and the second argument have different length.

Does not transform arguments to NumPy arrays.


assert_level_not_exists function

assert_level_not_exists(
    arg,
    level_name
)

Raise exception if index the argument has level level_name.


assert_meta_equal function

assert_meta_equal(
    arg1,
    arg2,
    axis=None
)

Raise exception if the first argument and the second argument have different metadata.


assert_ndim function

assert_ndim(
    arg,
    ndims
)

Raise exception if the argument has a different number of dimensions than ndims.


assert_not_instance_of function

assert_not_instance_of(
    arg,
    types,
    arg_name=None
)

Raise exception if the argument is one of types types.


assert_not_none function

assert_not_none(
    arg,
    arg_name=None
)

Raise exception if the argument is None.


assert_not_subclass_of function

assert_not_subclass_of(
    arg,
    classes,
    arg_name=None
)

Raise exception if the argument is a subclass of classes classes.


assert_numba_func function

assert_numba_func(
    func
)

Raise exception if func is not Numba-compiled.


assert_sequence function

assert_sequence(
    arg
)

Raise exception if the argument is not a sequence.


assert_shape_equal function

assert_shape_equal(
    arg1,
    arg2,
    axis=None
)

Raise exception if the first argument and the second argument have different shapes along axis.


assert_subclass_of function

assert_subclass_of(
    arg,
    classes,
    arg_name=None
)

Raise exception if the argument is not a subclass of classes classes.


assert_subdtype function

assert_subdtype(
    arg,
    dtype,
    arg_name=None
)

Raise exception if the argument is not a sub data type of dtype.


assert_type_equal function

assert_type_equal(
    arg1,
    arg2
)

Raise exception if the first argument and the second argument have different types.


iskeyword function

frozenset.__contains__(
    ...
)

x.contains(y) <==> y in x.


func_accepts_arg function

func_accepts_arg(
    func,
    arg_name,
    arg_kind=None
)

Check whether func accepts a positional or keyword argument with name arg_name.


is_any_array function

is_any_array(
    arg
)

Check whether the argument is a NumPy array or a Pandas object.


is_bool function

is_bool(
    arg
)

Check whether the argument is a bool.


is_class function

is_class(
    arg,
    types
)

Check whether the argument is types.

types can be one or multiple types, strings, or patterns of type Regex.


is_complex_iterable function

is_complex_iterable(
    arg
)

Check whether the argument is iterable but not a string or bytes object.


is_complex_sequence function

is_complex_sequence(
    arg
)

Check whether the argument is a sequence but not a string or bytes object.


is_deep_equal function

is_deep_equal(
    arg1,
    arg2,
    check_exact=False,
    debug=False,
    only_types=False,
    **kwargs
)

Check whether two objects are equal (deep check).


is_default_index function

is_default_index(
    arg,
    check_names=True
)

Check whether index is a basic range.


is_dt function

is_dt(
    arg
)

Check whether the argument is a datetime object.


is_dt_like function

is_dt_like(
    arg
)

Check whether the argument is a datetime-like object.


is_equal function

is_equal(
    arg1,
    arg2,
    equality_func=<function <lambda>>
)

Check whether two objects are equal.


is_float function

is_float(
    arg
)

Check whether the argument is a float.


is_frame function

is_frame(
    arg
)

Check whether the argument is pd.DataFrame.


is_frequency function

is_frequency(
    arg
)

Check whether the argument is a frequency object.


is_frequency_like function

is_frequency_like(
    arg
)

Check whether the argument is a frequency-like object.


is_hashable function

is_hashable(
    arg
)

Check whether the argument can be hashed.


is_index function

is_index(
    arg
)

Check whether the argument is pd.Index.


is_index_equal function

is_index_equal(
    arg1,
    arg2,
    check_names=True
)

Check whether indexes are equal.

If check_names is True, checks whether names are equal on top of pd.Index.equals.


is_instance_of function

is_instance_of(
    arg,
    types
)

Check whether the argument is an instance of types.

types can be one or multiple types or strings.


is_int function

is_int(
    arg
)

Check whether the argument is an integer (and not a timedelta, for example).


is_iterable function

is_iterable(
    arg
)

Check whether the argument is iterable.


is_mapping function

is_mapping(
    arg
)

Check whether the arguments is a mapping.


is_mapping_like function

is_mapping_like(
    arg
)

Check whether the arguments is a mapping-like object.


is_multi_index function

is_multi_index(
    arg
)

Check whether the argument is pd.MultiIndex.


is_namedtuple function

is_namedtuple(
    arg
)

Check whether object is an instance of namedtuple.


is_notebook function

is_notebook()

Check whether the code runs in a notebook.

Credit: https://stackoverflow.com/a/39662359


is_np_array function

is_np_array(
    arg
)

Check whether the argument is a NumPy array.


is_np_scalar function

is_np_scalar(
    arg
)

Check whether the argument is a NumPy scalar.


is_numba_enabled function

is_numba_enabled()

Check whether Numba is enabled globally.


is_numba_func function

is_numba_func(
    arg
)

Check whether the argument is a Numba-compiled function.


is_number function

is_number(
    arg
)

Check whether the argument is a number.


is_pandas function

is_pandas(
    arg
)

Check whether the argument is pd.Series, pd.Index, or pd.DataFrame.


is_record function

is_record(
    arg
)

Check whether object is a NumPy record.


is_record_array function

is_record_array(
    arg
)

Check whether the argument is a structured NumPy array.


is_sequence function

is_sequence(
    arg
)

Check whether the argument is a sequence.


is_series function

is_series(
    arg
)

Check whether the argument is pd.Series.


is_subclass_of function

is_subclass_of(
    arg,
    types
)

Check whether the argument is a subclass of types.

types can be one or multiple types, strings, or patterns of type Regex.


is_td function

is_td(
    arg
)

Check whether the argument is a timedelta object.


is_td_like function

is_td_like(
    arg
)

Check whether the argument is a timedelta-like object.


is_time function

is_time(
    arg
)

Check whether the argument is a time object.


is_time_like function

is_time_like(
    arg
)

Check whether the argument is a time-like object.


is_valid_variable_name function

is_valid_variable_name(
    arg
)

Check whether the argument is a valid variable name.


safe_assert function

safe_assert(
    arg,
    msg=None
)

Comparable class

Comparable()

Class representing an object that can be compared to another object.

Subclasses


equals method

Comparable.equals(
    other,
    *args,
    **kwargs
)

Check two objects for (deep) equality.

Should accept the keyword arguments accepted by is_deep_equal().