Switched transforming prefix to standard to use the symbol instead of the name #238
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.
UPDATED
This PR is a bug fix for the features added in #237.
Problem
$μA$ , as microamps was not being processed properly, as the the unicode character μ was automatically being translated to $μA$ and $microampere$ gets transformed to $A*micro$ , instead of $microampere$ .
microas implemented in #237. SoThe Bug
In
unit_system_conversions.pyon line 8 there is a set of SI prefixes, containing ('full name', 'short name', 'base 10 definition', (alternatives as a tuple)).In
utility/physical_quantity_utilitites.pyline 237 is the code that creates all the combinations of units and prefixes, with all the alternatives, and returns four dictionaries:{'unit_short_name OR unit_alternative': 'unit_long_name'}- e.g.{'A': 'ampere', 'Ampere': 'ampere'}{ 'decaha': 'decahectare', 'muha': 'microhectare', 'microha': 'microhectare'}joulevsjoules)4.The units with various endings with the relevant prefixes (see 2)
The issue was that the prefix + short name did not have a mapping to prefix + long name, which is used for the evaluation. For example,
microAdid not have a mapping formicroampere.The Fix
utility/physical_quantity_utilitites.pyline 276 appends the mapping ofprefix + shortname:prefix + longnameto theprefixed_units` dictionary. If the prefix + short name is not already a key in the dictionary that maps short unit names to long unit names.Other changes
context/phyiscal_quantity.pytoultiltiy/physical_quantity_utilities.pyto share the preprocessing with the preview implementationevaluation_tests.py- Added a test for previewing unicode mu then evaluating there responsepreview_implementations/physical_quantity_preview.py- Implemented the preprocessing for the units added in Feature/unicode support #237 to support unicode characters in previewpreview_tests.py- Removed old todo notetests/physical_quantitiyes_evaluation_tests.py- edited test case to match the implementation. There should be no space between the prefix and the short name of the unit.utility/physical_quantity_utilities.py- The fix discussed above on line 276, and the refactored code fromcontext/physical_quantity.pymake up the rest of the changes.