Skip to content

Conversation

@pavelkomarov
Copy link
Collaborator

This one is ongoing. As I've read through some of the code, there were some obvious things I could do, but the majority of this one lies ahead. Opening early, because I sometimes feel it's helpful to be able to look at the diff visually as I go.

@pavelkomarov pavelkomarov changed the title deduplicated unused rmse function in evaluate Optimizer things Jul 3, 2025

:param markersize: marker size of noisy observations
:type markersize: int, optional
:param np.array[float] x: array of noisy data
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just shortening docstrings per #71.

def __rms_error__(a, e):
"""
Calculate rms error
def _rms_error(a, e):
Copy link
Collaborator Author

@pavelkomarov pavelkomarov Jul 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Calls to this should maybe be replaced with numpy.linalg.norm.

"source": [
"import os\n",
"import sys\n",
"import time\n",
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unused imports

Import useful functions from the optimize module
"""

import logging as _logging
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

raising a warning instead of logging now


:param x_hat: estimated (smoothed) x
:type x_hat: np.array
def metrics(x, dt, x_hat, dxdt_hat, x_truth=None, dxdt_truth=None, padding=0):
Copy link
Collaborator Author

@pavelkomarov pavelkomarov Jul 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

padding was default removing 2.5% on either end of the data. I think default behavior should be to calculate the metric on the full data, so I've changed the default to 0. If called with None or 'auto', 2.5% automatic slicing is still available.

"""
_np.random.seed(random_seed)
timeseries_length = _np.max(x.shape)
noise = _np.random.__getattribute__(noise_type)(noise_parameters[0], noise_parameters[1],
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Passing noise_parameters[0], noise_parameters[1] only works if there are two parameters, like for normal. For poisson this wouldn't work, so I've changed this to be variable arguments with a *.

- None: dummy output

:rtype: tuple -> (np.array, np.array, np.array, None)
def sine(duration=4, noise_type='normal', noise_parameters=(0, 0.5), random_seed=1,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

timeseries_length is confusing terminology, necessitating clarification in the docstring. I've changed the name to duration to be more precise about what this thing is.

@pavelkomarov
Copy link
Collaborator Author

This one has gotten to be pretty big despite not being very consequential, just moving comments around and deduping stuff. I'm merging it, and I'll work on the optimizer some more in a subsequent PR.

@pavelkomarov pavelkomarov merged commit 15c8870 into master Jul 4, 2025
1 check passed
@pavelkomarov pavelkomarov deleted the hack-the-optimizer branch July 4, 2025 00:57
@pavelkomarov pavelkomarov changed the title Optimizer things Simulation and Evaluation code inspection Jul 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant