Skip to content

Comments

fix: touch up serialization, add TypedDict#151

Merged
henryiii merged 3 commits intomainfrom
henryiii/fix/serialization
Apr 14, 2025
Merged

fix: touch up serialization, add TypedDict#151
henryiii merged 3 commits intomainfrom
henryiii/fix/serialization

Conversation

@henryiii
Copy link
Member

@henryiii henryiii commented Apr 14, 2025

One change:

  • circular is now a required property. Simplified implementation; I don't think there's a need to make it optional for a new standard. Metadata needs to be optional, as a way to indicate no metadata present, but circular is just like all the other non-optional fields.

One fix:

  • The storages had copy-paste errors in the schema.

And a feature:

  • Added a TypedDict version of the schema. I have not added a dependency on typing_extensions for versions older than 3.11, so I'm using the total=False mechanism. It could be updated to Required/NonRequired in the future.

@henryiii henryiii requested a review from Copilot April 14, 2025 16:28
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 2 out of 4 changed files in this pull request and generated no comments.

Files not reviewed (2)
  • src/uhi/resources/histogram.schema.json: Language not supported
  • tests/resources/reg.json: Language not supported
Comments suppressed due to low confidence (1)

src/uhi/typing/serialization.py:92

  • [nitpick] The class name 'WeighedData' may be better spelled as 'WeightedData' to maintain consistency with similar names like 'WeightedMeanData'.
class WeighedData(TypedDict):

Signed-off-by: Henry Schreiner <[email protected]>
@henryiii
Copy link
Member Author

The class name 'WeighedData' may be better spelled as 'WeightedData' to maintain consistency with similar names like 'WeightedMeanData'.

Thanks, Copilot!

@henryiii
Copy link
Member Author

@jpivarski, @HDembinski, since this is a minor change to the schema (circular now a required property), can I get a signoff from you?

@jpivarski
Copy link
Member

Sounds good to me. I wondered for a moment if this might be an issue in Uproot because it doesn't mention the circular property when producing or consuming boost-histogram, but then I realized that you're talking about the serialization protocol. That won't break anything in Uproot because Uproot doesn't use that.

@HDembinski
Copy link
Member

Also looks good to me.

@henryiii
Copy link
Member Author

Yes, no one uses it yet, so I think it's safe to change a tiny bit as we implement it (plus the description warns it could change while being implemented). I'm working on getting it implemented in boost-histogram, based on @aryamanjeendgar's excellent start, and the ROOT team might be looking at it soon, after implementing UHI.

Thanks!

@henryiii henryiii merged commit e7c44fc into main Apr 14, 2025
10 checks passed
@henryiii henryiii deleted the henryiii/fix/serialization branch April 14, 2025 19:43
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