Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/feature/v4_docs_review' into fea…
Browse files Browse the repository at this point in the history
…ture/v4_docs_review
  • Loading branch information
mds2120 committed Apr 8, 2022
2 parents a275ac7 + 3cb5f63 commit 823e331
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 9 deletions.
5 changes: 2 additions & 3 deletions docs/code/dimension_reduction/pod/plot_pod_1.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,8 @@

start_time = time.time()

pod = DirectPOD(solution_snapshots=Data, modes=1)
pod.run()
Data_reconstr =pod.reconstructed_solution
pod = DirectPOD(solution_snapshots=Data, n_modes=1)
Data_reconstr = pod.reconstructed_solution

# %% md
#
Expand Down
3 changes: 1 addition & 2 deletions docs/code/dimension_reduction/pod/plot_pod_diffusion.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,7 @@
Data_modes = []

for n_mode in n_modes:
pod = DirectPOD(solution_snapshots=Data, modes=n_mode)
pod.run()
pod = DirectPOD(solution_snapshots=Data, n_modes=n_mode)
Data_reconstr = pod.reconstructed_solution
Data_reduced = pod.reduced_solution
Data_modes.append(Data_reconstr[:, :, frame])
Expand Down
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"sphinx.ext.viewcode",
"sphinx.ext.githubpages",
"sphinx.ext.autosummary",
"sphinx.ext.autosectionlabel",
# "sphinx.ext.autosectionlabel",
"sphinx_autodoc_typehints",
"sphinxcontrib.bibtex",
"sphinx_gallery.gen_gallery",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ def frechet_variance(grassmann_points: Union[list[Numpy2DFloatArrayOrthonormal],

variance_nominator = 0
for i in range(points_number):
distances = distance.calculate_distance_matrix([reference_point, grassmann_points[i]], p_dim)
distance.calculate_distance_matrix([reference_point, grassmann_points[i]], p_dim)
distances = distance.distance_matrix
variance_nominator += distances[0] ** 2

return variance_nominator / points_number
Expand Down
9 changes: 7 additions & 2 deletions src/UQpy/dimension_reduction/pod/baseclass/POD.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,19 @@ def __init__(self,
if n_modes is None and reconstruction_percentage is None:
raise ValueError("Either a number of modes or a reconstruction percentage must be chosen, not both.")

if reconstruction_percentage is not None and reconstruction_percentage <= 0:
if reconstruction_percentage is not None and reconstruction_percentage <= 0:
raise ValueError("Invalid input, the reconstruction percentage is defined in the range (0,100].")



self.solution_snapshots = solution_snapshots
self.logger = logging.getLogger(__name__)
self.modes = n_modes
self.reconstruction_percentage = reconstruction_percentage

if reconstruction_percentage is None:
self.reconstruction_percentage = 10**10

if solution_snapshots is not None:
self.run(solution_snapshots)

Expand Down Expand Up @@ -117,7 +122,7 @@ def run(self, solution_snapshots: Union[np.ndarray, list]):
"Number of dimensions is %i", n_iterations)

reconstructed_solutions, reduced_solutions = \
self._calculate_reduced_and_reconstructed_solutions(u, phi, rows, columns, snapshot_number)
self._calculate_reduced_and_reconstructed_solutions(self.U, phi, rows, columns, snapshot_number)

self.logger.info(f"UQpy: Successful execution of {type(self).__name__}!")

Expand Down

0 comments on commit 823e331

Please sign in to comment.