From 24877a23d2043d0e22366489f19e2b4cc1f3ecbf Mon Sep 17 00:00:00 2001 From: Jake Stevens-Haas <37048747+Jacob-Stevens-Haas@users.noreply.github.com> Date: Mon, 10 Apr 2023 18:31:32 -0700 Subject: [PATCH] BUG: Update parametrized library calc_trajectory API calc_trajectory now returns tuple of (x, x_lhs) Also reverted a error in merging master around inheritance of calc_trajectory --- pysindy/feature_library/generalized_library.py | 4 +++- pysindy/feature_library/parameterized_library.py | 6 ++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pysindy/feature_library/generalized_library.py b/pysindy/feature_library/generalized_library.py index 3a68f8213..08b93cadb 100644 --- a/pysindy/feature_library/generalized_library.py +++ b/pysindy/feature_library/generalized_library.py @@ -161,7 +161,6 @@ def __init__( self.inputs_per_library_ = inputs_per_library self.libraries_full_ = self.libraries_ self.exclude_libs_ = exclude_libraries - self.calc_trajectory = self.libraries_[0].calc_trajectory @x_sequence_or_item def fit(self, x_full, y=None): @@ -315,6 +314,9 @@ def get_feature_names(self, input_features=None): feature_names += lib.get_feature_names(input_features_i) return feature_names + def calc_trajectory(self, diff_method, x, t): + return self.libraries_[0].calc_trajectory(diff_method, x, t) + def get_spatial_grid(self): for lib_k in self.libraries_: spatial_grid = lib_k.get_spatial_grid() diff --git a/pysindy/feature_library/parameterized_library.py b/pysindy/feature_library/parameterized_library.py index ce4208cd2..1f859e0b8 100644 --- a/pysindy/feature_library/parameterized_library.py +++ b/pysindy/feature_library/parameterized_library.py @@ -113,9 +113,7 @@ def calc_trajectory(self, diff_method, x, t): constants_final = np.ones(self.libraries_[0].K) for k in range(self.libraries_[0].K): constants_final[k] = np.sum(self.libraries_[0].fullweights0[k]) - return ( - self.libraries_[0].calc_trajectory(diff_method, x, t) - * constants_final[:, np.newaxis] - ) + x, x_int = self.libraries_[0].calc_trajectory(diff_method, x, t) + return x, x_int * constants_final[:, np.newaxis] else: return self.libraries_[0].calc_trajectory(diff_method, x, t)