Only use automatic unit conversion for simple units (not compound units) #4583
+47
−3
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.
Description
This pr removes code attempting to find the best units for the given user input/limits. As noted in #4063 this code (always?) leads to incorrect units for compound units, e.g.u"m/s"
. It also seems like a difficult problem to determine how to distribute prefixes or if they are even wanted.After a brief discussion with Simon I changed this pr to only affect compound units, i.e. units like
u"m/s"
. These units now no longer try to find an optimal prefix, which led to them becoming wrong. They instead get set once and then stay what they are. Simple units likeu"m"
continue to optimize their prefix.The reason for the change in direction is that you can already turn off the prefix conversions by creating a UnitfulConversion with the unit you want. E.g.
Results:
(1:10) .* u"nm/m^2
results in unitu"nm/m^2
1e6 u"nm/m^2"
keepsu"nm/m^2"
1200u"nm/m^2 "
and the second1.3u"µm/m^2"
,u"nm/m^2"
will still be used.I also added some extra code to convert a unit string with exponents to rich text with superscript.
Added refimg:
Closes #3891
Fixes #4063
Type of change
Delete options that do not apply:
Checklist