-
Notifications
You must be signed in to change notification settings - Fork 18
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
Additional utilities for identity functions, +
, and -
#23
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
957ec74
Add proper `one`, `zero`, and `oneunit` calls
MilesCranmer ca3f6f9
Extend `+` and `-` to regular numbers
MilesCranmer 060d147
Test new behavior of `zero`, `one`, `oneunit`, `+`, `-`
MilesCranmer 5bcce75
Remove `::Number` restrictions on math
MilesCranmer 0257746
Clean up `zero` and `oneunit`
MilesCranmer 3300a00
Fix behavior of `one(::Quantity)`
MilesCranmer 6538750
Ensure dimensionless when using `one(::Quantity)`
MilesCranmer bada5cf
Add `isless` and `==` for numbers
MilesCranmer 2412d55
Merge branch 'units' into additional-utils
MilesCranmer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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.
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.
It seems that both Dimensions and Quantity are given many number-like methods. Might it be simpler to only do this for Quantity, and use
Quantity(true, Dimension(...))
in place of a naked Dimension?Or some special One if
true
is too narrow. But I'm not so sure how much it's intended to supportQuantity([1,2,3], time=1)
. It would seem simplest to me to restrict Quantity to real numbers, but maybe you have other plans.Actually, when would methods like
*(::Number, ::Dimension)
be used at all? #22 definesconst m = Quantity(1.0, length=1)
. It could instead use this method and definem::Dimension
, but instead seems to focus on numbers.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.
I'm not sure if this is possible because
Quantity.value
andDimensions
are different number systems:.value
is a regular number, whileDimensions.(field)
are powers. So, for example,:*(::Dimensions, ::Dimensions)
actually adds fields, rather than multiplies them.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.
This is just a convenience thing that felt more intuitive than using
Quantity()
directly. For example:which puts
y
in the units ofx
.You could do
Quantity(0.5, dimension(x))
, but I think after #22 merges, theQuantity()
constructor will be used less often, so this multiplication strategy seems useful. Wdyt?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.
(Sorry, just realized all my messages were listed as pending because they are submitted as a batch when I hit "Review changes"...)