diff --git a/mpl_interactions/controller.py b/mpl_interactions/controller.py index ac68584..5db41a7 100644 --- a/mpl_interactions/controller.py +++ b/mpl_interactions/controller.py @@ -393,7 +393,7 @@ def gogogo_controls( if extra_controls is None: extra_controls = [ctrl_context] else: - extra_controls.append[ctrl_context] + extra_controls.append(ctrl_context) # Squash controls + extra_controls and make sure we have a unique controller object diff --git a/tests/test_controls.py b/tests/test_controls.py index cf07d4a..a6a31f8 100644 --- a/tests/test_controls.py +++ b/tests/test_controls.py @@ -55,3 +55,17 @@ def f2(x, amp, tau, beta): ctrls.save_animation(str(tmp_path / "animation-amp.gif"), fig, "amp", N_frames=10) ctrls.save_animation(str(tmp_path / "animation-beta.gif"), fig, "beta") ctrls.save_animation(str(tmp_path / "animation-tau.gif"), fig, "tau") + + +def test_scalar_inside_context(): + x = np.random.randn(20) + y = 2 * x + np.random.randn(20) / 2 + + x2 = np.random.randn(20) + y2 = -2 * x2 - np.random.randn(20) / 2 + + fig, ax = plt.subplots() + ctrls = iplt.scatter(x, y, s=(10, 1000)) + # this shouldn't fail + with ctrls: + _ = iplt.scatter(x2, y2, s=ctrls["s"], ax=ax)