fix array equality comparison - #394
Merged
Merged
Conversation
attrs' generated __eq__ hit numpy's elementwise == on array fields, so comparing any two components with arrays raised. Array fields now compare with array_eq: shape and dtype must match, NaNs at the same position are equal, and dask arrays are compared by graph name without being computed. spec.field() applies it to any field with a shape. Gwf.output holds a back-reference to its model and made model equality recurse forever, so it no longer takes part in comparison. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Inline arrays like auxiliary have no shape for field() to key on, so codegen emits eq=ARRAY_EQ for fields converted with to_array. Add a test that every array-typed field uses a non-default comparer, and update the Disv equality test for the DFN-shaped vertices and cell2d. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The hook lived in _ml_field, which is never called with a converter, so regenerating dropped eq=ARRAY_EQ from inline to_array fields. Move it to filters.field_call and regenerate, which also covers maw/sfr/uzf. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Comparing components with arrays raised an error because the
__eq__method generated by attrs used numpy elementwise comparison, which returns an array instead of a bool. Compare arrays with a newarray_eqfunction instead: