Skip to content

Commit 5d92ab5

Browse files
committed
Restored old parameter behavior
1 parent fd0955a commit 5d92ab5

File tree

1 file changed

+19
-14
lines changed

1 file changed

+19
-14
lines changed

pydmd/bopdmd.py

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,9 @@ class BOPDMDOperator(DMDOperator):
8484
Use arguments less than or equal to zero for no warning condition.
8585
:type bag_warning: int
8686
:param bag_maxfail: Number of consecutive non-converged trials of BOP-DMD
87-
at which to terminate the fit. Set this parameter to infinity for no
88-
stopping condition. Set to a non-positive value to simply use the
89-
results of the non-converged trials. This is the default behavior.
90-
:type bag_maxfail: int or float
87+
at which to terminate the fit. Default is 100. Use arguments less than
88+
or equal to zero for no stopping condition.
89+
:type bag_maxfail: int
9190
:param init_lambda: Initial value used for the regularization parameter in
9291
the Levenberg method. Default is 1.0.
9392
Note: Larger lambda values make the method more like gradient descent.
@@ -318,7 +317,6 @@ def _push_eigenvalues(self, eigenvalues):
318317
b = 0.5 * (abs(eig_1.imag) + abs(eig_2.imag))
319318
new_eigs[ind_1] = a + 1j * (b * np.sign(eig_1.imag))
320319
new_eigs[ind_2] = a + 1j * (b * np.sign(eig_2.imag))
321-
# ind_1 and ind_2 have now been paired.
322320

323321
eigenvalues = np.copy(new_eigs)
324322

@@ -860,7 +858,7 @@ def compute_operator(self, H, t):
860858

861859
if (
862860
not runtime_warning_given
863-
and num_consecutive_fails >= self._bag_warning
861+
and num_consecutive_fails == self._bag_warning
864862
):
865863
msg = (
866864
"{} many trials without convergence. "
@@ -870,7 +868,7 @@ def compute_operator(self, H, t):
870868
print(msg.format(num_consecutive_fails))
871869
runtime_warning_given = True
872870

873-
if not keep_bad_bags and num_consecutive_fails >= self._bag_maxfail:
871+
if not keep_bad_bags and num_consecutive_fails == self._bag_maxfail:
874872
msg = (
875873
"Terminating the bagging routine due to "
876874
"{} many trials without convergence."
@@ -982,10 +980,9 @@ class BOPDMD(DMDBase):
982980
Use arguments less than or equal to zero for no warning condition.
983981
:type bag_warning: int
984982
:param bag_maxfail: Number of consecutive non-converged trials of BOP-DMD
985-
at which to terminate the fit. Set this parameter to infinity for no
986-
stopping condition. Set to a non-positive value to simply use the
987-
results of the non-converged trials. This is the default behavior.
988-
:type bag_maxfail: int or float
983+
at which to terminate the fit. Default is 100. Use arguments less than
984+
or equal to zero for no stopping condition.
985+
:type bag_maxfail: int
989986
:param varpro_opts_dict: Dictionary containing the desired parameter values
990987
for variable projection. The following parameters may be specified:
991988
`init_lambda`, `maxlam`, `lamup`, `use_levmarq`, `maxiter`, `tol`,
@@ -1009,7 +1006,7 @@ def __init__(
10091006
eig_constraints=None,
10101007
mode_prox=None,
10111008
bag_warning=100,
1012-
bag_maxfail=0,
1009+
bag_maxfail=100,
10131010
varpro_opts_dict=None,
10141011
):
10151012
self._svd_rank = svd_rank
@@ -1021,6 +1018,16 @@ def __init__(
10211018
self._trial_size = trial_size
10221019
self._eig_sort = eig_sort
10231020

1021+
if not isinstance(bag_warning, int) or not isinstance(bag_maxfail, int):
1022+
msg = (
1023+
"bag_warning and bag_maxfail must be integers. "
1024+
"Please use a non-positive integer if no warning "
1025+
"or stopping condition is desired."
1026+
)
1027+
raise TypeError(msg)
1028+
self._bag_warning = bag_warning
1029+
self._bag_maxfail = bag_maxfail
1030+
10241031
if varpro_opts_dict is None:
10251032
self._varpro_opts_dict = {}
10261033
elif not isinstance(varpro_opts_dict, dict):
@@ -1037,8 +1044,6 @@ def __init__(
10371044
self._check_eig_constraints(eig_constraints)
10381045
self._eig_constraints = eig_constraints
10391046
self._mode_prox = mode_prox
1040-
self._bag_warning = bag_warning
1041-
self._bag_maxfail = bag_maxfail
10421047

10431048
self._snapshots_holder = None
10441049
self._time = None

0 commit comments

Comments
 (0)