-
Notifications
You must be signed in to change notification settings - Fork 393
✨ Add Equals() to IQuantity interfaces #1215
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Codecov ReportPatch coverage has no change and project coverage change:
Additional details and impacted files@@ Coverage Diff @@
## master #1215 +/- ##
=======================================
- Coverage 85% 84% -2%
=======================================
Files 328 328
Lines 33513 34227 +714
=======================================
+ Hits 28800 28805 +5
- Misses 4713 5422 +709
☔ View full report in Codecov by Sentry. |
@tmilnthorp Would like your eyes on this whenever you have time. |
f75cc0c
to
72fa8af
Compare
I have the same comment as before |
I must have missed it, what comment? |
Perhaps instead of using the bool Equals(TQuantity other, TQuantity tolerance); Or if you want asymmetric bounds: bool IsBetween(TQuantity other, TQuantity min, TQuantity max); This gives a lot of flexibility to use the same method for handling both situations (as unit test frameworks do):
This also lets us remove the |
@angularsen What did you decide to do about this PR? Is it going to be merged at some moment or? |
This slipped off my radar honestly. @tmilnthorp Hm, yes, I like this contract better. Providing the error margin as a quantity.
So, I propose:
@dmytro-gokun How does this work for you? |
@angularsen sounds good to me. Users can also use |
@angularsen I just need this method (Equals/IsBetween/whatever) be on a some sort of a generic interface, so that it is possible to call in generic code. The rest is not important for my scenario |
Ref #1193 In v5, equality changed to strict equality. This meant it became more cumbersome to compare equality for `IQuantity` objects of different units, but similar value when converted to the same unit. - Add interface `IEquatableQuantity` to help compare `IQuantity` objects with a tolerance for error Merge IEquatableQuantity into IQuantity<TSelf, Unit, ValueType> interface
72fa8af
to
1e8c9c7
Compare
Ref #1193
In v5, the default equality implementation changed to strict equality and the existing methods to compare across units with a tolerance, but this was not available in
IQuantity
interfaces.Changes
Equals(IQuantity? other, IQuantity tolerance)
toIQuantity
Equals(TSelf? other, TSelf tolerance)
toIQuantity<TSelf, TUnitType, TValueType>
for strongly typed comparisonsEquals(TQuantity other, double tolerance, ComparisonType comparisonType)
method in quantity types