-
Notifications
You must be signed in to change notification settings - Fork 22
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
Smarter UHI in slices #485
Comments
I made this comment before: it is generally bad design to make objects context aware. I wrote down the alternative, which is to replace the slice object instead of making locators slice aware. The drawback of that is that the special slice syntax does not work anymore, but it is clean. I think we also agreed that we don't need slice-aware locators right now. Adding infrastructure for stuff that is not currently needed is adding unnecessary complexity. |
I forgot the argument about bh.overflow. |
In our call, the main outcome was that that locators needed to be smarter (this was @jpivarski's idea, and we all agreed on this). We came to that decision because we were discussing whether This is completely orthogonal to the other problem which I didn't even realize was causing an issue in the call - the upper limit of a slice is non-inclusive, so the meaning of a locator in the upper bin might be different than the lower bin. This is a second argument in favor of smart locators - this is valuable information that users writing locators need to be able to express all possibilities in a locator. There probably is a decision to be made here - do we want the default locators to be smart, expressing 'meaning' vs. a simple transform. Currently This is also the issue with bh.overflow - I am willing to concede and let Your new
Not if it is useful information to know where you are in a slice. The slices do not know which axis (as in, what axis number) they are operating with - that would be too much context information. But being able to tell
|
PS: I also don't want to duplicate the interface, which is why I am not proposing we add a separate "smart loc", just that we make it possible for a future user like Hist, Coffea, etc to write one. If we really want a smart loc, we should probably find some way to transition to |
That was not the main outcome for me. The main outcome was the decision to use the behavior of bh.loc that you suggested, which is simple and consistent. I never agreed to the motion that locators should be context aware.
I was confused, because I remembered that we decided a while ago that value selections should be inclusive on both ends and I expected boost-histogram to work like Boost.Histogram. You explained very well why that would be weird, and I eventually agreed. By no means did I agree to make bh.loc context aware. It is better if loc is dumb, because then its behavior is easily predictable. Things should behave consistently and interfaces should be plain. There should be no hidden modification of the behavior depending on context. I want bh.loc to behave the same way in a slice as it getitem. That's the main point we agree to the in call. |
I can include the underflow or overflow bin already by not specifying the lower or upper bound in the slice, which is perfect for me and I think also for the users. This whole discussion about |
You are just fixated on using locators and use the Python slice. The natural object to express a range is a slice-like object, not some context-aware locators inside a Python slice. Be honest, you want the short-hand slice syntax and that's your main motivation here. You could just add custom slice objects to the UHI if you wanted to. Then everyone can write slice objects with special semantics. If you insist on context-aware locators, we need another call with Jim, because I am strongly against that. I also don't see a need to add context-aware locators. The original problem is solved, one-sided slices include the corresponding overflow bins. |
Summary: |
Which needs another call, making context-aware locators available for users writing their own locators or using that context-dependence in locators provided by boost-histogram? We did talk about both on the last call. If we do another call, let's do it over a Google Doc and post the conclusions as minutes. I don't mind another conversation, but I think we're going in circles. |
Sorry, doesn't work. I took notes last time and immediately posted them: #479 (comment) explicitly to avoid issues like this, as they've happened in the past. But it didn't work. Outcome of meeting:
Originally posted by @henryiii in #479 (comment) |
Axis proxy objects passed to the UHI locators will gain
_slice_
and_slice_index_
properties that allow a UHI locator to detect the context of use. They will be optional from the locator's point of view - existing locators will continue to work.This will allow locators to detect which part of a slice they are in, allowing much more powerful locators to be written by users.
We will use this new power to fix
bh.overflow
as an endpoint of a slice.@HDembinski, on the matter of modifying
bh.loc
to avoid flow bins - You were in favor of it not hiding flow bins in slices either, @jpivarski was neutral, and I was in favor of it avoiding flow bins in slices. I'm willing to concede that now; it's easier to understand it as "the index at this point" if it uniformly includes flow bins in both cases, and matches Boost.Histogram better. As long as we have the ability to write a smart locator, I'm okay with the default one being straightforward but possibly exposing flow bins. For most users, I'm hoping they will leave of the end point for inclusive of flow, and use 0 /len
for cutting flow bins off, not relying onbh.loc
at the edges.I do think a smart, range inclusive locator that does not include flow would be quite useful, and might be introduced in hist one day. But I do think that's not
bh.loc / hist.loc
.Originally posted by @henryiii in #479 (comment)
The text was updated successfully, but these errors were encountered: