VeraGridEngine.Devices.Profiles packageο
Submodulesο
VeraGridEngine.Devices.Profiles.profile_bool moduleο
- class VeraGridEngine.Devices.Profiles.profile_bool.ProfileBool(default_value: bool, arr: ndarray | None = None, sparsity_threshold: float = 0.8, is_sparse: bool = False)[source]ο
Bases:
objectProfile specialized for
boolvalues.- astype(tpe: Any) ndarray[source]ο
Cast the dense representation to another dtype.
- Parameters:
tpe β Target dtype.
- Returns:
Cast dense array.
- convert_sparse_to_dense() None[source]ο
Convert the sparse profile into dense storage.
- Returns:
None.
- copy() ProfileBool[source]ο
Build a deep copy of the profile.
- Returns:
New profile copy.
- create_dense(size: int, default_value: bool) None[source]ο
Create the profile in dense form.
- Parameters:
size β Logical size.
default_value β Dense fill value.
- Returns:
None.
- create_sparse(size: int, default_value: bool, map_data: dict[int, bool] | None = None) None[source]ο
Create the profile in sparse form.
- Parameters:
size β Logical size.
default_value β Sparse default value.
map_data β Optional sparse map.
- Returns:
None.
- property default_value: boolο
Get the profile default value.
- Returns:
Default value.
- property dense_array: ndarray | Noneο
Get the dense backing array.
- Returns:
Dense array or
None.
- property dtype: type[bool]ο
Get the declared type.
- Returns:
bool.
- fill(value: bool) None[source]ο
Fill the profile with a single value.
- Parameters:
value β Fill value.
- Returns:
None.
- fix_nan(default_value: float = 0.0) None[source]ο
Keep the boolean profile API aligned with the generic profile.
- Parameters:
default_value β Unused placeholder.
- Returns:
None.
- get_sparse_map() dict[int, bool][source]ο
Get the sparse map when the profile is sparse.
- Returns:
Sparse map or an empty dictionary.
- get_sparse_representation() tuple[list[int], list[bool]][source]ο
Export the sparse contents as parallel index and value lists.
- Returns:
Tuple
(indices, values).
- property is_initialized: boolο
Get whether the profile has been initialized.
- Returns:
Initialization state.
- property is_sparse: boolο
Get whether the profile uses sparse storage.
- Returns:
Sparse state.
- resample(indices: ndarray[tuple[Any, ...], dtype[int64]]) None[source]ο
Resample the profile in place.
- Parameters:
indices β New index selection.
- Returns:
None.
- resize(n: int) None[source]ο
Resize the profile.
- Parameters:
n β New logical size.
- Returns:
None.
- scale(value: float | int) None[source]ο
Reject scaling because boolean profiles are not numeric.
- Parameters:
value β Scalar multiplier.
- Returns:
None.
- set(arr: ndarray) bool[source]ο
Set the profile from a dense array.
- Parameters:
arr β Dense boolean array.
- Returns:
Truewhen the assignment succeeds.
- set_sparse_data_from_data(indptr: list[int], data: list[bool]) None[source]ο
Load sparse data from parallel lists.
- Parameters:
indptr β Sparse indices.
data β Sparse values.
- Returns:
None.
- property sparse_array: SparseArrayBool | Noneο
Get the sparse backing array.
- Returns:
Sparse array or
None.
- property sparsity: floatο
Get the sparse stored-entry ratio.
- Returns:
Sparsity ratio.
VeraGridEngine.Devices.Profiles.profile_device moduleο
- class VeraGridEngine.Devices.Profiles.profile_device.ProfileDevice(default_value: EditableDevice | str | None, device_type: DeviceType, arr: np.ndarray | None = None, sparsity_threshold: float = 0.8, is_sparse: bool = False)[source]ο
Bases:
objectProfile specialized for editable-device references.
- astype(tpe: Any) ndarray[source]ο
Cast the dense representation to another dtype.
- Parameters:
tpe β Target dtype.
- Returns:
Cast dense array.
- convert_sparse_to_dense() None[source]ο
Convert the sparse profile into dense storage.
- Returns:
None.
- copy() ProfileDevice[source]ο
Build a deep copy of the profile.
- Returns:
New profile copy.
- create_dense(size: int, default_value: EditableDevice | str | None) None[source]ο
Create the profile in dense form.
- Parameters:
size β Logical size.
default_value β Dense fill value.
- Returns:
None.
- create_sparse(size: int, default_value: EditableDevice | str | None, map_data: dict[int, 'EditableDevice | str | None'] | None = None) None[source]ο
Create the profile in sparse form.
- Parameters:
size β Logical size.
default_value β Sparse default value.
map_data β Optional sparse map.
- Returns:
None.
- property default_value: EditableDevice | str | Noneο
Get the profile default value.
- Returns:
Default value.
- property dense_array: ndarray | Noneο
Get the dense backing array.
- Returns:
Dense array or
None.
- property dtype: DeviceTypeο
Get the declared selector type.
- Returns:
Device selector.
- fill(value: EditableDevice | str | None) None[source]ο
Fill the profile with a single value.
- Parameters:
value β Fill value.
- Returns:
None.
- fix_nan(default_value: float = 0.0) None[source]ο
Keep the device profile API aligned with the generic profile.
- Parameters:
default_value β Unused placeholder.
- Returns:
None.
- get_sparse_map() dict[int, 'EditableDevice | str | None'][source]ο
Get the sparse map when the profile is sparse.
- Returns:
Sparse map or an empty dictionary.
- get_sparse_representation() tuple[list[int], list['EditableDevice | str | None']][source]ο
Export the sparse contents as parallel index and value lists.
- Returns:
Tuple
(indices, values).
- property is_initialized: boolο
Get whether the profile has been initialized.
- Returns:
Initialization state.
- property is_sparse: boolο
Get whether the profile uses sparse storage.
- Returns:
Sparse state.
- rebind_device_references(objects_by_idtag: dict[str, 'EditableDevice']) None[source]ο
Rebind stored device references to equivalent objects from a target lookup.
- Parameters:
objects_by_idtag β idtag -> target object lookup.
- resample(indices: ndarray[tuple[Any, ...], dtype[int64]]) None[source]ο
Resample the profile in place.
- Parameters:
indices β New index selection.
- Returns:
None.
- resize(n: int) None[source]ο
Resize the profile.
- Parameters:
n β New logical size.
- Returns:
None.
- scale(value: float | int) None[source]ο
Reject scaling because device profiles are not numeric.
- Parameters:
value β Scalar multiplier.
- Returns:
None.
- set(arr: ndarray) bool[source]ο
Set the profile from a dense array.
- Parameters:
arr β Dense device-reference array.
- Returns:
Truewhen the assignment succeeds.
- set_sparse_data_from_data(indptr: list[int], data: list['EditableDevice | str | None']) None[source]ο
Load sparse data from parallel lists.
- Parameters:
indptr β Sparse indices.
data β Sparse values.
- Returns:
None.
- property sparse_array: SparseArrayDevice | Noneο
Get the sparse backing array.
- Returns:
Sparse array or
None.
- property sparsity: floatο
Get the sparse stored-entry ratio.
- Returns:
Sparsity ratio.
VeraGridEngine.Devices.Profiles.profile_enum moduleο
- class VeraGridEngine.Devices.Profiles.profile_enum.ProfileEnum(default_value: Enum | None, enum_type: type[Enum], arr: ndarray | None = None, sparsity_threshold: float = 0.8, is_sparse: bool = False)[source]ο
Bases:
objectProfile specialized for enum values.
- astype(tpe: Any) ndarray[source]ο
Cast the dense representation to another dtype.
- Parameters:
tpe β Target dtype.
- Returns:
Cast dense array.
- convert_sparse_to_dense() None[source]ο
Convert the sparse profile into dense storage.
- Returns:
None.
- copy() ProfileEnum[source]ο
Build a deep copy of the profile.
- Returns:
New profile copy.
- create_dense(size: int, default_value: Enum | None) None[source]ο
Create the profile in dense form.
- Parameters:
size β Logical size.
default_value β Dense fill value.
- Returns:
None.
- create_sparse(size: int, default_value: Enum | None, map_data: dict[int, Enum | None] | None = None) None[source]ο
Create the profile in sparse form.
- Parameters:
size β Logical size.
default_value β Sparse default value.
map_data β Optional sparse map.
- Returns:
None.
- property default_value: Enum | Noneο
Get the profile default value.
- Returns:
Default value.
- property dense_array: ndarray | Noneο
Get the dense backing array.
- Returns:
Dense array or
None.
- property dtype: type[Enum]ο
Get the declared enum type.
- Returns:
Enum class.
- fill(value: Enum | None) None[source]ο
Fill the profile with a single value.
- Parameters:
value β Fill value.
- Returns:
None.
- fix_nan(default_value: float = 0.0) None[source]ο
Keep the enum profile API aligned with the generic profile.
- Parameters:
default_value β Unused placeholder.
- Returns:
None.
- get_sparse_map() dict[int, Enum | None][source]ο
Get the sparse map when the profile is sparse.
- Returns:
Sparse map or an empty dictionary.
- get_sparse_representation() tuple[list[int], list[Enum | None]][source]ο
Export the sparse contents as parallel index and value lists.
- Returns:
Tuple
(indices, values).
- property is_initialized: boolο
Get whether the profile has been initialized.
- Returns:
Initialization state.
- property is_sparse: boolο
Get whether the profile uses sparse storage.
- Returns:
Sparse state.
- resample(indices: ndarray[tuple[Any, ...], dtype[int64]]) None[source]ο
Resample the profile in place.
- Parameters:
indices β New index selection.
- Returns:
None.
- resize(n: int) None[source]ο
Resize the profile.
- Parameters:
n β New logical size.
- Returns:
None.
- scale(value: float | int) None[source]ο
Reject scaling because enum profiles are not numeric.
- Parameters:
value β Scalar multiplier.
- Returns:
None.
- set(arr: ndarray) bool[source]ο
Set the profile from a dense array.
- Parameters:
arr β Dense enum array.
- Returns:
Truewhen the assignment succeeds.
- set_sparse_data_from_data(indptr: list[int], data: list[Enum | None]) None[source]ο
Load sparse data from parallel lists.
- Parameters:
indptr β Sparse indices.
data β Sparse values.
- Returns:
None.
- property sparse_array: SparseArrayEnum | Noneο
Get the sparse backing array.
- Returns:
Sparse array or
None.
- property sparsity: floatο
Get the sparse stored-entry ratio.
- Returns:
Sparsity ratio.
VeraGridEngine.Devices.Profiles.profile_float moduleο
- class VeraGridEngine.Devices.Profiles.profile_float.ProfileFloat(default_value: float, arr: ndarray | None = None, sparsity_threshold: float = 0.8, is_sparse: bool = False)[source]ο
Bases:
objectProfile specialized for
floatvalues.- astype(tpe: Any) ndarray[source]ο
Cast the dense representation to another dtype.
- Parameters:
tpe β Target dtype.
- Returns:
Cast dense array.
- convert_sparse_to_dense() None[source]ο
Convert the sparse profile into dense storage.
- Returns:
None.
- copy() ProfileFloat[source]ο
Build a deep copy of the profile.
- Returns:
New profile copy.
- create_dense(size: int, default_value: float) None[source]ο
Create the profile in dense form.
- Parameters:
size β Logical size.
default_value β Dense fill value.
- Returns:
None.
- create_sparse(size: int, default_value: float, map_data: dict[int, float] | None = None) None[source]ο
Create the profile in sparse form.
- Parameters:
size β Logical size.
default_value β Sparse default value.
map_data β Optional sparse map.
- Returns:
None.
- property default_value: floatο
Get the profile default value.
- Returns:
Default value.
- property dense_array: ndarray | Noneο
Get the dense backing array.
- Returns:
Dense array or
None.
- property dtype: type[float]ο
Get the declared type.
- Returns:
float.
- fill(value: float) None[source]ο
Fill the profile with a single value.
- Parameters:
value β Fill value.
- Returns:
None.
- fix_nan(default_value: float = 0.0) None[source]ο
Replace
NaNvalues in place.- Parameters:
default_value β Replacement value.
- Returns:
None.
- get_sparse_map() dict[int, float][source]ο
Get the sparse map when the profile is sparse.
- Returns:
Sparse map or an empty dictionary.
- get_sparse_representation() tuple[list[int], list[float]][source]ο
Export the sparse contents as parallel index and value lists.
- Returns:
Tuple
(indices, values).
- property is_initialized: boolο
Get whether the profile has been initialized.
- Returns:
Initialization state.
- property is_sparse: boolο
Get whether the profile uses sparse storage.
- Returns:
Sparse state.
- resample(indices: ndarray[tuple[Any, ...], dtype[int64]]) None[source]ο
Resample the profile in place.
- Parameters:
indices β New index selection.
- Returns:
None.
- resize(n: int) None[source]ο
Resize the profile.
- Parameters:
n β New logical size.
- Returns:
None.
- scale(value: float | int) None[source]ο
Scale the profile by a scalar.
- Parameters:
value β Scalar multiplier.
- Returns:
None.
- set(arr: ndarray) bool[source]ο
Set the profile from a dense array.
- Parameters:
arr β Dense float array.
- Returns:
Truewhen the assignment succeeds.
- set_sparse_data_from_data(indptr: list[int], data: list[float]) None[source]ο
Load sparse data from parallel lists.
- Parameters:
indptr β Sparse indices.
data β Sparse values.
- Returns:
None.
- property sparse_array: SparseArrayFloat | Noneο
Get the sparse backing array.
- Returns:
Sparse array or
None.
- property sparsity: floatο
Get the sparse stored-entry ratio.
- Returns:
Sparsity ratio.
VeraGridEngine.Devices.Profiles.profile_int moduleο
- class VeraGridEngine.Devices.Profiles.profile_int.ProfileInt(default_value: int, arr: ndarray | None = None, sparsity_threshold: float = 0.8, is_sparse: bool = False)[source]ο
Bases:
objectProfile specialized for
intvalues.- astype(tpe: Any) ndarray[source]ο
Cast the dense representation to another dtype.
- Parameters:
tpe β Target dtype.
- Returns:
Cast dense array.
- convert_sparse_to_dense() None[source]ο
Convert the sparse profile into dense storage.
- Returns:
None.
- copy() ProfileInt[source]ο
Build a deep copy of the profile.
- Returns:
New profile copy.
- create_dense(size: int, default_value: int) None[source]ο
Create the profile in dense form.
- Parameters:
size β Logical size.
default_value β Dense fill value.
- Returns:
None.
- create_sparse(size: int, default_value: int, map_data: dict[int, int] | None = None) None[source]ο
Create the profile in sparse form.
- Parameters:
size β Logical size.
default_value β Sparse default value.
map_data β Optional sparse map.
- Returns:
None.
- property default_value: intο
Get the profile default value.
- Returns:
Default value.
- property dense_array: ndarray | Noneο
Get the dense backing array.
- Returns:
Dense array or
None.
- property dtype: type[int]ο
Get the declared type.
- Returns:
int.
- fill(value: int) None[source]ο
Fill the profile with a single value.
- Parameters:
value β Fill value.
- Returns:
None.
- fix_nan(default_value: float = 0.0) None[source]ο
Keep the integer profile API aligned with the generic profile.
- Parameters:
default_value β Unused placeholder.
- Returns:
None.
- get_sparse_map() dict[int, int][source]ο
Get the sparse map when the profile is sparse.
- Returns:
Sparse map or an empty dictionary.
- get_sparse_representation() tuple[list[int], list[int]][source]ο
Export the sparse contents as parallel index and value lists.
- Returns:
Tuple
(indices, values).
- property is_initialized: boolο
Get whether the profile has been initialized.
- Returns:
Initialization state.
- property is_sparse: boolο
Get whether the profile uses sparse storage.
- Returns:
Sparse state.
- resample(indices: ndarray[tuple[Any, ...], dtype[int64]]) None[source]ο
Resample the profile in place.
- Parameters:
indices β New index selection.
- Returns:
None.
- resize(n: int) None[source]ο
Resize the profile.
- Parameters:
n β New logical size.
- Returns:
None.
- scale(value: float | int) None[source]ο
Scale the profile by a scalar.
- Parameters:
value β Scalar multiplier.
- Returns:
None.
- set(arr: ndarray) bool[source]ο
Set the profile from a dense array.
- Parameters:
arr β Dense integer array.
- Returns:
Truewhen the assignment succeeds.
- set_sparse_data_from_data(indptr: list[int], data: list[int]) None[source]ο
Load sparse data from parallel lists.
- Parameters:
indptr β Sparse indices.
data β Sparse values.
- Returns:
None.
- property sparse_array: SparseArrayInt | Noneο
Get the sparse backing array.
- Returns:
Sparse array or
None.
- property sparsity: floatο
Get the sparse stored-entry ratio.
- Returns:
Sparsity ratio.
VeraGridEngine.Devices.Profiles.sparse_array_bool moduleο
- class VeraGridEngine.Devices.Profiles.sparse_array_bool.SparseArrayBool(default_value: bool, size: int = 0)[source]ο
Bases:
objectSparse array specialized for
boolvalues.- at(idx: int) bool[source]ο
Get a value at a given position.
- Parameters:
idx β Position to read.
- Returns:
Value at
idx.
- copy() SparseArrayBool[source]ο
Build a deep copy of the sparse array.
- Returns:
New sparse array copy.
- create(size: int, default_value: bool, data: dict[int, bool] | None = None) SparseArrayBool[source]ο
Create the sparse array from explicit sparse data.
- Parameters:
size β Logical size.
default_value β Default sparse value.
data β Sparse map.
- Returns:
self.
- create_from_array(array: ndarray, default_value: bool) SparseArrayBool[source]ο
Create the sparse array from a dense array.
- Parameters:
array β Dense boolean array.
default_value β Default sparse value.
- Returns:
self.
- create_from_dict(default_value: bool, size: int, map_data: dict[int, bool]) SparseArrayBool[source]ο
Create the sparse array from a sparse map.
- Parameters:
default_value β Default sparse value.
size β Logical size.
map_data β Sparse map.
- Returns:
self.
- property default_value: boolο
Get the default sparse value.
- Returns:
Default sparse value.
- property dtype: type[bool]ο
Get the declared type.
- Returns:
bool.
- fill(value: bool) None[source]ο
Fill the logical array with the same value.
- Parameters:
value β Fill value.
- Returns:
None.
- get_sparse_representation() tuple[list[int], list[bool]][source]ο
Export the sparse contents as parallel index and value lists.
- Returns:
Tuple
(indices, values).
- insert(i: int, x: bool) None[source]ο
Insert a sparse value explicitly.
- Parameters:
i β Target index.
x β Value to store.
- Returns:
None.
- resample(indices: ndarray[tuple[Any, ...], dtype[int64]]) None[source]ο
Resample the sparse array in place.
- Parameters:
indices β New index selection.
- Returns:
None.
- resize(n: int) None[source]ο
Resize the sparse array.
- Parameters:
n β New logical size.
- Returns:
None.
- set_data(d: dict[int, bool]) None[source]ο
Replace the sparse map.
- Parameters:
d β New sparse map.
- Returns:
None.
- set_sparse_data_from_data(indptr: list[int], data: list[bool]) None[source]ο
Load sparse data from parallel lists.
- Parameters:
indptr β Sparse indices.
data β Sparse values.
- Returns:
None.
- slice(indices: ndarray[tuple[Any, ...], dtype[int64]]) SparseArrayBool[source]ο
Get a resampled copy.
- Parameters:
indices β New index selection.
- Returns:
Resampled sparse array.
VeraGridEngine.Devices.Profiles.sparse_array_device moduleο
- class VeraGridEngine.Devices.Profiles.sparse_array_device.SparseArrayDevice(default_value: EditableDevice | str | None, device_type: DeviceType, size: int = 0)[source]ο
Bases:
objectSparse array specialized for editable-device references.
- at(idx: int) EditableDevice | str | None[source]ο
Get a value at a given position.
- Parameters:
idx β Position to read.
- Returns:
Value at
idx.
- copy() SparseArrayDevice[source]ο
Build a deep copy of the sparse array.
- Returns:
New sparse array copy.
- create(size: int, default_value: EditableDevice | str | None, data: dict[int, 'EditableDevice | str | None'] | None = None) SparseArrayDevice[source]ο
Create the sparse array from explicit sparse data.
- Parameters:
size β Logical size.
default_value β Default sparse value.
data β Sparse map.
- Returns:
self.
- create_from_array(array: np.ndarray, default_value: EditableDevice | str | None) SparseArrayDevice[source]ο
Create the sparse array from a dense array.
- Parameters:
array β Dense object array.
default_value β Default sparse value.
- Returns:
self.
- create_from_dict(default_value: EditableDevice | str | None, size: int, map_data: dict[int, 'EditableDevice | str | None']) SparseArrayDevice[source]ο
Create the sparse array from a sparse map.
- Parameters:
default_value β Default sparse value.
size β Logical size.
map_data β Sparse map.
- Returns:
self.
- property default_value: EditableDevice | str | Noneο
Get the default sparse value.
- Returns:
Default sparse value.
- property dtype: DeviceTypeο
Get the declared selector type.
- Returns:
Device selector.
- fill(value: EditableDevice | str | None) None[source]ο
Fill the logical array with the same value.
- Parameters:
value β Fill value.
- Returns:
None.
- get_map() dict[int, 'EditableDevice | str | None'][source]ο
Get the sparse map.
- Returns:
Sparse index-value map.
- get_sparse_representation() tuple[list[int], list['EditableDevice | str | None']][source]ο
Export the sparse contents as parallel index and value lists.
- Returns:
Tuple
(indices, values).
- insert(i: int, x: EditableDevice | str | None) None[source]ο
Insert a sparse value explicitly.
- Parameters:
i β Target index.
x β Value to store.
- Returns:
None.
- rebind_device_references(objects_by_idtag: dict[str, 'EditableDevice']) None[source]ο
Rebind stored device references to equivalent objects from a target lookup.
- Parameters:
objects_by_idtag β idtag -> target object lookup.
- resample(indices: ndarray[tuple[Any, ...], dtype[int64]]) None[source]ο
Resample the sparse array in place.
- Parameters:
indices β New index selection.
- Returns:
None.
- resize(n: int) None[source]ο
Resize the sparse array.
- Parameters:
n β New logical size.
- Returns:
None.
- set_data(d: dict[int, 'EditableDevice | str | None']) None[source]ο
Replace the sparse map.
- Parameters:
d β New sparse map.
- Returns:
None.
- set_sparse_data_from_data(indptr: list[int], data: list['EditableDevice | str | None']) None[source]ο
Load sparse data from parallel lists.
- Parameters:
indptr β Sparse indices.
data β Sparse values.
- Returns:
None.
- slice(indices: ndarray[tuple[Any, ...], dtype[int64]]) SparseArrayDevice[source]ο
Get a resampled copy.
- Parameters:
indices β New index selection.
- Returns:
Resampled sparse array.
VeraGridEngine.Devices.Profiles.sparse_array_enum moduleο
- class VeraGridEngine.Devices.Profiles.sparse_array_enum.SparseArrayEnum(default_value: Enum | None, enum_type: type[Enum], size: int = 0)[source]ο
Bases:
objectSparse array specialized for enum values.
- at(idx: int) Enum | None[source]ο
Get a value at a given position.
- Parameters:
idx β Position to read.
- Returns:
Value at
idx.
- copy() SparseArrayEnum[source]ο
Build a deep copy of the sparse array.
- Returns:
New sparse array copy.
- create(size: int, default_value: Enum | None, data: dict[int, Enum | None] | None = None) SparseArrayEnum[source]ο
Create the sparse array from explicit sparse data.
- Parameters:
size β Logical size.
default_value β Default sparse value.
data β Sparse map.
- Returns:
self.
- create_from_array(array: ndarray, default_value: Enum | None) SparseArrayEnum[source]ο
Create the sparse array from a dense array.
- Parameters:
array β Dense object array.
default_value β Default sparse value.
- Returns:
self.
- create_from_dict(default_value: Enum | None, size: int, map_data: dict[int, Enum | None]) SparseArrayEnum[source]ο
Create the sparse array from a sparse map.
- Parameters:
default_value β Default sparse value.
size β Logical size.
map_data β Sparse map.
- Returns:
self.
- property default_value: Enum | Noneο
Get the default sparse value.
- Returns:
Default sparse value.
- property dtype: type[Enum]ο
Get the declared enum type.
- Returns:
Enum class.
- fill(value: Enum | None) None[source]ο
Fill the logical array with the same value.
- Parameters:
value β Fill value.
- Returns:
None.
- get_sparse_representation() tuple[list[int], list[Enum | None]][source]ο
Export the sparse contents as parallel index and value lists.
- Returns:
Tuple
(indices, values).
- insert(i: int, x: Enum | None) None[source]ο
Insert a sparse value explicitly.
- Parameters:
i β Target index.
x β Value to store.
- Returns:
None.
- resample(indices: ndarray[tuple[Any, ...], dtype[int64]]) None[source]ο
Resample the sparse array in place.
- Parameters:
indices β New index selection.
- Returns:
None.
- resize(n: int) None[source]ο
Resize the sparse array.
- Parameters:
n β New logical size.
- Returns:
None.
- set_data(d: dict[int, Enum | None]) None[source]ο
Replace the sparse map.
- Parameters:
d β New sparse map.
- Returns:
None.
- set_sparse_data_from_data(indptr: list[int], data: list[Enum | None]) None[source]ο
Load sparse data from parallel lists.
- Parameters:
indptr β Sparse indices.
data β Sparse values.
- Returns:
None.
- slice(indices: ndarray[tuple[Any, ...], dtype[int64]]) SparseArrayEnum[source]ο
Get a resampled copy.
- Parameters:
indices β New index selection.
- Returns:
Resampled sparse array.
VeraGridEngine.Devices.Profiles.sparse_array_float moduleο
- class VeraGridEngine.Devices.Profiles.sparse_array_float.SparseArrayFloat(default_value: float, size: int = 0)[source]ο
Bases:
objectSparse array specialized for
floatvalues.- at(idx: int) float[source]ο
Get a value at a given position.
- Parameters:
idx β Position to read.
- Returns:
Value at
idx.
- copy() SparseArrayFloat[source]ο
Build a deep copy of the sparse array.
- Returns:
New sparse array copy.
- create(size: int, default_value: float, data: dict[int, float] | None = None) SparseArrayFloat[source]ο
Create the sparse array from explicit sparse data.
- Parameters:
size β Logical size.
default_value β Default sparse value.
data β Sparse map.
- Returns:
self.
- create_from_array(array: ndarray, default_value: float) SparseArrayFloat[source]ο
Create the sparse array from a dense array.
- Parameters:
array β Dense float array.
default_value β Default sparse value.
- Returns:
self.
- create_from_dict(default_value: float, size: int, map_data: dict[int, float]) SparseArrayFloat[source]ο
Create the sparse array from a sparse map.
- Parameters:
default_value β Default sparse value.
size β Logical size.
map_data β Sparse map.
- Returns:
self.
- property default_value: floatο
Get the default sparse value.
- Returns:
Default sparse value.
- property dtype: type[float]ο
Get the declared type.
- Returns:
float.
- fill(value: float) None[source]ο
Fill the logical array with the same value.
- Parameters:
value β Fill value.
- Returns:
None.
- get_sparse_representation() tuple[list[int], list[float]][source]ο
Export the sparse contents as parallel index and value lists.
- Returns:
Tuple
(indices, values).
- insert(i: int, x: float) None[source]ο
Insert a sparse value explicitly.
- Parameters:
i β Target index.
x β Value to store.
- Returns:
None.
- resample(indices: ndarray[tuple[Any, ...], dtype[int64]]) None[source]ο
Resample the sparse array in place.
- Parameters:
indices β New index selection.
- Returns:
None.
- resize(n: int) None[source]ο
Resize the sparse array.
- Parameters:
n β New logical size.
- Returns:
None.
- set_data(d: dict[int, float]) None[source]ο
Replace the sparse map.
- Parameters:
d β New sparse map.
- Returns:
None.
- set_sparse_data_from_data(indptr: list[int], data: list[float]) None[source]ο
Load sparse data from parallel lists.
- Parameters:
indptr β Sparse indices.
data β Sparse values.
- Returns:
None.
- slice(indices: ndarray[tuple[Any, ...], dtype[int64]]) SparseArrayFloat[source]ο
Get a resampled copy.
- Parameters:
indices β New index selection.
- Returns:
Resampled sparse array.
VeraGridEngine.Devices.Profiles.sparse_array_int moduleο
- class VeraGridEngine.Devices.Profiles.sparse_array_int.SparseArrayInt(default_value: int, size: int = 0)[source]ο
Bases:
objectSparse array specialized for
intvalues.- at(idx: int) int[source]ο
Get a value at a given position.
- Parameters:
idx β Position to read.
- Returns:
Value at
idx.
- copy() SparseArrayInt[source]ο
Build a deep copy of the sparse array.
- Returns:
New sparse array copy.
- create(size: int, default_value: int, data: dict[int, int] | None = None) SparseArrayInt[source]ο
Create the sparse array from explicit sparse data.
- Parameters:
size β Logical size.
default_value β Default sparse value.
data β Sparse map.
- Returns:
self.
- create_from_array(array: ndarray, default_value: int) SparseArrayInt[source]ο
Create the sparse array from a dense array.
- Parameters:
array β Dense integer array.
default_value β Default sparse value.
- Returns:
self.
- create_from_dict(default_value: int, size: int, map_data: dict[int, int]) SparseArrayInt[source]ο
Create the sparse array from a sparse map.
- Parameters:
default_value β Default sparse value.
size β Logical size.
map_data β Sparse map.
- Returns:
self.
- property default_value: intο
Get the default sparse value.
- Returns:
Default sparse value.
- property dtype: type[int]ο
Get the declared type.
- Returns:
int.
- fill(value: int) None[source]ο
Fill the logical array with the same value.
- Parameters:
value β Fill value.
- Returns:
None.
- get_sparse_representation() tuple[list[int], list[int]][source]ο
Export the sparse contents as parallel index and value lists.
- Returns:
Tuple
(indices, values).
- insert(i: int, x: int) None[source]ο
Insert a sparse value explicitly.
- Parameters:
i β Target index.
x β Value to store.
- Returns:
None.
- resample(indices: ndarray[tuple[Any, ...], dtype[int64]]) None[source]ο
Resample the sparse array in place.
- Parameters:
indices β New index selection.
- Returns:
None.
- resize(n: int) None[source]ο
Resize the sparse array.
- Parameters:
n β New logical size.
- Returns:
None.
- set_data(d: dict[int, int]) None[source]ο
Replace the sparse map.
- Parameters:
d β New sparse map.
- Returns:
None.
- set_sparse_data_from_data(indptr: list[int], data: list[int]) None[source]ο
Load sparse data from parallel lists.
- Parameters:
indptr β Sparse indices.
data β Sparse values.
- Returns:
None.
- slice(indices: ndarray[tuple[Any, ...], dtype[int64]]) SparseArrayInt[source]ο
Get a resampled copy.
- Parameters:
indices β New index selection.
- Returns:
Resampled sparse array.
VeraGridEngine.Devices.Profiles.type_checks moduleο
- VeraGridEngine.Devices.Profiles.type_checks.check_if_sparse(arr: ndarray, sparsity: float = 0.8) tuple[bool, Any][source]ο
Check whether an array should be stored as sparse.
- Parameters:
arr β Array to inspect.
sparsity β Minimum repetition ratio required for sparse storage.
- Returns:
Tuple
(is_sparse, most_frequent_value).
- VeraGridEngine.Devices.Profiles.type_checks.check_type(dtype: type[bool] | type[int] | type[float] | type[Enum] | DeviceType, value: Any) bool[source]ο
Check that a value is compatible with a declared profile type.
- Parameters:
dtype β Declared profile type.
value β Value to validate.
- Returns:
Truewhenvaluematchesdtype.
Module contentsο
- class VeraGridEngine.Devices.Profiles.ProfileBool(default_value: bool, arr: ndarray | None = None, sparsity_threshold: float = 0.8, is_sparse: bool = False)[source]ο
Bases:
objectProfile specialized for
boolvalues.- astype(tpe: Any) ndarray[source]ο
Cast the dense representation to another dtype.
- Parameters:
tpe β Target dtype.
- Returns:
Cast dense array.
- convert_sparse_to_dense() None[source]ο
Convert the sparse profile into dense storage.
- Returns:
None.
- copy() ProfileBool[source]ο
Build a deep copy of the profile.
- Returns:
New profile copy.
- create_dense(size: int, default_value: bool) None[source]ο
Create the profile in dense form.
- Parameters:
size β Logical size.
default_value β Dense fill value.
- Returns:
None.
- create_sparse(size: int, default_value: bool, map_data: dict[int, bool] | None = None) None[source]ο
Create the profile in sparse form.
- Parameters:
size β Logical size.
default_value β Sparse default value.
map_data β Optional sparse map.
- Returns:
None.
- property default_value: boolο
Get the profile default value.
- Returns:
Default value.
- property dense_array: ndarray | Noneο
Get the dense backing array.
- Returns:
Dense array or
None.
- property dtype: type[bool]ο
Get the declared type.
- Returns:
bool.
- fill(value: bool) None[source]ο
Fill the profile with a single value.
- Parameters:
value β Fill value.
- Returns:
None.
- fix_nan(default_value: float = 0.0) None[source]ο
Keep the boolean profile API aligned with the generic profile.
- Parameters:
default_value β Unused placeholder.
- Returns:
None.
- get_sparse_map() dict[int, bool][source]ο
Get the sparse map when the profile is sparse.
- Returns:
Sparse map or an empty dictionary.
- get_sparse_representation() tuple[list[int], list[bool]][source]ο
Export the sparse contents as parallel index and value lists.
- Returns:
Tuple
(indices, values).
- property is_initialized: boolο
Get whether the profile has been initialized.
- Returns:
Initialization state.
- property is_sparse: boolο
Get whether the profile uses sparse storage.
- Returns:
Sparse state.
- resample(indices: ndarray[tuple[Any, ...], dtype[int64]]) None[source]ο
Resample the profile in place.
- Parameters:
indices β New index selection.
- Returns:
None.
- resize(n: int) None[source]ο
Resize the profile.
- Parameters:
n β New logical size.
- Returns:
None.
- scale(value: float | int) None[source]ο
Reject scaling because boolean profiles are not numeric.
- Parameters:
value β Scalar multiplier.
- Returns:
None.
- set(arr: ndarray) bool[source]ο
Set the profile from a dense array.
- Parameters:
arr β Dense boolean array.
- Returns:
Truewhen the assignment succeeds.
- set_sparse_data_from_data(indptr: list[int], data: list[bool]) None[source]ο
Load sparse data from parallel lists.
- Parameters:
indptr β Sparse indices.
data β Sparse values.
- Returns:
None.
- property sparse_array: SparseArrayBool | Noneο
Get the sparse backing array.
- Returns:
Sparse array or
None.
- property sparsity: floatο
Get the sparse stored-entry ratio.
- Returns:
Sparsity ratio.
- class VeraGridEngine.Devices.Profiles.ProfileDevice(default_value: EditableDevice | str | None, device_type: DeviceType, arr: np.ndarray | None = None, sparsity_threshold: float = 0.8, is_sparse: bool = False)[source]ο
Bases:
objectProfile specialized for editable-device references.
- astype(tpe: Any) ndarray[source]ο
Cast the dense representation to another dtype.
- Parameters:
tpe β Target dtype.
- Returns:
Cast dense array.
- convert_sparse_to_dense() None[source]ο
Convert the sparse profile into dense storage.
- Returns:
None.
- copy() ProfileDevice[source]ο
Build a deep copy of the profile.
- Returns:
New profile copy.
- create_dense(size: int, default_value: EditableDevice | str | None) None[source]ο
Create the profile in dense form.
- Parameters:
size β Logical size.
default_value β Dense fill value.
- Returns:
None.
- create_sparse(size: int, default_value: EditableDevice | str | None, map_data: dict[int, 'EditableDevice | str | None'] | None = None) None[source]ο
Create the profile in sparse form.
- Parameters:
size β Logical size.
default_value β Sparse default value.
map_data β Optional sparse map.
- Returns:
None.
- property default_value: EditableDevice | str | Noneο
Get the profile default value.
- Returns:
Default value.
- property dense_array: ndarray | Noneο
Get the dense backing array.
- Returns:
Dense array or
None.
- property dtype: DeviceTypeο
Get the declared selector type.
- Returns:
Device selector.
- fill(value: EditableDevice | str | None) None[source]ο
Fill the profile with a single value.
- Parameters:
value β Fill value.
- Returns:
None.
- fix_nan(default_value: float = 0.0) None[source]ο
Keep the device profile API aligned with the generic profile.
- Parameters:
default_value β Unused placeholder.
- Returns:
None.
- get_sparse_map() dict[int, 'EditableDevice | str | None'][source]ο
Get the sparse map when the profile is sparse.
- Returns:
Sparse map or an empty dictionary.
- get_sparse_representation() tuple[list[int], list['EditableDevice | str | None']][source]ο
Export the sparse contents as parallel index and value lists.
- Returns:
Tuple
(indices, values).
- property is_initialized: boolο
Get whether the profile has been initialized.
- Returns:
Initialization state.
- property is_sparse: boolο
Get whether the profile uses sparse storage.
- Returns:
Sparse state.
- rebind_device_references(objects_by_idtag: dict[str, 'EditableDevice']) None[source]ο
Rebind stored device references to equivalent objects from a target lookup.
- Parameters:
objects_by_idtag β idtag -> target object lookup.
- resample(indices: ndarray[tuple[Any, ...], dtype[int64]]) None[source]ο
Resample the profile in place.
- Parameters:
indices β New index selection.
- Returns:
None.
- resize(n: int) None[source]ο
Resize the profile.
- Parameters:
n β New logical size.
- Returns:
None.
- scale(value: float | int) None[source]ο
Reject scaling because device profiles are not numeric.
- Parameters:
value β Scalar multiplier.
- Returns:
None.
- set(arr: ndarray) bool[source]ο
Set the profile from a dense array.
- Parameters:
arr β Dense device-reference array.
- Returns:
Truewhen the assignment succeeds.
- set_sparse_data_from_data(indptr: list[int], data: list['EditableDevice | str | None']) None[source]ο
Load sparse data from parallel lists.
- Parameters:
indptr β Sparse indices.
data β Sparse values.
- Returns:
None.
- property sparse_array: SparseArrayDevice | Noneο
Get the sparse backing array.
- Returns:
Sparse array or
None.
- property sparsity: floatο
Get the sparse stored-entry ratio.
- Returns:
Sparsity ratio.
- class VeraGridEngine.Devices.Profiles.ProfileEnum(default_value: Enum | None, enum_type: type[Enum], arr: ndarray | None = None, sparsity_threshold: float = 0.8, is_sparse: bool = False)[source]ο
Bases:
objectProfile specialized for enum values.
- astype(tpe: Any) ndarray[source]ο
Cast the dense representation to another dtype.
- Parameters:
tpe β Target dtype.
- Returns:
Cast dense array.
- convert_sparse_to_dense() None[source]ο
Convert the sparse profile into dense storage.
- Returns:
None.
- copy() ProfileEnum[source]ο
Build a deep copy of the profile.
- Returns:
New profile copy.
- create_dense(size: int, default_value: Enum | None) None[source]ο
Create the profile in dense form.
- Parameters:
size β Logical size.
default_value β Dense fill value.
- Returns:
None.
- create_sparse(size: int, default_value: Enum | None, map_data: dict[int, Enum | None] | None = None) None[source]ο
Create the profile in sparse form.
- Parameters:
size β Logical size.
default_value β Sparse default value.
map_data β Optional sparse map.
- Returns:
None.
- property default_value: Enum | Noneο
Get the profile default value.
- Returns:
Default value.
- property dense_array: ndarray | Noneο
Get the dense backing array.
- Returns:
Dense array or
None.
- property dtype: type[Enum]ο
Get the declared enum type.
- Returns:
Enum class.
- fill(value: Enum | None) None[source]ο
Fill the profile with a single value.
- Parameters:
value β Fill value.
- Returns:
None.
- fix_nan(default_value: float = 0.0) None[source]ο
Keep the enum profile API aligned with the generic profile.
- Parameters:
default_value β Unused placeholder.
- Returns:
None.
- get_sparse_map() dict[int, Enum | None][source]ο
Get the sparse map when the profile is sparse.
- Returns:
Sparse map or an empty dictionary.
- get_sparse_representation() tuple[list[int], list[Enum | None]][source]ο
Export the sparse contents as parallel index and value lists.
- Returns:
Tuple
(indices, values).
- property is_initialized: boolο
Get whether the profile has been initialized.
- Returns:
Initialization state.
- property is_sparse: boolο
Get whether the profile uses sparse storage.
- Returns:
Sparse state.
- resample(indices: ndarray[tuple[Any, ...], dtype[int64]]) None[source]ο
Resample the profile in place.
- Parameters:
indices β New index selection.
- Returns:
None.
- resize(n: int) None[source]ο
Resize the profile.
- Parameters:
n β New logical size.
- Returns:
None.
- scale(value: float | int) None[source]ο
Reject scaling because enum profiles are not numeric.
- Parameters:
value β Scalar multiplier.
- Returns:
None.
- set(arr: ndarray) bool[source]ο
Set the profile from a dense array.
- Parameters:
arr β Dense enum array.
- Returns:
Truewhen the assignment succeeds.
- set_sparse_data_from_data(indptr: list[int], data: list[Enum | None]) None[source]ο
Load sparse data from parallel lists.
- Parameters:
indptr β Sparse indices.
data β Sparse values.
- Returns:
None.
- property sparse_array: SparseArrayEnum | Noneο
Get the sparse backing array.
- Returns:
Sparse array or
None.
- property sparsity: floatο
Get the sparse stored-entry ratio.
- Returns:
Sparsity ratio.
- class VeraGridEngine.Devices.Profiles.ProfileFloat(default_value: float, arr: ndarray | None = None, sparsity_threshold: float = 0.8, is_sparse: bool = False)[source]ο
Bases:
objectProfile specialized for
floatvalues.- astype(tpe: Any) ndarray[source]ο
Cast the dense representation to another dtype.
- Parameters:
tpe β Target dtype.
- Returns:
Cast dense array.
- convert_sparse_to_dense() None[source]ο
Convert the sparse profile into dense storage.
- Returns:
None.
- copy() ProfileFloat[source]ο
Build a deep copy of the profile.
- Returns:
New profile copy.
- create_dense(size: int, default_value: float) None[source]ο
Create the profile in dense form.
- Parameters:
size β Logical size.
default_value β Dense fill value.
- Returns:
None.
- create_sparse(size: int, default_value: float, map_data: dict[int, float] | None = None) None[source]ο
Create the profile in sparse form.
- Parameters:
size β Logical size.
default_value β Sparse default value.
map_data β Optional sparse map.
- Returns:
None.
- property default_value: floatο
Get the profile default value.
- Returns:
Default value.
- property dense_array: ndarray | Noneο
Get the dense backing array.
- Returns:
Dense array or
None.
- property dtype: type[float]ο
Get the declared type.
- Returns:
float.
- fill(value: float) None[source]ο
Fill the profile with a single value.
- Parameters:
value β Fill value.
- Returns:
None.
- fix_nan(default_value: float = 0.0) None[source]ο
Replace
NaNvalues in place.- Parameters:
default_value β Replacement value.
- Returns:
None.
- get_sparse_map() dict[int, float][source]ο
Get the sparse map when the profile is sparse.
- Returns:
Sparse map or an empty dictionary.
- get_sparse_representation() tuple[list[int], list[float]][source]ο
Export the sparse contents as parallel index and value lists.
- Returns:
Tuple
(indices, values).
- property is_initialized: boolο
Get whether the profile has been initialized.
- Returns:
Initialization state.
- property is_sparse: boolο
Get whether the profile uses sparse storage.
- Returns:
Sparse state.
- resample(indices: ndarray[tuple[Any, ...], dtype[int64]]) None[source]ο
Resample the profile in place.
- Parameters:
indices β New index selection.
- Returns:
None.
- resize(n: int) None[source]ο
Resize the profile.
- Parameters:
n β New logical size.
- Returns:
None.
- scale(value: float | int) None[source]ο
Scale the profile by a scalar.
- Parameters:
value β Scalar multiplier.
- Returns:
None.
- set(arr: ndarray) bool[source]ο
Set the profile from a dense array.
- Parameters:
arr β Dense float array.
- Returns:
Truewhen the assignment succeeds.
- set_sparse_data_from_data(indptr: list[int], data: list[float]) None[source]ο
Load sparse data from parallel lists.
- Parameters:
indptr β Sparse indices.
data β Sparse values.
- Returns:
None.
- property sparse_array: SparseArrayFloat | Noneο
Get the sparse backing array.
- Returns:
Sparse array or
None.
- property sparsity: floatο
Get the sparse stored-entry ratio.
- Returns:
Sparsity ratio.
- class VeraGridEngine.Devices.Profiles.ProfileInt(default_value: int, arr: ndarray | None = None, sparsity_threshold: float = 0.8, is_sparse: bool = False)[source]ο
Bases:
objectProfile specialized for
intvalues.- astype(tpe: Any) ndarray[source]ο
Cast the dense representation to another dtype.
- Parameters:
tpe β Target dtype.
- Returns:
Cast dense array.
- convert_sparse_to_dense() None[source]ο
Convert the sparse profile into dense storage.
- Returns:
None.
- copy() ProfileInt[source]ο
Build a deep copy of the profile.
- Returns:
New profile copy.
- create_dense(size: int, default_value: int) None[source]ο
Create the profile in dense form.
- Parameters:
size β Logical size.
default_value β Dense fill value.
- Returns:
None.
- create_sparse(size: int, default_value: int, map_data: dict[int, int] | None = None) None[source]ο
Create the profile in sparse form.
- Parameters:
size β Logical size.
default_value β Sparse default value.
map_data β Optional sparse map.
- Returns:
None.
- property default_value: intο
Get the profile default value.
- Returns:
Default value.
- property dense_array: ndarray | Noneο
Get the dense backing array.
- Returns:
Dense array or
None.
- property dtype: type[int]ο
Get the declared type.
- Returns:
int.
- fill(value: int) None[source]ο
Fill the profile with a single value.
- Parameters:
value β Fill value.
- Returns:
None.
- fix_nan(default_value: float = 0.0) None[source]ο
Keep the integer profile API aligned with the generic profile.
- Parameters:
default_value β Unused placeholder.
- Returns:
None.
- get_sparse_map() dict[int, int][source]ο
Get the sparse map when the profile is sparse.
- Returns:
Sparse map or an empty dictionary.
- get_sparse_representation() tuple[list[int], list[int]][source]ο
Export the sparse contents as parallel index and value lists.
- Returns:
Tuple
(indices, values).
- property is_initialized: boolο
Get whether the profile has been initialized.
- Returns:
Initialization state.
- property is_sparse: boolο
Get whether the profile uses sparse storage.
- Returns:
Sparse state.
- resample(indices: ndarray[tuple[Any, ...], dtype[int64]]) None[source]ο
Resample the profile in place.
- Parameters:
indices β New index selection.
- Returns:
None.
- resize(n: int) None[source]ο
Resize the profile.
- Parameters:
n β New logical size.
- Returns:
None.
- scale(value: float | int) None[source]ο
Scale the profile by a scalar.
- Parameters:
value β Scalar multiplier.
- Returns:
None.
- set(arr: ndarray) bool[source]ο
Set the profile from a dense array.
- Parameters:
arr β Dense integer array.
- Returns:
Truewhen the assignment succeeds.
- set_sparse_data_from_data(indptr: list[int], data: list[int]) None[source]ο
Load sparse data from parallel lists.
- Parameters:
indptr β Sparse indices.
data β Sparse values.
- Returns:
None.
- property sparse_array: SparseArrayInt | Noneο
Get the sparse backing array.
- Returns:
Sparse array or
None.
- property sparsity: floatο
Get the sparse stored-entry ratio.
- Returns:
Sparsity ratio.
- class VeraGridEngine.Devices.Profiles.SparseArrayBool(default_value: bool, size: int = 0)[source]ο
Bases:
objectSparse array specialized for
boolvalues.- at(idx: int) bool[source]ο
Get a value at a given position.
- Parameters:
idx β Position to read.
- Returns:
Value at
idx.
- copy() SparseArrayBool[source]ο
Build a deep copy of the sparse array.
- Returns:
New sparse array copy.
- create(size: int, default_value: bool, data: dict[int, bool] | None = None) SparseArrayBool[source]ο
Create the sparse array from explicit sparse data.
- Parameters:
size β Logical size.
default_value β Default sparse value.
data β Sparse map.
- Returns:
self.
- create_from_array(array: ndarray, default_value: bool) SparseArrayBool[source]ο
Create the sparse array from a dense array.
- Parameters:
array β Dense boolean array.
default_value β Default sparse value.
- Returns:
self.
- create_from_dict(default_value: bool, size: int, map_data: dict[int, bool]) SparseArrayBool[source]ο
Create the sparse array from a sparse map.
- Parameters:
default_value β Default sparse value.
size β Logical size.
map_data β Sparse map.
- Returns:
self.
- property default_value: boolο
Get the default sparse value.
- Returns:
Default sparse value.
- property dtype: type[bool]ο
Get the declared type.
- Returns:
bool.
- fill(value: bool) None[source]ο
Fill the logical array with the same value.
- Parameters:
value β Fill value.
- Returns:
None.
- get_sparse_representation() tuple[list[int], list[bool]][source]ο
Export the sparse contents as parallel index and value lists.
- Returns:
Tuple
(indices, values).
- insert(i: int, x: bool) None[source]ο
Insert a sparse value explicitly.
- Parameters:
i β Target index.
x β Value to store.
- Returns:
None.
- resample(indices: ndarray[tuple[Any, ...], dtype[int64]]) None[source]ο
Resample the sparse array in place.
- Parameters:
indices β New index selection.
- Returns:
None.
- resize(n: int) None[source]ο
Resize the sparse array.
- Parameters:
n β New logical size.
- Returns:
None.
- set_data(d: dict[int, bool]) None[source]ο
Replace the sparse map.
- Parameters:
d β New sparse map.
- Returns:
None.
- set_sparse_data_from_data(indptr: list[int], data: list[bool]) None[source]ο
Load sparse data from parallel lists.
- Parameters:
indptr β Sparse indices.
data β Sparse values.
- Returns:
None.
- slice(indices: ndarray[tuple[Any, ...], dtype[int64]]) SparseArrayBool[source]ο
Get a resampled copy.
- Parameters:
indices β New index selection.
- Returns:
Resampled sparse array.
- class VeraGridEngine.Devices.Profiles.SparseArrayDevice(default_value: EditableDevice | str | None, device_type: DeviceType, size: int = 0)[source]ο
Bases:
objectSparse array specialized for editable-device references.
- at(idx: int) EditableDevice | str | None[source]ο
Get a value at a given position.
- Parameters:
idx β Position to read.
- Returns:
Value at
idx.
- copy() SparseArrayDevice[source]ο
Build a deep copy of the sparse array.
- Returns:
New sparse array copy.
- create(size: int, default_value: EditableDevice | str | None, data: dict[int, 'EditableDevice | str | None'] | None = None) SparseArrayDevice[source]ο
Create the sparse array from explicit sparse data.
- Parameters:
size β Logical size.
default_value β Default sparse value.
data β Sparse map.
- Returns:
self.
- create_from_array(array: np.ndarray, default_value: EditableDevice | str | None) SparseArrayDevice[source]ο
Create the sparse array from a dense array.
- Parameters:
array β Dense object array.
default_value β Default sparse value.
- Returns:
self.
- create_from_dict(default_value: EditableDevice | str | None, size: int, map_data: dict[int, 'EditableDevice | str | None']) SparseArrayDevice[source]ο
Create the sparse array from a sparse map.
- Parameters:
default_value β Default sparse value.
size β Logical size.
map_data β Sparse map.
- Returns:
self.
- property default_value: EditableDevice | str | Noneο
Get the default sparse value.
- Returns:
Default sparse value.
- property dtype: DeviceTypeο
Get the declared selector type.
- Returns:
Device selector.
- fill(value: EditableDevice | str | None) None[source]ο
Fill the logical array with the same value.
- Parameters:
value β Fill value.
- Returns:
None.
- get_map() dict[int, 'EditableDevice | str | None'][source]ο
Get the sparse map.
- Returns:
Sparse index-value map.
- get_sparse_representation() tuple[list[int], list['EditableDevice | str | None']][source]ο
Export the sparse contents as parallel index and value lists.
- Returns:
Tuple
(indices, values).
- insert(i: int, x: EditableDevice | str | None) None[source]ο
Insert a sparse value explicitly.
- Parameters:
i β Target index.
x β Value to store.
- Returns:
None.
- rebind_device_references(objects_by_idtag: dict[str, 'EditableDevice']) None[source]ο
Rebind stored device references to equivalent objects from a target lookup.
- Parameters:
objects_by_idtag β idtag -> target object lookup.
- resample(indices: ndarray[tuple[Any, ...], dtype[int64]]) None[source]ο
Resample the sparse array in place.
- Parameters:
indices β New index selection.
- Returns:
None.
- resize(n: int) None[source]ο
Resize the sparse array.
- Parameters:
n β New logical size.
- Returns:
None.
- set_data(d: dict[int, 'EditableDevice | str | None']) None[source]ο
Replace the sparse map.
- Parameters:
d β New sparse map.
- Returns:
None.
- set_sparse_data_from_data(indptr: list[int], data: list['EditableDevice | str | None']) None[source]ο
Load sparse data from parallel lists.
- Parameters:
indptr β Sparse indices.
data β Sparse values.
- Returns:
None.
- slice(indices: ndarray[tuple[Any, ...], dtype[int64]]) SparseArrayDevice[source]ο
Get a resampled copy.
- Parameters:
indices β New index selection.
- Returns:
Resampled sparse array.
- class VeraGridEngine.Devices.Profiles.SparseArrayEnum(default_value: Enum | None, enum_type: type[Enum], size: int = 0)[source]ο
Bases:
objectSparse array specialized for enum values.
- at(idx: int) Enum | None[source]ο
Get a value at a given position.
- Parameters:
idx β Position to read.
- Returns:
Value at
idx.
- copy() SparseArrayEnum[source]ο
Build a deep copy of the sparse array.
- Returns:
New sparse array copy.
- create(size: int, default_value: Enum | None, data: dict[int, Enum | None] | None = None) SparseArrayEnum[source]ο
Create the sparse array from explicit sparse data.
- Parameters:
size β Logical size.
default_value β Default sparse value.
data β Sparse map.
- Returns:
self.
- create_from_array(array: ndarray, default_value: Enum | None) SparseArrayEnum[source]ο
Create the sparse array from a dense array.
- Parameters:
array β Dense object array.
default_value β Default sparse value.
- Returns:
self.
- create_from_dict(default_value: Enum | None, size: int, map_data: dict[int, Enum | None]) SparseArrayEnum[source]ο
Create the sparse array from a sparse map.
- Parameters:
default_value β Default sparse value.
size β Logical size.
map_data β Sparse map.
- Returns:
self.
- property default_value: Enum | Noneο
Get the default sparse value.
- Returns:
Default sparse value.
- property dtype: type[Enum]ο
Get the declared enum type.
- Returns:
Enum class.
- fill(value: Enum | None) None[source]ο
Fill the logical array with the same value.
- Parameters:
value β Fill value.
- Returns:
None.
- get_sparse_representation() tuple[list[int], list[Enum | None]][source]ο
Export the sparse contents as parallel index and value lists.
- Returns:
Tuple
(indices, values).
- insert(i: int, x: Enum | None) None[source]ο
Insert a sparse value explicitly.
- Parameters:
i β Target index.
x β Value to store.
- Returns:
None.
- resample(indices: ndarray[tuple[Any, ...], dtype[int64]]) None[source]ο
Resample the sparse array in place.
- Parameters:
indices β New index selection.
- Returns:
None.
- resize(n: int) None[source]ο
Resize the sparse array.
- Parameters:
n β New logical size.
- Returns:
None.
- set_data(d: dict[int, Enum | None]) None[source]ο
Replace the sparse map.
- Parameters:
d β New sparse map.
- Returns:
None.
- set_sparse_data_from_data(indptr: list[int], data: list[Enum | None]) None[source]ο
Load sparse data from parallel lists.
- Parameters:
indptr β Sparse indices.
data β Sparse values.
- Returns:
None.
- slice(indices: ndarray[tuple[Any, ...], dtype[int64]]) SparseArrayEnum[source]ο
Get a resampled copy.
- Parameters:
indices β New index selection.
- Returns:
Resampled sparse array.
- class VeraGridEngine.Devices.Profiles.SparseArrayFloat(default_value: float, size: int = 0)[source]ο
Bases:
objectSparse array specialized for
floatvalues.- at(idx: int) float[source]ο
Get a value at a given position.
- Parameters:
idx β Position to read.
- Returns:
Value at
idx.
- copy() SparseArrayFloat[source]ο
Build a deep copy of the sparse array.
- Returns:
New sparse array copy.
- create(size: int, default_value: float, data: dict[int, float] | None = None) SparseArrayFloat[source]ο
Create the sparse array from explicit sparse data.
- Parameters:
size β Logical size.
default_value β Default sparse value.
data β Sparse map.
- Returns:
self.
- create_from_array(array: ndarray, default_value: float) SparseArrayFloat[source]ο
Create the sparse array from a dense array.
- Parameters:
array β Dense float array.
default_value β Default sparse value.
- Returns:
self.
- create_from_dict(default_value: float, size: int, map_data: dict[int, float]) SparseArrayFloat[source]ο
Create the sparse array from a sparse map.
- Parameters:
default_value β Default sparse value.
size β Logical size.
map_data β Sparse map.
- Returns:
self.
- property default_value: floatο
Get the default sparse value.
- Returns:
Default sparse value.
- property dtype: type[float]ο
Get the declared type.
- Returns:
float.
- fill(value: float) None[source]ο
Fill the logical array with the same value.
- Parameters:
value β Fill value.
- Returns:
None.
- get_sparse_representation() tuple[list[int], list[float]][source]ο
Export the sparse contents as parallel index and value lists.
- Returns:
Tuple
(indices, values).
- insert(i: int, x: float) None[source]ο
Insert a sparse value explicitly.
- Parameters:
i β Target index.
x β Value to store.
- Returns:
None.
- resample(indices: ndarray[tuple[Any, ...], dtype[int64]]) None[source]ο
Resample the sparse array in place.
- Parameters:
indices β New index selection.
- Returns:
None.
- resize(n: int) None[source]ο
Resize the sparse array.
- Parameters:
n β New logical size.
- Returns:
None.
- set_data(d: dict[int, float]) None[source]ο
Replace the sparse map.
- Parameters:
d β New sparse map.
- Returns:
None.
- set_sparse_data_from_data(indptr: list[int], data: list[float]) None[source]ο
Load sparse data from parallel lists.
- Parameters:
indptr β Sparse indices.
data β Sparse values.
- Returns:
None.
- slice(indices: ndarray[tuple[Any, ...], dtype[int64]]) SparseArrayFloat[source]ο
Get a resampled copy.
- Parameters:
indices β New index selection.
- Returns:
Resampled sparse array.
- class VeraGridEngine.Devices.Profiles.SparseArrayInt(default_value: int, size: int = 0)[source]ο
Bases:
objectSparse array specialized for
intvalues.- at(idx: int) int[source]ο
Get a value at a given position.
- Parameters:
idx β Position to read.
- Returns:
Value at
idx.
- copy() SparseArrayInt[source]ο
Build a deep copy of the sparse array.
- Returns:
New sparse array copy.
- create(size: int, default_value: int, data: dict[int, int] | None = None) SparseArrayInt[source]ο
Create the sparse array from explicit sparse data.
- Parameters:
size β Logical size.
default_value β Default sparse value.
data β Sparse map.
- Returns:
self.
- create_from_array(array: ndarray, default_value: int) SparseArrayInt[source]ο
Create the sparse array from a dense array.
- Parameters:
array β Dense integer array.
default_value β Default sparse value.
- Returns:
self.
- create_from_dict(default_value: int, size: int, map_data: dict[int, int]) SparseArrayInt[source]ο
Create the sparse array from a sparse map.
- Parameters:
default_value β Default sparse value.
size β Logical size.
map_data β Sparse map.
- Returns:
self.
- property default_value: intο
Get the default sparse value.
- Returns:
Default sparse value.
- property dtype: type[int]ο
Get the declared type.
- Returns:
int.
- fill(value: int) None[source]ο
Fill the logical array with the same value.
- Parameters:
value β Fill value.
- Returns:
None.
- get_sparse_representation() tuple[list[int], list[int]][source]ο
Export the sparse contents as parallel index and value lists.
- Returns:
Tuple
(indices, values).
- insert(i: int, x: int) None[source]ο
Insert a sparse value explicitly.
- Parameters:
i β Target index.
x β Value to store.
- Returns:
None.
- resample(indices: ndarray[tuple[Any, ...], dtype[int64]]) None[source]ο
Resample the sparse array in place.
- Parameters:
indices β New index selection.
- Returns:
None.
- resize(n: int) None[source]ο
Resize the sparse array.
- Parameters:
n β New logical size.
- Returns:
None.
- set_data(d: dict[int, int]) None[source]ο
Replace the sparse map.
- Parameters:
d β New sparse map.
- Returns:
None.
- set_sparse_data_from_data(indptr: list[int], data: list[int]) None[source]ο
Load sparse data from parallel lists.
- Parameters:
indptr β Sparse indices.
data β Sparse values.
- Returns:
None.
- slice(indices: ndarray[tuple[Any, ...], dtype[int64]]) SparseArrayInt[source]ο
Get a resampled copy.
- Parameters:
indices β New index selection.
- Returns:
Resampled sparse array.
- VeraGridEngine.Devices.Profiles.check_if_sparse(arr: ndarray, sparsity: float = 0.8) tuple[bool, Any][source]ο
Check whether an array should be stored as sparse.
- Parameters:
arr β Array to inspect.
sparsity β Minimum repetition ratio required for sparse storage.
- Returns:
Tuple
(is_sparse, most_frequent_value).
- VeraGridEngine.Devices.Profiles.check_type(dtype: type[bool] | type[int] | type[float] | type[Enum] | DeviceType, value: Any) bool[source]ο
Check that a value is compatible with a declared profile type.
- Parameters:
dtype β Declared profile type.
value β Value to validate.
- Returns:
Truewhenvaluematchesdtype.