Skip to content

Commit

Permalink
Update Comparator to work with generators
Browse files Browse the repository at this point in the history
  • Loading branch information
hoxbro committed Aug 31, 2024
1 parent c0c0d89 commit 15f89b8
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions param/parameterized.py
Original file line number Diff line number Diff line change
Expand Up @@ -1718,11 +1718,18 @@ class Comparator:
type(None): operator.eq,
lambda o: hasattr(o, '_infinitely_iterable'): operator.eq, # Time
}
# equalities.update({dtt: operator.eq for dtt in _dt_types})
gen_equalities = {
_dt_types: operator.eq
}

@classmethod
def is_equal(cls, obj1, obj2):
for eq_type, eq in cls.equalities.items():
equals = cls.equalities.copy()
for gen, op in cls.gen_equalities.items():
for t in gen():
equals[t] = op

for eq_type, eq in equals.items():
try:
are_instances = isinstance(obj1, eq_type) and isinstance(obj2, eq_type)
except TypeError:
Expand Down

0 comments on commit 15f89b8

Please sign in to comment.