Skip to content

Commit 176af0f

Browse files
authored
Merge pull request #101 from Pressio/fix_99
Remove "Abstract" from "AbstractXYZ" class names
2 parents 086551a + 8406e6c commit 176af0f

File tree

10 files changed

+61
-61
lines changed

10 files changed

+61
-61
lines changed

romtools/__init__.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
8181
## Representative abstract base classes
8282
83-
- `AbstractTrialSpace`
83+
- `TrialSpace`
8484
- This class defines the minimum API requirements for a trial space
8585
8686
- Constructing a trial space relies on utilities like truncaters, orthogonalizers, etc. Abstract classes, and
@@ -92,7 +92,7 @@
9292
- splitters
9393
- truncaters
9494
95-
- `AbstractParameterSpace`
95+
- `ParameterSpace`
9696
- This class defines the minimum API of a parameter space. These parameter spaces are used in workflows for
9797
running/building ROMs
9898

romtools/hyper_reduction/ecsw.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@
8181
import numpy as np
8282

8383

84-
class AbstractECSWsolver(abc.ABC):
84+
class ECSWsolver(abc.ABC):
8585
'''
8686
Abstract base class for ECSW solvers
8787
@@ -129,7 +129,7 @@ def __call__(self, full_mesh_lhs: np.ndarray, full_mesh_rhs: np.array, tolerance
129129
# this function because tau can't be specified
130130

131131

132-
class ECSWsolverNNLS(AbstractECSWsolver):
132+
class ECSWsolverNNLS(ECSWsolver):
133133
'''
134134
Given a linear system with left-hand side full_mesh_lhs and right-hand side full_mesh_rhs compute sample mesh indices and weights for ECSW using the non-negative least squares algorithm from Chapman et al. 2016
135135
DOI: 10.1002/nme.5332.
@@ -330,7 +330,7 @@ def _construct_linear_system(residual_snapshots: np.ndarray,
330330
return full_mesh_lhs, full_mesh_rhs
331331

332332

333-
def ecsw_fixed_test_basis(ecsw_solver: AbstractECSWsolver,
333+
def ecsw_fixed_test_basis(ecsw_solver: ECSWsolver,
334334
residual_snapshots: np.ndarray,
335335
test_basis: np.ndarray,
336336
n_var: int,
@@ -340,7 +340,7 @@ def ecsw_fixed_test_basis(ecsw_solver: AbstractECSWsolver,
340340
ECSW implementation for a fixed test basis, such as POD-Galerkin projection
341341
342342
Args:
343-
ecsw_solver: AbstractECSWsolver object corresponding to a child class with concrete implementations such as ECSWsolverNNLS.
343+
ecsw_solver: ECSWsolver object corresponding to a child class with concrete implementations such as ECSWsolverNNLS.
344344
residual_snapshots: (n_dof*n_var, n_snap) numpy ndarray, where n_dof is the number of mesh degrees of freedom (DoFs) (nodes, volumes, or elements), n_var is the number of residual variables, and n_snap is the number of snapshots
345345
test_basis: (n_dof*n_var, n_mode) numpy ndarray, where n_mode is the number of modes in the basis.
346346
n_var: int, the number of residual variables (e.g. for fluid flow, residual variable could be mass, x-momentum, y-momentum, z-momentum, and energy)
@@ -361,15 +361,15 @@ def ecsw_fixed_test_basis(ecsw_solver: AbstractECSWsolver,
361361

362362
return ecsw_solver(full_mesh_lhs, full_mesh_rhs, tolerance)
363363

364-
def ecsw_varying_test_basis(ecsw_solver: AbstractECSWsolver,
364+
def ecsw_varying_test_basis(ecsw_solver: ECSWsolver,
365365
full_mesh_lhs: np.ndarray,
366366
full_mesh_rhs: np.ndarray,
367367
tolerance: np.double):
368368
'''
369369
ECSW implementation for a varying test basis, such as Least-Squares Petrov-Galerkin projection
370370
371371
Args:
372-
ecsw_solver: AbstractECSWsolver object corresponding to a child class with concrete implementations such as ECSWsolverNNLS.
372+
ecsw_solver: ECSWsolver object corresponding to a child class with concrete implementations such as ECSWsolverNNLS.
373373
full_mesh_lhs: (n_snap*n_rom, n_dof) numpy ndarray, where n_snap is the number of residual snapshots, n_rom is the ROM dimension, and n_dof is the number of mesh degrees of freedom (DoFs) (nodes, volumes, or elements)
374374
full_mesh_rhs: (n_snap*n_rom,) numpy array
375375
tolerance: Double, the ECSW tolerance parameter. Lower values of tolerance will result in more mesh DoF samples

romtools/trial_space.py

+22-22
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,14 @@
6565

6666
import abc
6767
import numpy as np
68-
from romtools.trial_space_utils.truncater import AbstractTruncater, NoOpTruncater
69-
from romtools.trial_space_utils.shifter import AbstractShifter, NoOpShifter
70-
from romtools.trial_space_utils.scaler import AbstractScaler
71-
from romtools.trial_space_utils.splitter import AbstractSplitter, NoOpSplitter
72-
from romtools.trial_space_utils.orthogonalizer import AbstractOrthogonalizer, NoOpOrthogonalizer
68+
from romtools.trial_space_utils.truncater import Truncater, NoOpTruncater
69+
from romtools.trial_space_utils.shifter import Shifter, NoOpShifter
70+
from romtools.trial_space_utils.scaler import Scaler
71+
from romtools.trial_space_utils.splitter import Splitter, NoOpSplitter
72+
from romtools.trial_space_utils.orthogonalizer import Orthogonalizer, NoOpOrthogonalizer
7373

7474

75-
class AbstractTrialSpace(abc.ABC):
75+
class TrialSpace(abc.ABC):
7676
'''
7777
Abstract base class for trial space implementations.
7878
@@ -142,7 +142,7 @@ def matrix_to_tensor(n_var, matrix_input):
142142
return output_matrix
143143

144144

145-
class DictionaryTrialSpace(AbstractTrialSpace):
145+
class DictionaryTrialSpace(TrialSpace):
146146
'''
147147
##Reduced basis trial space (no truncation).
148148
@@ -205,7 +205,7 @@ def get_basis(self):
205205
return self.__basis
206206

207207

208-
class TrialSpaceFromPOD(AbstractTrialSpace):
208+
class TrialSpaceFromPOD(TrialSpace):
209209
'''
210210
##POD trial space (constructed via SVD).
211211
@@ -225,20 +225,20 @@ class TrialSpaceFromPOD(AbstractTrialSpace):
225225

226226
def __init__(self,
227227
snapshot_tensor,
228-
truncater: AbstractTruncater = NoOpTruncater(),
229-
shifter: AbstractShifter = NoOpShifter(),
230-
splitter: AbstractSplitter = NoOpSplitter(),
231-
orthogonalizer: AbstractOrthogonalizer = NoOpOrthogonalizer(),
228+
truncater: Truncater = NoOpTruncater(),
229+
shifter: Shifter = NoOpShifter(),
230+
splitter: Splitter = NoOpSplitter(),
231+
orthogonalizer: Orthogonalizer = NoOpOrthogonalizer(),
232232
svdFnc = None):
233233
'''
234234
Constructor for the POD trial space.
235235
236236
Args:
237237
snapshot_tensor (np.ndarray): Snapshot data tensor
238-
truncater (AbstractTruncater): Class that truncates the basis.
239-
shifter (AbstractShifter): Class that shifts the basis.
240-
splitter (AbstractSplitter): Class that splits the basis.
241-
orthogonalizer (AbstractOrthogonalizer): Class that orthogonalizes
238+
truncater (Truncater): Class that truncates the basis.
239+
shifter (Shifter): Class that shifts the basis.
240+
splitter (Splitter): Class that splits the basis.
241+
orthogonalizer (Orthogonalizer): Class that orthogonalizes
242242
the basis.
243243
svdFnc: a callable to use for computing the SVD on the snapshots data.
244244
IMPORTANT: must conform to the API of [np.linalg.svd](https://numpy.org/doc/stable/reference/generated/numpy.linalg.svd.html#numpy-linalg-svd).
@@ -296,7 +296,7 @@ def get_basis(self):
296296
return self.__basis
297297

298298

299-
class TrialSpaceFromScaledPOD(AbstractTrialSpace):
299+
class TrialSpaceFromScaledPOD(TrialSpace):
300300
'''
301301
##POD trial space (constructed via scaled SVD).
302302
@@ -315,11 +315,11 @@ class TrialSpaceFromScaledPOD(AbstractTrialSpace):
315315
'''
316316

317317
def __init__(self, snapshot_tensor,
318-
truncater: AbstractTruncater,
319-
shifter: AbstractShifter,
320-
scaler: AbstractScaler,
321-
splitter: AbstractSplitter,
322-
orthogonalizer: AbstractOrthogonalizer):
318+
truncater: Truncater,
319+
shifter: Shifter,
320+
scaler: Scaler,
321+
splitter: Splitter,
322+
orthogonalizer: Orthogonalizer):
323323
'''
324324
Constructor for the POD trial space constructed via scaled SVD.
325325

romtools/trial_space_utils/orthogonalizer.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
import scipy.sparse
5959

6060

61-
class AbstractOrthogonalizer(abc.ABC):
61+
class Orthogonalizer(abc.ABC):
6262
'''
6363
Abstract base class
6464
'''
@@ -68,7 +68,7 @@ def __call__(self, my_array: np.ndarray) -> np.ndarray:
6868
pass
6969

7070

71-
class NoOpOrthogonalizer(AbstractOrthogonalizer):
71+
class NoOpOrthogonalizer(Orthogonalizer):
7272
'''
7373
No op class (doesn't do anything)
7474
'''
@@ -79,7 +79,7 @@ def __call__(self, my_array: np.ndarray):
7979
return my_array
8080

8181

82-
class EuclideanL2Orthogonalizer(AbstractOrthogonalizer):
82+
class EuclideanL2Orthogonalizer(Orthogonalizer):
8383
'''
8484
Orthogonalizes the basis in the standard Euclidean L2 inner product, i.e.,
8585
the output basis will satisfy
@@ -104,7 +104,7 @@ def __call__(self, my_array: np.ndarray):
104104
return my_array
105105

106106

107-
class EuclideanVectorWeightedL2Orthogonalizer(AbstractOrthogonalizer):
107+
class EuclideanVectorWeightedL2Orthogonalizer(Orthogonalizer):
108108
'''
109109
Orthogonalizes the basis in vector-weighted Euclidean L2 inner product,
110110
i.e., the output basis will satisfy

romtools/trial_space_utils/outputter.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
import os
4747
import math
4848
import numpy as np
49-
from romtools.trial_space import AbstractTrialSpace
49+
from romtools.trial_space import TrialSpace
5050

5151
try:
5252
import exodus
@@ -59,13 +59,13 @@
5959
pass
6060

6161

62-
def npz_output(filename: str, trial_space: AbstractTrialSpace, compress=True) -> None:
62+
def npz_output(filename: str, trial_space: TrialSpace, compress=True) -> None:
6363
'''
6464
Save trial space information to a compressed or uncompressed NumPy .npz file.
6565
6666
Args:
6767
filename (str): The name of the output file.
68-
trial_space (AbstractTrialSpace): The trial space containing shift and basis information.
68+
trial_space (TrialSpace): The trial space containing shift and basis information.
6969
compress (bool, optional): Whether to compress the output file (default is True).
7070
7171
Example:
@@ -81,13 +81,13 @@ def npz_output(filename: str, trial_space: AbstractTrialSpace, compress=True) ->
8181
basis=trial_space.get_basis())
8282

8383

84-
def hdf5_output(output_filename: str, trial_space: AbstractTrialSpace) -> None:
84+
def hdf5_output(output_filename: str, trial_space: TrialSpace) -> None:
8585
'''
8686
Save trial space information to an HDF5 file.
8787
8888
Args:
8989
output_filename (str): The name of the output HDF5 file.
90-
trial_space (AbstractTrialSpace): The trial space containing shift and basis information.
90+
trial_space (TrialSpace): The trial space containing shift and basis information.
9191
9292
Example:
9393
hdf5_output("trial_space.h5", my_trial_space)
@@ -97,14 +97,14 @@ def hdf5_output(output_filename: str, trial_space: AbstractTrialSpace) -> None:
9797
f.create_dataset('basis', data=trial_space.get_basis())
9898

9999

100-
def exodus_ouput(output_filename: str, mesh_filename: str, trial_space: AbstractTrialSpace, var_names: list = None) -> None:
100+
def exodus_ouput(output_filename: str, mesh_filename: str, trial_space: TrialSpace, var_names: list = None) -> None:
101101
'''
102102
Save trial space information to an Exodus file.
103103
104104
Args:
105105
output_filename (str): The name of the output Exodus file.
106106
mesh_filename (str): The name of the mesh file.
107-
trial_space (AbstractTrialSpace): The trial space containing shift and basis information.
107+
trial_space (TrialSpace): The trial space containing shift and basis information.
108108
var_names (list, optional): A list of variable names (default is None).
109109
110110
Example:

romtools/trial_space_utils/scaler.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
import numpy as np
7676

7777

78-
class AbstractScaler(abc.ABC):
78+
class Scaler(abc.ABC):
7979
'''
8080
Abstract base class
8181
'''
@@ -95,7 +95,7 @@ def post_scaling(self, data_tensor: np.ndarray) -> np.ndarray:
9595
pass
9696

9797

98-
class NoOpScaler(AbstractScaler):
98+
class NoOpScaler(Scaler):
9999
'''
100100
No op implementation
101101
'''
@@ -109,7 +109,7 @@ def post_scaling(self, data_tensor):
109109
return data_tensor
110110

111111

112-
class VectorScaler(AbstractScaler):
112+
class VectorScaler(Scaler):
113113
'''
114114
Concrete implementation designed to scale snapshot matrices by a vector.
115115
For a snapshot tensor $\\mathbf{S} \\in \\mathbb{R}^{N_{\\mathrm{u}} \\times N \\times K}$, the VectorScaler
@@ -162,7 +162,7 @@ def post_scaling(self, data_tensor):
162162
return self.__scaling_vector_matrix[None, :, None] * data_tensor
163163

164164

165-
class VariableScaler(AbstractScaler):
165+
class VariableScaler(Scaler):
166166
'''
167167
Concrete implementation designed for snapshot matrices involving multiple
168168
state variables.
@@ -259,7 +259,7 @@ def post_scaling(self, data_tensor):
259259
return data_tensor
260260

261261

262-
class VariableAndVectorScaler(AbstractScaler):
262+
class VariableAndVectorScaler(Scaler):
263263
'''
264264
Concrete implementation designed to scale snapshot matrices involving
265265
multiple state variables by both the variable magnitudes and an additional

romtools/trial_space_utils/shifter.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
import numpy as np
6464

6565

66-
class AbstractShifter(abc.ABC):
66+
class Shifter(abc.ABC):
6767
'''
6868
Abstract implmentation
6969
'''
@@ -76,7 +76,7 @@ def __call__(self, my_array: np.ndarray) -> Tuple[np.ndarray, np.ndarray]:
7676
pass
7777

7878

79-
class NoOpShifter(AbstractShifter):
79+
class NoOpShifter(Shifter):
8080
'''
8181
No op implementation
8282
'''
@@ -88,7 +88,7 @@ def __call__(self, my_array: np.ndarray):
8888
return my_array, shift_vector
8989

9090

91-
class ConstantShifter(AbstractShifter):
91+
class ConstantShifter(Shifter):
9292
'''
9393
Shifts the data by a constant value.
9494
'''
@@ -118,7 +118,7 @@ def __call__(self, my_array: np.ndarray):
118118
return my_array-shift_vector[:, :, None], shift_vector
119119

120120

121-
class VectorShifter(AbstractShifter):
121+
class VectorShifter(Shifter):
122122
'''
123123
Shifts the data by a user-input vector.
124124
'''
@@ -135,7 +135,7 @@ def __call__(self, my_array: np.ndarray):
135135
return my_array-self.__shift_vector[..., None], self.__shift_vector
136136

137137

138-
class AverageShifter(AbstractShifter):
138+
class AverageShifter(Shifter):
139139
'''
140140
Shifts the data by the average of a data matrix.
141141
'''
@@ -147,7 +147,7 @@ def __call__(self, my_array: np.ndarray):
147147
return my_array-shift_vector[:, :, None], shift_vector
148148

149149

150-
class FirstVecShifter(AbstractShifter):
150+
class FirstVecShifter(Shifter):
151151
'''
152152
Shifts the data by the first vector of a data matrix.
153153
'''

romtools/trial_space_utils/splitter.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,15 @@
8686
import numpy as np
8787

8888

89-
class AbstractSplitter(abc.ABC):
89+
class Splitter(abc.ABC):
9090
'''Abstract class for a splitter'''
9191

9292
@abc.abstractmethod
9393
def __call__(self, my_array: np.ndarray) -> np.ndarray:
9494
pass
9595

9696

97-
class NoOpSplitter(AbstractSplitter):
97+
class NoOpSplitter(Splitter):
9898
'''Concrete no-op implementation'''
9999
def __init__(self) -> None:
100100
pass
@@ -103,7 +103,7 @@ def __call__(self, my_array: np.ndarray):
103103
return my_array
104104

105105

106-
class BlockSplitter(AbstractSplitter):
106+
class BlockSplitter(Splitter):
107107
'''
108108
Splits a data matrix into blocks defined by a list, e.g., for our Euler
109109
equation example above, we could set

0 commit comments

Comments
 (0)