@@ -127,9 +127,8 @@ def comparator(orig: Any, new: Any, superset_obj=False) -> bool: # noqa: ANN001
127127 if isinstance (orig , tf .SparseTensor ):
128128 if not comparator (orig .dense_shape .numpy (), new .dense_shape .numpy (), superset_obj ):
129129 return False
130- return (
131- comparator (orig .indices .numpy (), new .indices .numpy (), superset_obj ) and
132- comparator (orig .values .numpy (), new .values .numpy (), superset_obj )
130+ return comparator (orig .indices .numpy (), new .indices .numpy (), superset_obj ) and comparator (
131+ orig .values .numpy (), new .values .numpy (), superset_obj
133132 )
134133
135134 if isinstance (orig , tf .RaggedTensor ):
@@ -182,8 +181,8 @@ def comparator(orig: Any, new: Any, superset_obj=False) -> bool: # noqa: ANN001
182181 # dict_values need element-wise comparison (order matters)
183182 return comparator (list (orig ), list (new ))
184183 if type_name == "dict_items" :
185- # dict_items can be compared as sets of tuples (order doesn't matter for items )
186- return comparator (list (orig ), list (new ))
184+ # Convert to dict for order-insensitive comparison (handles unhashable values )
185+ return comparator (dict (orig ), dict (new ), superset_obj )
187186
188187 if HAS_NUMPY :
189188 import numpy as np # type: ignore # noqa: PGH003
0 commit comments