-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Overwrite x_axis only during fitting #77 #90
Conversation
muspinsim/simconfig.py
Outdated
if xname == "t": | ||
# Special case | ||
self._time_N = len(self._x_range[xname]) | ||
if self._x_range[xname] is None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if self._x_range[xname] is None: | |
if self._x_range.get(xname) is None: |
if the xname
key is not in the _x_range
dict, it will return KeyError
rather returning None
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The behaviour's a bit counter-intuitive here I think. We initialize to have a value of None
in the dict
:
muspinsim/muspinsim/simconfig.py
Line 117 in 08a3430
self._x_range[x] = None |
Which may get assigned an actual range (or not).
Then xname
is taken directly from the dict
, so must be present as a key:
muspinsim/muspinsim/simconfig.py
Line 186 in 08a3430
xname = list(self._x_range.keys())[0] |
I'm naturally wary of changing things which aren't needed for the issue, to keep scope limited and for fear of breaking something accidentally. So while I think a lot of this could be rewritten to be clearer, at the time I left the lines I didn't need to change as is (e.g 186). But that means the new line 189 is confusing.
To make what's actually happening clearer, propose changing keys()
to items()
on 186 and assigning/using the value for the first key/value pair directly.
Codecov Report
@@ Coverage Diff @@
## main #90 +/- ##
=======================================
Coverage ? 86.40%
=======================================
Files ? 23
Lines ? 2795
Branches ? 538
=======================================
Hits ? 2415
Misses ? 248
Partials ? 132 |
Adds handling for
x_axis
andx_axis_values
for fitting experiments. The WARNING for overwriting values has been downgraded to INFO, and will only be printed when the x_axis is set by the user (this checks the value forx_axis
and also if the default value of time is altered without explicitly changingx_axis
). If no values given, we use the experimental data for the final evaluation of the function, and saving the .dat file.If however the user specifies values, then these will be used only for the final .dat evaluation.
Justification
Considered interpolation/overlapping of ranges provided by the user, but decided that this was not the right approach as the experimental data contains all our information, and we will either be upscaling (implying a precision we do not possess) or downscaling (discarding information prior to the fit). Neither of these is a good. Instead, we should use (all) the information we have for the fit, which defines our variables - then if the user wants to evaluate this on a range which differs from the experimental range, that is perfectly acceptable - and would be no different from if they just started a new experiment with the values that came out of the fit and a new x_axis. This approach is also a lot simpler than having to worry about how to interpolate arbitrarily.
TODO
#77