-
Notifications
You must be signed in to change notification settings - Fork 103
Glitch tweak #1867
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
Glitch tweak #1867
Conversation
Please add a CHANGELOG entry. |
src/pint/models/glitch.py
Outdated
if not hasattr(self, param + "%d" % idx): | ||
if not hasattr(self, param + str(idx)): | ||
param0 = getattr(self, f"{param}1") | ||
self.add_param(param0.new_param(idx)) | ||
getattr(self, param + "%d" % idx).value = 0.0 | ||
getattr(self, param + str(idx)).value = 0.0 | ||
self.register_deriv_funcs( | ||
getattr(self, f"d_phase_d_{param[:-1]}"), param + "%d" % idx | ||
getattr(self, f"d_phase_d_{param[:-1]}"), param + str(idx) | ||
) |
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.
It will be better to use fstring instead of the + operator here since that is the style we had decided to prefer.
I'm never sure where to draw the line but... is it worth noting relatively minor code cleanup in the CHANGELOG? It's not something, imo, that users of new versions really need to be aware of. |
I think it's good for posterity, in case someone wonders in the future when/how/why some change was made. |
I noticed a bunch of nearly-duplicate code in the Glitch derivatives, so I pushed that into the "deriv_prep" function. Otherwise, I switched to f-strings, cleaned up the math and syntax in a few places, and added some missing tests for sanity checks on models.
(E.g., the code attempts to test for a missing GLEP, but there was no test coverage for that. The code only checked for whether or not a GLEP was present, but it always is! It's value is set to None, though, so the code now checks for that and the test covers it.