utils¶
- exception OutOfInterval¶
Bases:
ExceptionAn error raised when a value is outside of an acceptable timestamp interval.
- get_interval_slice(timestamps, start, stop)¶
Gets a slice object representing the indices of timestamps within a specified interval.
- greatest_common_denominator(values, return_inverse=True)¶
Finds the greatest common denominator (GCD) of a list of numbers and optionally returns its inverse.
- validate_keys(keys, keys_reference, allow_missing)¶
Validates that a set of keys conforms to a reference set, optionally allowing missing keys.
- Parameters:
- Return type:
- Returns:
If the keys pass validation.
- Raises:
KeyError – If any keys are undefined or if missing keys are not allowed.
- validate_timestamps(timestamps)¶
Validates that a sequence of timestamps contains no duplicates. Always returns
Trueif the timestamps are valid, otherwise raises aValueError.- Parameters:
timestamps (
ndarray|int|float|str|integer|floating) – The timestamps to validate.- Return type:
- Returns:
If the timestamps are valid.
- Raises:
ValueError – If timestamps is a scalar.
ValueError – If any timestamps are duplicated.
- validated_length(*values)¶
Returns the length of all iterable values if they are all the same length. Returns
Noneif all values are scalars.- Parameters:
*values (
ndarray|int|float|str|integer|floating) – An iterable of values to check the length of.- Return type:
- Returns:
The length of all iterable values if they are all the same length. Returns
Noneif all values are scalars.- Raises:
ValueError – If the values have unequal lengths or contain unsized iterables objects.
- writeable(*arrays)¶
A context manager that temporarily makes numpy arrays writeable.
This context manager is useful when you need to modify the contents of a read-only array within a specific block of code. It ensures that the writeable flag is restored to its original state after the block, even if exceptions occur.