The checks.py module#

Summary#

ensure_design_is_active

Make sure that the design is active before executing a method.

check_is_float_int

Check if a parameter has a float or integer value.

check_ndarray_is_float_int

Check if a numpy.ndarray has float or integer values.

check_ndarray_is_not_none

Check if a numpy.ndarray has all None values.

check_ndarray_is_all_nan

Check if a numpy.ndarray is all nan-valued.

check_ndarray_is_non_zero

Check if a numpy.ndarray is zero-valued.

check_pint_unit_compatibility

Check if input for pint.Unit is compatible with the expected input.

check_type_equivalence

Check if an input object is of the same class as an expected object.

check_type

Check if an input object is of the same type as expected types.

check_type_all_elements_in_iterable

Check if all elements in an iterable are of the same type as expected types.

min_backend_version

Compare a method’s minimum required version to the current backend version.

Description#

Provides functions for performing common checks.

Module detail#

checks.ensure_design_is_active(method)#

Make sure that the design is active before executing a method.

This function is necessary to be called whenever we do any operation on the design. If we are just accessing information of the class, it is not necessary to call this.

checks.check_is_float_int(param: object, param_name: beartype.typing.Optional[beartype.typing.Union[str, None]] = None) None#

Check if a parameter has a float or integer value.

Parameters:
paramobject

Object instance to check.

param_namestr, default: None

Parameter name (if any).

Raises:
TypeError

If the parameter does not have a float or integer value.

checks.check_ndarray_is_float_int(param: numpy.ndarray, param_name: beartype.typing.Optional[beartype.typing.Union[str, None]] = None) None#

Check if a numpy.ndarray has float or integer values.

Parameters:
paramndarray

numpy.ndarray instance to check.

param_namestr, default: None

numpy.ndarray instance name (if any).

Raises:
TypeError

If the numpy.ndarray instance does not have float or integer values.

checks.check_ndarray_is_not_none(param: numpy.ndarray, param_name: beartype.typing.Optional[beartype.typing.Union[str, None]] = None) None#

Check if a numpy.ndarray has all None values.

Parameters:
paramndarray

numpy.ndarray instance to check.

param_namestr, default: None

numpy.ndarray instance name (if any).

Raises:
ValueError

If the numpy.ndarray instance has a value of None for all parameters.

checks.check_ndarray_is_all_nan(param: numpy.ndarray, param_name: beartype.typing.Optional[beartype.typing.Union[str, None]] = None) None#

Check if a numpy.ndarray is all nan-valued.

Parameters:
paramndarray

numpy.ndarray instance to check.

param_namestr or None, default: None

numpy.ndarray instance name (if any).

Raises:
ValueError

If the numpy.ndarray instance is all nan-valued.

checks.check_ndarray_is_non_zero(param: numpy.ndarray, param_name: beartype.typing.Optional[beartype.typing.Union[str, None]] = None) None#

Check if a numpy.ndarray is zero-valued.

Parameters:
paramndarray

numpy.ndarray instance to check.

param_namestr, default: None

numpy.ndarray instance name (if any).

Raises:
ValueError

If the numpy.ndarray instance is zero-valued.

checks.check_pint_unit_compatibility(input: pint.Unit, expected: pint.Unit) None#

Check if input for pint.Unit is compatible with the expected input.

Parameters:
inputUnit

pint.Unit input.

expectedUnit

pint.Unit expected dimensionality.

Raises:
TypeError

If the input is not compatible with the pint.Unit class.

checks.check_type_equivalence(input: object, expected: object) None#

Check if an input object is of the same class as an expected object.

Parameters:
inputobject

Input object.

expectedobject

Expected object.

Raises:
TypeError

If the objects are not of the same class.

checks.check_type(input: object, expected_type: beartype.typing.Union[type, beartype.typing.Tuple[type, beartype.typing.Any]]) None#

Check if an input object is of the same type as expected types.

Parameters:
inputobject

Input object.

expected_typeUnion[type, Tuple[type, …]]

One or more types to compare the input object against.

Raises:
TypeError

If the object does not match the one or more expected types.

checks.check_type_all_elements_in_iterable(input: beartype.typing.Iterable, expected_type: beartype.typing.Union[type, beartype.typing.Tuple[type, beartype.typing.Any]]) None#

Check if all elements in an iterable are of the same type as expected types.

Parameters:
inputIterable

Input iterable.

expected_typeUnion[type, Tuple[type, …]]

One or more types to compare the input object against.

Raises:
TypeError

If one of the elements in the iterable does not match the one or more expected types.

checks.min_backend_version(major: int, minor: int, service_pack: int)#

Compare a method’s minimum required version to the current backend version.

Parameters:
majorint

Minimum major version required by the method.

minorint

Minimum minor version required by the method.

service_packint

Minimum service pack version required by the method.

Raises:
GeometryRuntimeError

If the method version is higher than the backend version.

GeometryRuntimeError

If the client is not available.