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

Fix FutureWarning by setting rcond=None in np.linalg.lstsq calls #54

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/pykoopman/analytics/_ms_pd21.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@ def __init__(
:, self.small_to_large_error_eigen_index[:k]
]
sparse_measurement_matrix = np.linalg.lstsq(
eigenfunction_evaluated_on_traj_top_k, validate_data
eigenfunction_evaluated_on_traj_top_k, validate_data,
rcond=None
)[0]
residual = (
eigenfunction_evaluated_on_traj_top_k @ sparse_measurement_matrix
Expand Down Expand Up @@ -301,7 +302,7 @@ def sweep_among_best_L_modes(
bool_non_zero = np.linalg.norm(coefs_enet_comp[:, :, i_alpha], axis=0) > 0
phi_tilde_scaled_reduced = phi_tilde_scaled[:, bool_non_zero]
coef_enet_comp_reduced_i_alpha = np.linalg.lstsq(
phi_tilde_scaled_reduced, X
phi_tilde_scaled_reduced, X, rcond=None
)[0]
coefs_enet_comp[
:, bool_non_zero, i_alpha
Expand Down
2 changes: 1 addition & 1 deletion src/pykoopman/analytics/_pruned_koopman.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def fit(self, x):

# pruned V
selected_eigenphi = self.psi(x.T).T
result = np.linalg.lstsq(selected_eigenphi, x)
result = np.linalg.lstsq(selected_eigenphi, x, rcond=None)
# print('refit residual = {}'.format(result[1]))
self.W_ = result[0].T

Expand Down
2 changes: 1 addition & 1 deletion src/pykoopman/observables/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ def fit(self, X, y=None):
].measurement_matrix_
else:
g = self.transform(X)
tmp = np.linalg.lstsq(g, X)[0].T
tmp = np.linalg.lstsq(g, X, rcond=None)[0].T
assert tmp.shape == self.measurement_matrix_.shape
self.measurement_matrix_ = tmp

Expand Down
2 changes: 1 addition & 1 deletion src/pykoopman/observables/_radial_basis_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def fit(self, x, y=None):

xlift = self._rbf_lifting(x)
# self.measurement_matrix_ = x.T @ np.linalg.pinv(xlift.T)
self.measurement_matrix_ = np.linalg.lstsq(xlift, x)[0].T
self.measurement_matrix_ = np.linalg.lstsq(xlift, x, rcond=None)[0].T

return self

Expand Down
2 changes: 1 addition & 1 deletion src/pykoopman/observables/_random_fourier_features.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def fit(self, x, y=None):
# z[:,:x.shape[1]] = x
# z[:,x.shape[1]:] = self._rff_lifting(x)
z = self._rff_lifting(x)
self.measurement_matrix_ = np.linalg.lstsq(z, x)[0].T
self.measurement_matrix_ = np.linalg.lstsq(z, x, rcond=None)[0].T

return self

Expand Down
2 changes: 1 addition & 1 deletion src/pykoopman/regression/_edmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def fit(self, x, y=None, dt=None):

# X1, X2 are row-wise data, so there is a transpose in the end.
self._coef_ = U.conj().T @ X2T @ V @ np.diag(np.reciprocal(s))
# self._coef_ = np.linalg.lstsq(X1, X2)[0].T # [0:Nlift, 0:Nlift]
# self._coef_ = np.linalg.lstsq(X1, X2, rcond=None)[0].T # [0:Nlift, 0:Nlift]
self._state_matrix_ = self._coef_
[self._eigenvalues_, self._eigenvectors_] = scipy.linalg.eig(self.state_matrix_)
# self._ur = np.eye(self.n_input_features_)
Expand Down