Skip to content

Commit 42bbb84

Browse files
committed
small printing fix to TimedBlock, bug note for continuous regselect
1 parent 57278a3 commit 42bbb84

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/opinf/roms/_base.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -728,6 +728,13 @@ def training_error(reg_params):
728728
error += post.Lp_error(Q, solution_train, t[:trainsize])[1]
729729
return error / len(states)
730730

731+
# BUG: training states may not align with the first `trainsize`
732+
# entries of `solution` because `Q` (from `states`) may have been
733+
# cropped by the time derivative estimator.
734+
# This is not an issue for fully discrete models.
735+
# Potential fix: implement some kind of mask in ddt_estimator and
736+
# replace `solution[:, :trainsize]` -> `solution[:, the_ddt_mask]`.
737+
731738
best_regularization = utils.gridsearch(
732739
training_error,
733740
candidates,

src/opinf/utils/_timer.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,12 @@ def __init__(
102102
timelimit: int = None,
103103
):
104104
"""Store print/log message."""
105+
if not message:
106+
message = ""
105107
self.__original_stdout = sys.stdout
106108
self.__new_buffer = None
107109
self.__front = "\n" if message.endswith("\n") else ""
108-
self.message = message.rstrip()
110+
self.message = "" if message is None else message.rstrip()
109111
self.__back = "\n" if "\r" not in message else ""
110112
if timelimit is not None:
111113
timelimit = max(int(timelimit), 1)
@@ -151,7 +153,8 @@ def __exit__(self, exc_type, exc_value, exc_traceback):
151153
elapsed = self._toc - self._tic
152154
if exc_type: # Report an exception if present.
153155
if self.timelimit is not None and exc_type is TimeoutError:
154-
print(flush=True)
156+
if self.message:
157+
print(flush=True)
155158
report = f"TIMED OUT after {elapsed:.2f} s."
156159
logging.info(f"{self.message}...{report}")
157160
if self.rebuffer:

0 commit comments

Comments
 (0)