CADETProcess.dataStructure.parameter.DimensionalizedArray#
- class CADETProcess.dataStructure.parameter.DimensionalizedArray(n_dim: int | None = None, *args: Any, **kwargs: Any)[source]#
Bases:
NdArrayParameter descriptor constrained to np.arrays with a specific dimensionality.
The descriptor ensures that the ndarray assigned matches the specified number of dimensions (n_dim).
- Attributes:
- n_dimint
The number of dimensions the array must have.
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
- n_dim = None#