Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not trigger event if identity of parameter value is unchanged #901

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions param/parameterized.py
Original file line number Diff line number Diff line change
Expand Up @@ -2056,6 +2056,8 @@ def _changed(cls, event):
Predicate that determines whether a Event object has actually
changed such that old != new.
"""
if event.old is event.new:
return False
return not Comparator.is_equal(event.old, event.new)

def _instantiate_param(self_, param_obj, dict_=None, key=None, deepcopy=True):
Expand Down
4 changes: 2 additions & 2 deletions tests/testwatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ def accumulator(change):
obj.a = 1
self.assertEqual(self.accumulator, 1)

def test_triggered_when_unchanged_complex_type(self):
def test_untriggered_when_unchanged_complex_type(self):
def accumulator(change):
self.accumulator += 1

Expand All @@ -193,7 +193,7 @@ def accumulator(change):
obj.a = subobj
self.assertEqual(self.accumulator, 1)
obj.a = subobj
self.assertEqual(self.accumulator, 2)
self.assertEqual(self.accumulator, 1)

def test_triggered_when_unchanged_if_not_onlychanged(self):
accumulator = Accumulator()
Expand Down