pyRadPlan.util package#
Submodules#
pyRadPlan.util.helpers module#
Test Helper functions for pyRadPlan.
- dl2ld(dict_of_lists, type_check=True)[source]#
Convert a dictionary of lists to a list of dictionaries.
- Parameters:
dict_of_lists (
dict[str,list]) – The dictionary of lists to convert.type_check (
bool) – Whether to perform type checking, by default True
- Returns:
A list of dictionaries.
- Return type:
list[dict]
- ld2dl(list_of_dicts, type_check=True)[source]#
Convert a list of dictionaries to a dictionary of lists.
- Parameters:
list_of_dicts (
list[dict]) – The list of dictionaries to convert.type_check (
bool) – Whether to perform type checking, by default True
- Returns:
A dictionary of lists.
- Return type:
dict[str,list]
- models2recarray(models, serialization_context=None, override_types=None, by_alias=False)[source]#
Convert a list of PyRadPlanBaseModel instances to a numpy recarray.
- Parameters:
models (
list[BaseModel]) – The list of PyRadPlanBaseModel instances to convert.serialization_context (
Union[dict,str]) – The context in which the datastructure should be serialized, by default None.override_types (
dict) – A dictionary of types to override the automatically obtained types, by default None. If the context contains “matRad” and the models are of type PyRadPlanBaseModel, the models will be converted to matRad compatible structures.by_alias (
bool) – Whether to use the alias names for serialization, by default False.
- Returns:
A numpy recarray.
- Return type:
recarray
- swap_orientation_sparse_matrix(sparse_matrix, original_shape, axes)[source]#
Swap the specified axes of a sparse matrix.
- Parameters:
sparse_matrix (
csc_matrix) – The sparse matrix to swap axes.original_shape (tuple) – The original shape of the matrix.
axes (tuple) – The axes to swap.
- Returns:
The sparse matrix with swapped axes.
- Return type:
csc_matrix
Module contents#
Utility functions and helper methods.
- dl2ld(dict_of_lists, type_check=True)[source]#
Convert a dictionary of lists to a list of dictionaries.
- Parameters:
dict_of_lists (
dict[str,list]) – The dictionary of lists to convert.type_check (
bool) – Whether to perform type checking, by default True
- Returns:
A list of dictionaries.
- Return type:
list[dict]
- ld2dl(list_of_dicts, type_check=True)[source]#
Convert a list of dictionaries to a dictionary of lists.
- Parameters:
list_of_dicts (
list[dict]) – The list of dictionaries to convert.type_check (
bool) – Whether to perform type checking, by default True
- Returns:
A dictionary of lists.
- Return type:
dict[str,list]
- models2recarray(models, serialization_context=None, override_types=None, by_alias=False)[source]#
Convert a list of PyRadPlanBaseModel instances to a numpy recarray.
- Parameters:
models (
list[BaseModel]) – The list of PyRadPlanBaseModel instances to convert.serialization_context (
Union[dict,str]) – The context in which the datastructure should be serialized, by default None.override_types (
dict) – A dictionary of types to override the automatically obtained types, by default None. If the context contains “matRad” and the models are of type PyRadPlanBaseModel, the models will be converted to matRad compatible structures.by_alias (
bool) – Whether to use the alias names for serialization, by default False.
- Returns:
A numpy recarray.
- Return type:
recarray
- swap_orientation_sparse_matrix(sparse_matrix, original_shape, axes)[source]#
Swap the specified axes of a sparse matrix.
- Parameters:
sparse_matrix (
csc_matrix) – The sparse matrix to swap axes.original_shape (tuple) – The original shape of the matrix.
axes (tuple) – The axes to swap.
- Returns:
The sparse matrix with swapped axes.
- Return type:
csc_matrix