-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Simplify common unit if label has just one unit (#338)
If we don't do this, it's a weird situation: we end up with a `CommonUnit<A, B, ...>` type, whose _label_ is just the label for a single _simple_ unit `X`... which is quantity-equivalent to `CommonUnit<A, B, ...>`. This means that when we print it, it will _look just like it is_ `X`, and people might get confused. With this PR, when we're in this situation, we simply make `CommonUnitT<A, B, ...>` (note the `T`, i.e., "compute the common unit") return `X` itself! To do this, we _could_ try to piggyback on the label definition. I found that way introduces some really confusing circular dependencies. I find it is much simpler to simply count the _distinct unscaled units_ in the common unit, and do the simplification exactly when we get down to only one. Helps #105.
- Loading branch information
Showing
2 changed files
with
70 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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