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.
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
pint-xarray blog post #251
pint-xarray blog post #251
Changes from 19 commits
6d26cc3
d9596c8
772c427
7ca85ce
d5d3017
f35ff96
829ae25
c47a615
e035caa
d953fb9
684b465
5baef32
64cd10b
baf2948
ba9bcf2
1e32d37
844096b
2aedbac
bfeb716
3d02b83
a1cde77
8d37219
3f358b9
0758dca
8df4609
7c52770
3f0e319
c048904
7b4cfeb
bf63bc8
7179b6c
37cd971
99c11cc
3aa009c
f9bb62c
1b2b832
061aa8b
0283833
7144eb0
94dbe36
69f6035
587e16c
d8d6578
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
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 feels a bit strange to me:
pint
will happily do the computation, converting units along the way to make sure the results stay correct. At the end of the computation, all we have to do is ask to get the desired units. For this particular example:For functions that don't support units, we'd either write a wrapper that does the conversion (no need to check if the units already are what we need) and strips the units, then adds units to the result, or use
expects
once that's ready.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.
Feel free to change the details of this example. The point just needs to be that unit-aware code would have prevented the error that befell the JPL mission. Exactly whether the code raises an error, converts, or whatever doesn't really matter for the pedagogical purposes of this blog post.
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 just noticed that with that it becomes essentially the same as 3 (unit conversion). Do you want to replace / extend that section? 4 should then be a section on wrapping library functions.
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.
Okay fair point that then they would be the same. Instead consider:
The point of section 3 is showing that you can do unit conversions, the point of section 4 is showing that you can require specific units for finicky library functions. The easiest way to demonstrate that you can require specific units on an input is to raise an error. We don't need to over-think it beyond that.
Therefore I now think that this would be fine for the purposes of this blog post
It gets the point across.
Yes in practice you would probably do this a bit differently, but that's what our pint-xarray docs should demonstrate.
(Change here)
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 feels a bit strange to have a blog post advertising
pint
andpint-xarray
using unidiomatic code... I don't expect this blog post to become as often read as the one onkerchunk
, but that had to be updated because people kept using the code from the blog instead of from the documentation.What if, instead of presenting it as a new feature, we'd show it as an example using 1 to 3? For unit-aware functions, that's what we'd actually end up doing.
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.
Okay - what would that look like?
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 example would be the one from #251 (comment), but we'd describe it as something like:
I'm sure we can improve the wording, though.
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.
@keewis I tried implementing your suggestion in 0283833, not quite sure if that's what you meant though.