-
Notifications
You must be signed in to change notification settings - Fork 25
feat: support conversion, AxesTuple subclass, get/setattr #456
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
Conversation
2a83def
to
7527191
Compare
7527191
to
f6aa5e1
Compare
f6aa5e1
to
62a294d
Compare
The reason to drop the cpp interface was to simplify the code and make the extra wrapping and indirection obsolete. I don't see that happening here, as you continue to rely on that the set_family feature. |
Other people should wrap boost-histogram by subclassing or via composition. |
Dropping CPP did simplify quite a bit, and removed the oax = CustomIntCategory(growth=True)
h = CustomHist(oax)
h.fill([1,2,3])
(ax,) = h.axes What is That is a way to replace this: you could track through all types through all boost-histogram operations and manually map types; you would also have to keep the type objects stored in the hist object (this also is needed for all other boost-histogram classes, like transforms and storages). At the moment, that replacement would a very significant change, and could possibly be more error prone (at least would be more manual code / dict building) for a user library to set up than a simple decorator. A nice documentation page on how to do this might be better than trying to replace the system with another system with more manual intervention. Also, this is subclassing; the family feature just enables consistent return types. If you only change Histogram, you don't need to add families; it's only for subclasses Axes, etc. (Since everyone will likely want to add names, I expect everyone will need to subclass at least Axis, though). You can't use composition because the underlying parts are in C++; templated C++ at that, so users cannot actually add a new Axes or subclass the C++ axes in C++; it wouldn't make a valid |
Ok, I think I understand, but this bothers me a bit. Perhaps it could be made so that the C++ code actually knows whether you pass a subclassed Axis to the histogram. We can already store arbitrary metadata in the metadata field, so in principle we could also store the subclassing info. |
Adding an involved test that looks "Hist"-like, to make sure functionality Hist relies on is tested, like the ability to override AxesTuple with a subclass. Closes #430, as @HDembinski doesn't want name lookup in boost-histogram, at least for the foreseeable future.
Due to the design, adding custom functionality like a read only name is actually quite easy - subclasses just need to access
._ax.metadata
directly. Didn't need a change, just a test.Adds a simple hook that allows customizations of the conversion process by subclasses.
Adds
ax.axes.<anything>
as a proxy forax.<anything>
, making "metadata" no longer special here either.