Skip to content

Commit ad5acd2

Browse files
committed
Indent add_cbar block and add test for it
1 parent 22e65ce commit ad5acd2

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

filter_functions/plotting.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -265,10 +265,10 @@ def plot_bloch_vector_evolution(
265265
lc = collections.LineCollection(segments[:, :, :2], colors=segment_colors)
266266
b.axes.add_collection3d(lc, zdir='z', zs=segments[:, :, 2])
267267

268-
if add_cbar:
269-
default_cbar_kwargs = dict(shrink=2/3, pad=0.05, label=r'$t$ ($\tau$)', ticks=[0, 1])
270-
cbar_kwargs = {**default_cbar_kwargs, **(cbar_kwargs or {})}
271-
b.fig.colorbar(cm.ScalarMappable(cmap=cmap), **cbar_kwargs)
268+
if add_cbar:
269+
default_cbar_kwargs = dict(shrink=2/3, pad=0.05, label=r'$t$ ($\tau$)', ticks=[0, 1])
270+
cbar_kwargs = {**default_cbar_kwargs, **(cbar_kwargs or {})}
271+
b.fig.colorbar(cm.ScalarMappable(cmap=cmap), **cbar_kwargs)
272272

273273
if show:
274274
b.make_sphere()

tests/test_plotting.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,9 @@ def test_plot_bloch_vector_evolution(self):
363363

364364
b = plotting.plot_bloch_vector_evolution(complicated_pulse)
365365

366+
# Test add_cbar kwarg
367+
b = plotting.plot_bloch_vector_evolution(simple_pulse, cmap='viridis', add_cbar=True)
368+
366369
# Check exceptions being raised
367370
with self.assertRaises(ValueError):
368371
plotting.plot_bloch_vector_evolution(two_qubit_pulse)

0 commit comments

Comments
 (0)