-
Notifications
You must be signed in to change notification settings - Fork 280
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
[ENH] Access output in timeseries by its time or redshift #4717
Conversation
Quick input:
|
Not sure I completely agree with @neutrinoceros about limiting the flexibility. The question the other day about flash datasets with particles would suggest there may be times when we don't know the attribute someone will be looking for. Can you make it use "Price Is Right" rules? i.e., closest-without-going-over? |
I am not sure I understand what you mean by "Price Is Right" rule. Anyways, in its current state, it is already possible to query a dataset by attribute, but the method is hidden ( Let me know what you think! I can always strip the leading |
I mean, if I want the closet to z=1 but definitely on one side or the
other, for instance. So having 0.99 take precedence over 1.01. (or even
0.95 over 1.001)
…On Wed, Nov 1, 2023, 12:17 PM Corentin Cadiou ***@***.***> wrote:
I am not sure I understand what you mean by "Price Is Right" rule.
Anyways, in its current state, it is already possible to query a dataset by
attribute, but the method is hidden (_get_by_attribute), because “with
great power comes great responsibility”.
Let me know what you think! I can always strip the leading _ to make it
more user-facing, with an obvious comment in the docstring warning against
misuses?
—
Reply to this email directly, view it on GitHub
<#4717 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAVXOYJQUYAJMHRHRFESSDYCJ7ZHAVCNFSM6AAAAAA6S75QZ2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTOOBZGM2DKNZZGU>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Oh I see, yes, I'll implement a |
I have nothing against that "the price is right rule", but I'd like to point out that left-to-right reading order isn't culturally neutral. I'd prefer that the interface be more inclusive. |
@neutrinoceros I've implemented a "smaller", "larger" or "nearest" switch so that there is no ambiguity arising from left-to-right vs. right-to-left reading order. Thanks for pointing it out! |
I think the new language is better. That being said, it's not necessarily true that RTL languages have different number line concepts: There's also some evidence that filmmaking conventions (such as progression from the left side of the screen to the right) are also commonly used outside of left-to-right languages. I will say that with redshift the entire situation is odd because the numeric progression is reversed from temporal progression. And I did choose redshift as my example... So I guess this is on me! |
@yt-fido test this please |
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 functionality is useful and the implementation is sound ! I have a couple questions and suggestions (mostly about type annotations)
# This will fail if no output is found within 100 Myr | ||
ds = ts.get_by_time((3, "Gyr"), tolerance=(100, "Myr")) | ||
# Get the output at the time right before and after 3 Gyr | ||
ds_before = ts.get_by_time((3, "Gyr"), side="smaller") |
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 still think the name of the argument could be clearer than side
. What about prefer="smaller"
?
@yt-fido test this please |
1 similar comment
@yt-fido test this please |
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.
Looks great!
I think the case of choosing a value exactly between two datasets needs to either explicitly handled or have its behavior defined in the docstring (see comments), but otherwise this is very useful!
pre-commit.ci autofix |
@yt-fido test this please |
@yt-fido Test this please |
Hey @cphyc , you still hoping for this to go into 4.4? I'd still like some clarification on expected behavior when you choose a time exactly between two points while setting the |
Co-authored-by: Clément Robert <[email protected]>
for more information, see https://pre-commit.ci
Co-authored-by: Chris Havlin <[email protected]>
@chrishavlin should be good now :) I am now testing the behaviour when exactly halfway which is working as expected as far as I could tell. |
great! thanks, @cphyc ! |
@neutrinoceros I think all your comments have been addressed, mind giving this a quick re-review when you have a moment? |
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.
Thanks for the ping ! Indeed my comments were all addressed !
Last thing before we merge this: @cphyc, can you re-title the PR to something a bit more descriptive that I can include directly in release notes ? |
Done! |
PR Summary
This provides the ability to quickly find the dataset that has the closest value to a given one (e.g. time or redshift). Example
PR Checklist