File tree 2 files changed +19
-1
lines changed 2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -351,7 +351,7 @@ def remove_callback(self, oid):
351
351
--------
352
352
add_callback
353
353
"""
354
- self ._callbacks .disconnect ("pchanged" , oid )
354
+ self ._callbacks .disconnect (oid )
355
355
356
356
def pchanged (self ):
357
357
"""
Original file line number Diff line number Diff line change @@ -303,3 +303,21 @@ def test_set_alpha_for_array():
303
303
art ._set_alpha_for_array ([0.5 , 1.1 ])
304
304
with pytest .raises (ValueError , match = "alpha must be between 0 and 1" ):
305
305
art ._set_alpha_for_array ([0.5 , np .nan ])
306
+
307
+
308
+ def test_callbacks ():
309
+ def func (artist ):
310
+ func .counter += 1
311
+
312
+ func .counter = 0
313
+
314
+ art = martist .Artist ()
315
+ oid = art .add_callback (func )
316
+ assert func .counter == 0
317
+ art .pchanged () # must call the callback
318
+ assert func .counter == 1
319
+ art .set_zorder (10 ) # setting a property must also call the callback
320
+ assert func .counter == 2
321
+ art .remove_callback (oid )
322
+ art .pchanged () # must not call the callback anymore
323
+ assert func .counter == 2
You can’t perform that action at this time.
0 commit comments