Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactoring for pre- and post-processing, new design #232

Merged
merged 15 commits into from
Feb 7, 2024
Merged

Conversation

ndem0
Copy link
Member

@ndem0 ndem0 commented Nov 2, 2022

No description provided.

@ndem0 ndem0 mentioned this pull request Jun 28, 2023
@ndem0 ndem0 marked this pull request as ready for review November 20, 2023 18:58
Copy link
Contributor

@flabowski flabowski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hei @ndem0, I left some random comments reading through some of the changes. I did not do any testing, but i like the idea of having plugins for pre- and post- processing.

@@ -41,7 +41,10 @@ def fit(self, points, values):

if as_np_array.ndim == 1 or (as_np_array.ndim == 2
and as_np_array.shape[1] == 1):
self.interpolator = interp1d(as_np_array, values, axis=0)

self.interpolator = interp1d(as_np_array, values, axis=0,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might want to consider adding axis=0, bounds_error=False, **kwargs to the arguments of fit(...). That way the user can control and specify these things.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this class, it is quite difficult to keep that general layout, mainly because we are internally using two different methods depending on the input dimension!


@property
def snapshots(self):
def parameters_matrix(self):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

small typo, could be changed to parameter_matrix

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would keep the plural form at the moment, just to avoid changing all the tests! I'll refactor this class a bit.


@property
def space(self):
def snapshots_matrix(self):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo, could be changed to snapshot_matrix

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would keep the plural form at the moment, just to avoid changing all the tests! I'll refactor this class a bit.

"""
if all(isinstance(n, int) for n in chunks):
if sum(chunks) != len(self):
raise ValueError('chunk elements are incosistent')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo, change to inconsistent


elif all(isinstance(n, float) for n in chunks):
if not np.isclose(sum(chunks), 1.):
raise ValueError('chunk elements are incosistent')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo

The plugin implements the atomatic "shifting" preprocessing: exploiting a
machine learning framework, it is able to detect the quantity to shift the
snapshots composing the database, such that the reduction method performs
better, dipendentely by the problem at hand.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo, "depending on ..."


class AutomaticShiftSnapshots(Plugin):
"""
The plugin implements the atomatic "shifting" preprocessing: exploiting a
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: automatic

Comment on lines 35 to 45
>>> def shift(time):
>>> return time-0.5
>>> pod = POD()
>>> rbf = RBF()
>>> db = Database()
>>> for param in params:
>>> space, values = wave(param)
>>> snap = Snapshot(values=values, space=space)
>>> db.add(Parameter(param), snap)
>>> rom = ROM(db, pod, rbf, plugins=[ShiftSnapshots(shift, RBF())])
>>> rom.fit()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This example is for ShiftSnapshots not for AutomaticShiftSnapshots

@ndem0 ndem0 merged commit a88a799 into mathLab:master Feb 7, 2024
6 of 7 checks passed
@ndem0 ndem0 mentioned this pull request Feb 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants