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
After generally-supportive discussion in #680, I wanted to see how feasible it is to make Quantity <: Real without breaking changes. It required few specialized changes, and basically all tests aside from logarithmic and affine pass (I just didn't touch them at all).
Overall I'm pretty positive that this change can be done without modifying tests at all (aside from those that check for specific subtyping of course), so no breaking changes.
Almost no special complex-of-quantity handling was required here, and working with complex units remain convenient with the same syntax.
Let me know if something along these lines can be accepted to Unitful, after updating the remaining parts so that all tests pass (currently some are commented out).
Overall I'm pretty positive that this change can be done without modifying tests at all (aside from those that check for specific subtyping of course), so no breaking changes.
Even if all of this package’s tests pass, that would not automatically mean that this isn’t a breaking change. We also need to make sure to not break anybody else’s code.
Here is a piece of code that works right now but doesn’t after this PR:
using Quaternions, Unitful
Quaternion(1,2,3,4)u"m"
One way to fix this particular case would be to make the unitm also a real number, i.e., m would be the same as 1m. Then we could at least still multiply any number type by units as long as that number type defines multiplication with real numbers. If a number type doesn’t define multiplication by real numbers, it would still be broken.
make the unit m also a real number, i.e., m would be the same as 1m
Nice approach!
An advantage of real quantities & units would be that then you'd be able to pass unitful numbers to f(::Quaternion) (and f(::Complex) and others). Now there's no way to do that.
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.
After generally-supportive discussion in #680, I wanted to see how feasible it is to make
Quantity <: Realwithout breaking changes. It required few specialized changes, and basically all tests aside from logarithmic and affine pass (I just didn't touch them at all).Overall I'm pretty positive that this change can be done without modifying tests at all (aside from those that check for specific subtyping of course), so no breaking changes.
Almost no special complex-of-quantity handling was required here, and working with complex units remain convenient with the same syntax.
Let me know if something along these lines can be accepted to
Unitful, after updating the remaining parts so that all tests pass (currently some are commented out).