Skip to content

Commit 1329713

Browse files
committed
Put bag_warning back in
1 parent 762863f commit 1329713

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

pydmd/bopdmd.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ class BOPDMDOperator(DMDOperator):
7979
routine after the modes have been projected back to the space of the
8080
full input data.
8181
:type mode_prox: function
82+
:param bag_warning: Number of consecutive non-converged trials of BOP-DMD
83+
at which to produce a warning message for the user. Default is 100.
84+
Use arguments less than or equal to zero for no warning condition.
85+
:type bag_warning: int
8286
:param bag_maxfail: Number of consecutive non-converged trials of BOP-DMD
8387
at which to terminate the fit. Set this parameter to infinity for no
8488
stopping condition. Set to a non-positive value to simply use the
@@ -134,6 +138,7 @@ def __init__(
134138
eig_sort,
135139
eig_constraints,
136140
mode_prox,
141+
bag_warning,
137142
bag_maxfail,
138143
init_lambda=1.0,
139144
maxlam=52,
@@ -154,6 +159,7 @@ def __init__(
154159
self._eig_sort = eig_sort
155160
self._eig_constraints = eig_constraints
156161
self._mode_prox = mode_prox
162+
self._bag_warning = bag_warning
157163
self._bag_maxfail = bag_maxfail
158164
self._varpro_opts = [
159165
init_lambda,
@@ -852,13 +858,13 @@ def compute_operator(self, H, t):
852858
else:
853859
num_consecutive_fails += 1
854860

855-
if not runtime_warning_given and num_consecutive_fails == 100:
861+
if not runtime_warning_given and num_consecutive_fails >= self._bag_warning:
856862
msg = (
857-
"100 trials without convergence. "
863+
"{} many trials without convergence. "
858864
"Consider loosening the tol requirements "
859865
"of the variable projection routine."
860866
)
861-
warnings.warn(msg)
867+
print(msg.format(num_consecutive_fails))
862868
runtime_warning_given = True
863869

864870
if not keep_bad_bags and num_consecutive_fails >= self._bag_maxfail:
@@ -968,6 +974,10 @@ class BOPDMD(DMDBase):
968974
routine after the modes have been projected back to the space of the
969975
full input data.
970976
:type mode_prox: function
977+
:param bag_warning: Number of consecutive non-converged trials of BOP-DMD
978+
at which to produce a warning message for the user. Default is 100.
979+
Use arguments less than or equal to zero for no warning condition.
980+
:type bag_warning: int
971981
:param bag_maxfail: Number of consecutive non-converged trials of BOP-DMD
972982
at which to terminate the fit. Set this parameter to infinity for no
973983
stopping condition. Set to a non-positive value to simply use the
@@ -995,6 +1005,7 @@ def __init__(
9951005
eig_sort="auto",
9961006
eig_constraints=None,
9971007
mode_prox=None,
1008+
bag_warning=100,
9981009
bag_maxfail=0,
9991010
varpro_opts_dict=None,
10001011
):
@@ -1023,6 +1034,7 @@ def __init__(
10231034
self._check_eig_constraints(eig_constraints)
10241035
self._eig_constraints = eig_constraints
10251036
self._mode_prox = mode_prox
1037+
self._bag_warning = bag_warning
10261038
self._bag_maxfail = bag_maxfail
10271039

10281040
self._snapshots_holder = None
@@ -1377,6 +1389,7 @@ def fit(self, X, t):
13771389
self._eig_sort,
13781390
self._eig_constraints,
13791391
self._mode_prox,
1392+
self._bag_warning,
13801393
self._bag_maxfail,
13811394
**self._varpro_opts_dict,
13821395
)

0 commit comments

Comments
 (0)