-
-
Notifications
You must be signed in to change notification settings - Fork 42
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
tec.units.indriya.quantity.QuantityDimension equals() bug #207
Comments
Thanks for your observation. It seems at least related to #33 and there is also a ticket in the API project: unitsofmeasurement/unit-api#89. |
Its not clear to me, how to reproduce the issue. |
Code Review: Javadoc from
So why is RI deviating from this? According to the spec, this predicate should be returned unconditionally, right?
|
Suggested improvement: re-implement private final boolean internalIsCompatible(Unit<?> that, boolean checkEquals) {
if (checkEquals) {
if (this == that || this.equals(that))
return true;
} else {
if (this == that)
return true;
}
if (!(that instanceof AbstractUnit))
return false;
Dimension thisDimension = this.getDimension();
Dimension thatDimension = that.getDimension();
return thisDimension.equals(thatDimension);
// if (thisDimension.equals(thatDimension))
// return true;
// DimensionalModel model = DimensionalModel.current(); // Use
// return model.getFundamentalDimension(thisDimension).equals(model.getFundamentalDimension(thatDimension));
} |
By this, do you mean that when you run the code that I pasted (as three standalone classes) that you get different results? Or do you mean that it's hard to replicate the problem in a single standalone test case? I'm curious if this is something particular about my environment. |
I failed to reproduce the issue trying:
However, I'd love to know what's causing this. |
Also I'm curious, whether you do have the same issue, if you try a different method (for the dimension equality check) as shown in the second test in [1]. |
When I run your test case, both dimensionsShouldBeEqual() and unitsShouldBeCompatible() are failing. For some reason, FuelEconomy.MILES_PER_GALLON.getDimension() is returning a dimension of [L]/null. Are these test cases completing successfully for you? |
Surefire Tests seem to fail as well. I guess, bumping JUnit versions earlier this day was a bad idea on my end. I'm reverting this commit ... |
... after having reverted my JUnit 'version bump' Surefire Tests do succeed again. |
I think the issue might be that I'm working from the current maven version 2.0-EDR (should have mentioned this in my first post), while I'm guessing you're working from the current snapshot which has probably fixed a few of the problems I'm finding. Are there any snapshots on Maven, or do I need to just clone all the GitHub repositories into my workspace? |
I found out how to get the snapshots by pointing to https://oss.jfrog.org/artifactory/oss-snapshot-local. This bug has been fixed in the current snapshot. I am now passing the test case that you posted. Thanks! |
I wrote some fuel efficiency units, and discovered a bug in dimension comparison:
Result:
FC dim: [L]²
FE dim: 1/[L]²
FE inv dim: [L]²
fcdim == feInv ? false
And very strangely, if you switch out the comments on the fcDim variable, here is the output:
FC dim: [L]²
FE dim: 1/[L]²
FE inv dim: [L]²
fcdim == feInv ? true
Why am I getting a different result depending on where I declare the unit? Can anybody else replicate this?
The text was updated successfully, but these errors were encountered: