Skip to content
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

[FEATURE] Improve Stacks #306

Open
henryiii opened this issue Sep 14, 2021 · 3 comments · Fixed by #318
Open

[FEATURE] Improve Stacks #306

henryiii opened this issue Sep 14, 2021 · 3 comments · Fixed by #318
Assignees
Labels
enhancement New feature or request

Comments

@henryiii
Copy link
Member

henryiii commented Sep 14, 2021

Several improvements to Stacks should be added.

Scaling

This maybe should work:

stack * vector

If these are the same length, then each histogram should get scaled (and other operations). Also true for inplace. Maybe dicts should be supported too?

Projections

Operations on a stack should fall through to the histogram, such as projection.

stack = hist.stack("cat")
new_stack =stack.project("x")
# Should be the same as
new_stack = hist.project("cat", "x").stack("cat")

This probably should go for other operations - slicing would be very nice, but does interfere with accessing the stack itself. Maybe we could have a proxy object? Say stack.hists* would apply an operation on every histogram. So stack.hists[0:2] would take [0:2] on every histogram in the stack and return a new stack? If it returns a simple number, then I guess it returns a list? That's a little more irritation statically, though. stack.list*, perhaps, would always return a list?

Setting

The stacks are not settable, they store tuples and have no setter. This should work:

stack[0] *= 2

The internal storage should be a list, and setting should make sure the new histogram matches the old one in axes. All the histogram mul/add/sub operations should work, including in place ones.

Other

I'm still not very happy with *args being the constructor for Stack, as things like Stack(x for x in xs) is not easy to write (and mappings are also not supported). But maybe too late to change. Tempting to allow both to work if args len is 1 and not an instance of a BaseHistogram.

@henryiii henryiii added the enhancement New feature or request label Sep 14, 2021
@henryiii
Copy link
Member Author

Also, stack.name should return and allow the setting of the names.

@henryiii
Copy link
Member Author

Raw setting is the only thing left. s[0] = h, where h gets checked to see if it is valid.

@henryiii
Copy link
Member Author

This is done (at least for the things listed above), but we should add the new stuff to the readme.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants