CADETProcess.dataStructure.parameter.DimensionalizedArray#
- class CADETProcess.dataStructure.parameter.DimensionalizedArray(n_dim=None, *args, **kwargs)[source]#
Parameter descriptor constrained to np.arrays with a specific dimensionality.
The descriptor ensures that the ndarray assigned matches the specified number of dimensions (n_dim).
Notes
The n_dim attribute can be set during initialization.
Examples
To create a descriptor for 2-dimensional arrays:
>>> class MyClass: ... arr = DimensionalizedArray(n_dim=2) ... >>> obj = MyClass() >>> obj.arr = np.array([[1, 2], [3, 4]]) # This is valid >>> obj.arr = np.array([1, 2, 3, 4]) # Raises a ValueError
- Attributes:
- n_dimint
The number of dimensions the array must have.
Methods
cast_value
(value)Cast lists or scalars (int or float) to numpy arrays.
get_default_value
(instance)Return default values if necessary.
ty
alias of
ndarray