feat: add behavior cls validation hook#3710
Merged
pfackeldey merged 4 commits intoscikit-hep:mainfrom Nov 5, 2025
Merged
Conversation
Member
|
@ikrommyd - Quick note — for draft PRs, it’s usually best if the author merges |
|
The documentation preview is ready to be viewed at http://preview.awkward-array.org.s3-website.us-east-1.amazonaws.com/PR3710 |
Codecov Report❌ Patch coverage is
Additional details and impacted files
🚀 New features to boost your workflow:
|
…nto behavior_validation
Collaborator
Author
|
@ianna this is now ready for a review :) |
ianna
reviewed
Nov 5, 2025
Member
ianna
left a comment
There was a problem hiding this comment.
@pfackeldey - This looks great! Please, go ahead and merge ti if you are done with it. Thanks.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds a way to run a validation method for behaviors, this helps to solve scikit-hep/vector#660.
A behavior may now implement the
__awkward_validation__method. It is run everytime awkward wants to update the class type of an highlevel array (which is on every instance creation, or 'in-place' mutation like__setitem__or__delitem__with fields. This implementation is non-invasive and safe in the sense thatselfis immutable (see its__setattr__implementation) and is run right before theak.validity_errorcheck.It is meant to be used for fast metadata checks, i.e. are certain fields present or not. This is not the right place to do O(n) array operations! <- I'll make this very explicit in the docs.
Also closes #1483.
Opening this in draft for now as I'm planning to add tests and docs tomorrow.