fix: form and type equality bugs#4101
Open
henryiii wants to merge 4 commits into
Open
Conversation
henryiii
added a commit
that referenced
this pull request
Jun 10, 2026
Covers NumpyForm inner_shape inequality, RegularForm/RegularType unknown_length comparison, ListType all_parameters propagation, and union purelist_parameters second-key resolution. Assisted-by: ClaudeCode:claude-sonnet-4-6
Codecov Report❌ Patch coverage is
❌ Your patch check has failed because the patch coverage (90.47%) is below the target coverage (98.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files
|
- NumpyForm._is_equal_to: compare _inner_shape in addition to _primitive, using unknown_length-safe per-element comparison - RegularForm._is_equal_to and RegularType._is_equal_to: guard size comparison against unknown_length to avoid TypeError (unknown_length.__eq__ raises on known values) - ListType._is_equal_to: propagate all_parameters flag to content comparison instead of calling __eq__ (which defaults to all_parameters=False) - UnionMeta.purelist_parameters: fix unconditional return after the first key so later keys are tried when the first yields no consistent answer; this fixes __list__-based behavior lookup on union arrays - RecordForm._is_equal_to and RecordType._is_equal_to: build a field→content dict for the other record once before the loop, reducing O(n²) to O(n) - ListForm.__init__: fix stops error message (was copy-pasting starts message) - IndexedForm.__init__: remove misleading content=None default that always fails validation - ListOffsetForm.__init__: add content validation matching sibling forms Assisted-by: ClaudeCode:claude-sonnet-4-6
Covers NumpyForm inner_shape inequality, RegularForm/RegularType unknown_length comparison, ListType all_parameters propagation, and union purelist_parameters second-key resolution. Assisted-by: ClaudeCode:claude-sonnet-4-6
Removed tests that do not exercise a bug (positive equality, known-size inequality, first-key-wins ordering). Renamed file from hyphens to underscores to satisfy the test-name validator hook. Removed section-header comments from the test file. Assisted-by: ClaudeCode:claude-sonnet-4-6
b19b951 to
09f176d
Compare
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.
🤖 AI text below 🤖
Summary
This PR fixes eight bugs and one performance issue in form/type equality and union parameter lookup:
NumpyForm._is_equal_to(src/awkward/forms/numpyform.py): missing_inner_shapecomparison causedNumpyForm("float64", (2,)) == NumpyForm("float64", (3,))to beTrue. Fixed with unknown_length-safe per-element comparison.RegularForm._is_equal_to(src/awkward/forms/regularform.py) andRegularType._is_equal_to(src/awkward/types/regulartype.py):self._size == other._sizeraisedTypeErrorwhen either side wasunknown_length(its__eq__raises on known values). Fixed with the guarded pattern fromtypes/arraytype.py.ListType._is_equal_to(src/awkward/types/listtype.py): content comparison used==(which callsis_equal_towith defaultall_parameters=False), dropping the caller's flag. Fixed by calling_is_equal_to(other._content, all_parameters)directly, matchingOptionType.UnionMeta.purelist_parameters(src/awkward/_meta/unionmeta.py): unconditionalreturn outinside thefor key in keysloop caused only the first key to ever be tried, making__list__-based behavior lookup on unions fail when__record__was absent. Fixed so the loop continues to the next key when the current one yields no consistent value.RecordForm._is_equal_to(src/awkward/forms/recordform.py) andRecordType._is_equal_to(src/awkward/types/recordtype.py): per-fieldother.content(field)call usedlist.index→ O(n²) for n fields. Fixed by building afield→contentdict forotheronce before the loop.ListForm.__init__(src/awkward/forms/listform.py): error message for invalidstopswas a copy-paste of thestartsmessage. Fixed to name and showstops.IndexedForm.__init__(src/awkward/forms/indexedform.py):content=Nonedefault always fails validation immediately after; removed the default to make the required-ness explicit.ListOffsetForm.__init__(src/awkward/forms/listoffsetform.py): the only list-like form that did not validatecontentis aForm; added the check matching sibling forms.AI assistance
This PR was produced with Claude Code (automated multi-agent review), an AI-assisted workflow. Per CONTRIBUTING.md, this is disclosed here.
Test plan
New regression tests in
tests/test_4101_fix_form_type_equality.pycover one focused case per distinct bug:NumpyForminner_shape inequality (different sizes → not equal)NumpyForminner_shape withunknown_length(compatible with any size)NumpyForminner_shape rank mismatch (different number of dimensions → not equal)RegularForm/RegularTypeunknown_lengthvs. known comparison (noTypeError)ListTypeall_parametersflag propagation to contentUnionMeta.purelist_parameterssecond-key resolution (core bug)UnionMeta.purelist_parametersinconsistency →None(preserved behaviour)Existing tests in
tests/test_2368_type_is_equal.py,tests/test_2426_is_equal_to.py,tests/test_0914_types_and_forms.py,tests/test_0348_form_keys.py,tests/test_2425_forms_from_type.pyall remain green.prek -a --quietpasses.🤖 Generated with Claude Code