Skip to content

Commit

Permalink
#195: update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
cwschilly committed May 29, 2024
1 parent b3092aa commit 7e643b6
Showing 1 changed file with 6 additions and 27 deletions.
33 changes: 6 additions & 27 deletions romtools/vector_space/utils/scaler.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,27 +150,19 @@ def __init__(self, scaling_vector) -> None:

def pre_scale(self, data_tensor: np.ndarray) -> None:
"""
Scales the input data matrix using the inverse of the scaling vector
and returns the scaled matrix.
Scales the input data matrix in place using the inverse of the scaling vector.
Args:
data_tensor (np.ndarray): The input data matrix to be scaled.
Returns:
np.ndarray: The scaled data matrix.
"""
data_tensor *= self.__scaling_vector_matrix_inv[None, :, None]

def post_scale(self, data_tensor: np.ndarray) -> None:
"""
Scales the input data matrix using the scaling vector and returns the
scaled matrix.
Scales the input data matrix in place using the scaling vector.
Args:
data_tensor (np.ndarray): The input data matrix to be scaled.
Returns:
np.ndarray: The scaled data matrix.
"""
data_tensor *= self.__scaling_vector_matrix[None, :, None]

Expand Down Expand Up @@ -254,14 +246,11 @@ def initialize_scalings(self, data_tensor: np.ndarray) -> None:
# These are all inplace operations
def pre_scale(self, data_tensor: np.ndarray) -> None:
"""
Scales the input data matrix before processing, taking into account
Scales the input data matrix in place before processing, taking into account
the previously initialized scaling factors.
Args:
data_tensor (np.ndarray): The input data matrix to be scaled.
Returns:
np.ndarray: The scaled data matrix.
"""
n_var = data_tensor.shape[0]
if self.have_scales_been_initialized:
Expand All @@ -274,14 +263,10 @@ def pre_scale(self, data_tensor: np.ndarray) -> None:

def post_scale(self, data_tensor: np.ndarray) -> None:
"""
Scales the input data matrix using the scaling vector and returns the
scaled matrix.
Scales the input data matrix in place using the scaling vector.
Args:
data_tensor (np.ndarray): The input data matrix to be scaled.
Returns:
np.ndarray: The scaled data matrix.
"""
assert self.have_scales_been_initialized, "Scales in VariableScaler have not been initialized"
# scale each field
Expand Down Expand Up @@ -319,28 +304,22 @@ def __init__(self, scaling_vector, scaling_type) -> None:

def pre_scale(self, data_tensor: np.ndarray) -> None:
"""
Scales the input data matrix before processing, first using the
Scales the input data matrix in place before processing, first using the
`VariableScaler` and then the `VectorScaler`.
Args:
data_tensor (np.ndarray): The input data matrix to be scaled.
Returns:
np.ndarray: The scaled data matrix.
"""
self.__my_variable_scaler.pre_scale(data_tensor)
self.__my_vector_scaler.pre_scale(data_tensor)

def post_scale(self, data_tensor: np.ndarray) -> None:
"""
Scales the input data matrix after processing, first using the
Scales the input data matrix in place after processing, first using the
`VectorScaler` and then the `VariableScaler`.
Args:
data_tensor (np.ndarray): The input data matrix to be scaled.
Returns:
np.ndarray: The scaled data matrix.
"""
self.__my_vector_scaler.post_scale(data_tensor)
self.__my_variable_scaler.post_scale(data_tensor)

0 comments on commit 7e643b6

Please sign in to comment.