Remove exec magic from sasdata.quantities.units#204
Open
rprospero wants to merge 979 commits into
Open
Conversation
To replace the old metadata loading.
Not need anymore.
This is clearer than ArbitraryUnit, which might be confused for uncalibrated scattering data.
Current the only invalid characters are Space, /, and ^. I've also refactored the argument parsing to remove duplication between the numerator and denominator.
172 unrecognized units (Again)
Adds linear algebra operations
* Simplify quotes in table building * Dynamically create modules * Descriptive comments * Ruff formatting * [pre-commit.ci lite] apply automatic fixes for ruff linting errors * Tell windows that code is in utf8 * Removes unused module --------- Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com> Co-authored-by: PaulSharp <44529197+DrPaulSharp@users.noreply.github.com>
10a93d9 to
e732111
Compare
There was a problem hiding this comment.
No quality gates enabled for this code.
See analysis details in CodeScene
Quality Gate Profile: Custom Configuration
Install CodeScene MCP: safeguard and uplift AI-generated code. Catch issues early with our IDE extension and CLI tool.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
My previous work on refactoring out the
unitsmodule depended heavily on writing a module at run time and then running the code throughexec. While this removed the need to keep_build_tables.pyandunits.pyin sync, it was also very ugly code that could be very frightening to edit.This PR produces a modified version that edits an exiting
unitsmodule instead of trying to write a new one from scratch.execfid.write(f" '{name}': {name}")pattern obscures the actual value in the dictionary).execversion would build the units module the moment someone importedsasdata.quantitiesinstead ofsasdata.quantities.units)Again providing guidance:
units.pywas just moved directly from__init__.pythiswas chosen to match convention from the Javascript community. I had also considered usingself, which is more Pythonic, but had the potential to be confusing, since it is usually attached to a class method.units.py. However, values are defined directly and moved into the module throughsetattr.