-
-
Notifications
You must be signed in to change notification settings - Fork 41
Add support for non-integer dimensions in Unit API #257
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -76,7 +76,7 @@ public interface Dimension { | |
| * power to raise this {@code Dimension} to. | ||
| * @return <code>this<sup>n</sup></code> | ||
| */ | ||
| Dimension pow(int n); | ||
| Dimension pow(double n); | ||
|
|
||
| /** | ||
| * Returns the given root of this dimension. | ||
|
|
@@ -87,13 +87,13 @@ public interface Dimension { | |
| * @throws ArithmeticException | ||
| * if {@code n == 0}. | ||
| */ | ||
| Dimension root(int n); | ||
| Dimension root(double n); | ||
|
|
||
| /** | ||
| * Returns the (fundamental) base dimensions and their exponent whose product is this dimension, or {@code null} if this dimension is a base | ||
| * dimension. | ||
| * | ||
| * @return the mapping between the fundamental dimensions and their exponent. | ||
| */ | ||
| Map<? extends Dimension, Integer> getBaseDimensions(); | ||
| Map<? extends Dimension, Double> getBaseDimensions(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The current changes (as of January 20th) are incompatible with the current API. Furthermore, while non-integer dimensions may be needed in some domains, it is also a complication for the majority of users. I'm in favour of supporting advanced uses, but the challenge is to find a way to do that while preserving ease-of-use for the majority of users. Unless we accept to break the API, this method cannot be changed. We could add a new method with a different name and declare that the old method throws Before to introduce non-integer dimensions support in the API, I would like to see a list of use cases. Two of them have been mentioned in #256, but I would like to see more examples with more details.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The JavaDoc says "...dimensions and their exponent". Is there even such thing as a non-integer exponent? |
||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
pow(int)method cannot be removed (this comment applies also to all other similar changes in this pull-request). Thepow(double)method could be added beside the existingpow(int)as method overloading, but see the comment below about whether thedoubletype is really appropriate.In the common case where the non-integer dimensions are fractions, we don't really need this new API. The same effect could be obtained by
pow(numerator).root(denominator). Not all implementations may accept that, but not all implementations would accept the newpow(double)method neither.