Simulation and Evaluation code inspection#124
Conversation
|
|
||
| :param markersize: marker size of noisy observations | ||
| :type markersize: int, optional | ||
| :param np.array[float] x: array of noisy data |
pynumdiff/utils/evaluate.py
Outdated
| def __rms_error__(a, e): | ||
| """ | ||
| Calculate rms error | ||
| def _rms_error(a, e): |
There was a problem hiding this comment.
Calls to this should maybe be replaced with numpy.linalg.norm.
…will no longer work in the 2a notebook
| "source": [ | ||
| "import os\n", | ||
| "import sys\n", | ||
| "import time\n", |
There was a problem hiding this comment.
unused imports
| Import useful functions from the optimize module | ||
| """ | ||
|
|
||
| import logging as _logging |
There was a problem hiding this comment.
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): |
There was a problem hiding this comment.
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], |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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.
|
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. |
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.