The checks.py
module#
Summary#
Make sure that the design is active before executing a method. |
|
Check if a parameter has a float or integer value. |
|
Check if a |
|
Check if a |
|
Check if a |
|
Check if a |
|
Check if input |
|
Check if an input object is of the same class as an expected object. |
|
Check if an input object is of the same type as expected types. |
|
Check if all elements in an iterable are of the same type as expected. |
|
Compare a minimum required version to the current backend version. |
|
Decorate a method as deprecated. |
|
Decorate a method argument as deprecated. |
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: str | None = None) None #
Check if a parameter has a float or integer value.
- checks.check_ndarray_is_float_int(param: numpy.ndarray, param_name: str | None = None) None #
Check if a
numpy.ndarray
has float/integer types.- Parameters:
- param
ndarray
numpy.ndarray
instance to check.- param_name
str
, default:None
numpy.ndarray
instance name (if any).
- param
- 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: str | None = None) None #
Check if a
numpy.ndarray
is allNone
.- Parameters:
- param
ndarray
numpy.ndarray
instance to check.- param_name
str
, default:None
numpy.ndarray
instance name (if any).
- param
- Raises:
ValueError
If the
numpy.ndarray
instance has a value ofNone
for all parameters.
- checks.check_ndarray_is_all_nan(param: numpy.ndarray, param_name: str | None = None) None #
Check if a
numpy.ndarray
is all nan-valued.- Parameters:
- param
ndarray
numpy.ndarray
instance to check.- param_name
str
orNone
, default:None
numpy.ndarray
instance name (if any).
- param
- Raises:
ValueError
If the
numpy.ndarray
instance is all nan-valued.
- checks.check_ndarray_is_non_zero(param: numpy.ndarray, param_name: str | None = None) None #
Check if a
numpy.ndarray
is zero-valued.- Parameters:
- param
ndarray
numpy.ndarray
instance to check.- param_name
str
, default:None
numpy.ndarray
instance name (if any).
- param
- 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
pint.Unit
is compatible with the expected input.
- checks.check_type_equivalence(input: object, expected: object) None #
Check if an input object is of the same class as an expected object.
- checks.check_type(input: object, expected_type: type | tuple[type, Ellipsis]) None #
Check if an input object is of the same type as expected types.
- checks.check_type_all_elements_in_iterable(input: collections.abc.Iterable, expected_type: type | tuple[type, Ellipsis]) None #
Check if all elements in an iterable are of the same type as expected.
- checks.min_backend_version(major: int, minor: int, service_pack: int)#
Compare a minimum required version to the current backend version.
- Parameters:
- Raises:
GeometryRuntimeError
If the method version is higher than the backend version.
GeometryRuntimeError
If the client is not available.
- checks.deprecated_method(alternative: str | None = None, info: str | None = None)#
Decorate a method as deprecated.