Skip to content

Commit

Permalink
fix extra_controls inside controls context (#240)
Browse files Browse the repository at this point in the history
  • Loading branch information
ianhi authored Mar 17, 2022
1 parent 4ecd1b5 commit 62887ca
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion mpl_interactions/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
14 changes: 14 additions & 0 deletions tests/test_controls.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit 62887ca

Please sign in to comment.