Skip to content

Commit

Permalink
Merge 922a4a6 into 6b0e9e4
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr committed Oct 12, 2018
2 parents 6b0e9e4 + 922a4a6 commit 41ec6e8
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion param/parameterized.py
Expand Up @@ -1004,8 +1004,8 @@ def set_param(self_, *args,**kwargs):
raise ValueError("'%s' is not a parameter of %s"%(k,self_or_cls.name))
setattr(self_or_cls,k,v)

self_._batch_call_watchers()
self_.self_or_cls.param._BATCH_WATCH = False
self_._batch_call_watchers()


def trigger(self_, *param_names):
Expand Down
20 changes: 20 additions & 0 deletions tests/API1/testwatch.py
Expand Up @@ -191,6 +191,26 @@ def test_simple_batched_watch_setattr(self):
self.assertEqual(args[0].type, 'changed')


def test_nested_batched_watch_setattr(self):

obj = SimpleWatchExample()

accumulator = Accumulator()
watcher = obj.param.watch(accumulator, ['a', 'c'])

def set_c(*events):
obj.c = 3

watcher2 = obj.param.watch(set_c, ['a', 'b'])

obj.param.set_param(a=2)
self.assertEqual(obj.c, 3)

# Change inside watch callback should have triggered
# second call to accumulator
self.assertEqual(accumulator.call_count(), 2)


def test_simple_batched_watch(self):

accumulator = Accumulator()
Expand Down

0 comments on commit 41ec6e8

Please sign in to comment.