Skip to content

Conversation

mrzimu
Copy link

@mrzimu mrzimu commented May 9, 2025

This is an idea/design of making uproot able to read custom classes, also allowing users to customize the reading process in uproot.

A summary of the design is:

  • Add a registration mechanism for user-defined custom interpretation.
  • Add a pre-defined interpretation AsCustom, which
    • Introduces a new layer of interface Reader for converting custom classes to awkward arrays.
    • Defines a series of readers following standard ROOT streaming rules.
    • Allows users to register their own custom readers.

The full description is in dev/custom-interpretation/README.md.

Since I have limited understanding and experience on either ROOT streaming or interface design, it would be grateful if any suggestion or help is provided😄

@mrzimu mrzimu changed the title Add custom interpretation API feat: Add custom interpretation API May 9, 2025
@ianna
Copy link
Collaborator

ianna commented May 29, 2025

Here is the link to the discussion: #1424

@mrzimu
Copy link
Author

mrzimu commented Jul 30, 2025

Hi, I think embedding the whole custom-class reading mechanism is too complicated and may make things a mess, so I created a standalone repository named uproot-custom for handling DIY custom class reading.

I removed the design docs of custom-class reading mechanism (so-call Readers), but I kept the custom interpretation registration interface.

Please let me know if anything I can help or improve, both for this MR and uproot-custom, thanks!

@mrzimu mrzimu marked this pull request as ready for review July 30, 2025 16:55
@mrzimu
Copy link
Author

mrzimu commented Jul 30, 2025

And I have no idea why the docs build failed....

@ariostas
Copy link
Collaborator

And I have no idea why the docs build failed....

pandas is an optional dependency, but you have pandas = uproot.extras.pandas() at the top level of custom.py, so it is crashing once it tries to load uproot. You can move that statement inside final_array, which is where it's actually needed.

Also, thanks for the updates! I'll look at this when I have some time. When you get a chance could you add a test so that we have a concrete usage example and we see if it actually works? Thanks!

@mrzimu
Copy link
Author

mrzimu commented Jul 31, 2025

Yes, I moved the import statement, and improved the test in test_1477_custom_interpretation.py. It just simply transforms the uint8 data to uint32 with big endian.

Copy link
Collaborator

@ariostas ariostas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking really nice! I'll look a bit more into how you're using this with pybes3.

@ariostas
Copy link
Collaborator

ariostas commented Aug 1, 2025

I'll tag @nsmith- since he has more insight than me on how this should work and how this would involve rootfilespec.

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

Successfully merging this pull request may close these issues.

3 participants