File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed
discussion/robust_inverse_graphics Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -116,6 +116,21 @@ class Example:
116116 scene_id : Any | None = None
117117 scene_embedding : Any | None = None
118118
119+ # Directly comparing members of the type `jax.Array` can throw an error:
120+ # "The truth value of an array with more than one element is ambiguous."
121+ # So we bring back an explicit implementation of __eq__ like it was prior to
122+ # Python 3.13 in order work around this possibility.
123+ def __eq__ (self , other ):
124+ if self is other :
125+ return True
126+ if other .__class__ is self .__class__ :
127+ return tuple (
128+ getattr (self , field .name ) for field in dataclasses .fields (self )
129+ ) == tuple (
130+ getattr (other , field .name ) for field in dataclasses .fields (other )
131+ )
132+ return NotImplemented
133+
119134 def fields_with_view_axis (self ) -> tree_util .DataclassView ['Example' ]:
120135 """Returns a view with only fields that typically have the view axis."""
121136 return tree_util .DataclassView (self , _fields_with_view_axis_selector )
You can’t perform that action at this time.
0 commit comments