You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using recommendations from the ruff linter and formatter extension in VS Code, cleaning various issues in Demag Gui. Highlights include:
Partially cleaning and re-organizing imports, removing unused imports, cleaning some duplicates.
Fixing style of equality comparisons (i.e., == to is, etc.), type comparisons.
Went from 258 "problems" to 125. Most of what is left is variable assignments, which are a little touchy, bare except statements, and some import confusion (mostly from star imports, I think). But, a little at a time and that done well.
Reviewed the diff and did a smoke test opening a working data directory and
stepping through the GUI — everything behaves as expected.
The changes are carefully largely mechanical (== None → is None, type(x) == Y → type(x) is Y, == True → truthy, unused import removal, DataFrame/Series → pd.DataFrame/pd.Series) and I verified each of
the removed imports is no longer referenced in the file. Two changes are
arguably latent bug fixes: scipy.mean → mean (scipy isn't actually
imported at the top level and scipy.mean was removed in SciPy 2.0), and math.isnan → np.isnan (math isn't imported either).
The only behavioral tightening is the bare except: → except FileNotFoundError:
changes in get_data_info and update_pmag_tables. My smoke test used a
complete working directory so it didn't exercise those paths — worth noting
that read_magic_file and pmag.magic_read both handle missing files
internally and return [] rather than raising, so the except FileNotFoundError:
branches will effectively never fire regardless. If anything, it's better
to let unexpected exceptions propagate than silently swallow them, so the
tightening is a net positive.
A couple of small follow-up opportunities spotted while reading:
Lines 3636 and 3652 have type(tmin) is str or type(tmin) is str and tmin != '' —
the two conditions are identical, so the whole expression reduces to type(tmin) is str.
The file has both import numpy as np and from numpy import vstack, sqrt, arange, array, mean, nan, which invites inconsistent np.array vs array usage. Worth consolidating to one style in a separate PR.
A leftover #DEBUG print in add_fit (line 2586) that probably makes sense to look into and clean-up.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Using recommendations from the
rufflinter and formatter extension in VS Code, cleaning various issues in Demag Gui. Highlights include:Partially cleaning and re-organizing imports, removing unused imports, cleaning some duplicates.
Fixing style of equality comparisons (i.e.,
==tois, etc.), type comparisons.Went from 258 "problems" to 125. Most of what is left is variable assignments, which are a little touchy, bare
exceptstatements, and some import confusion (mostly from star imports, I think). But, a little at a time and that done well.