Skip to content

Commit 91c066e

Browse files
committed
simplified code
1 parent c7285a3 commit 91c066e

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

packages/python/plotly/plotly/express/_imshow.py

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,12 @@ def imshow(
395395
args["animation_frame"] = ( # TODO
396396
"slice" if labels.get("slice") is None else labels["slice"]
397397
)
398+
iterables = ()
399+
if slice_through:
400+
if animation_frame is not None:
401+
iterables += (range(nslices_animation),)
402+
if facet_col is not None:
403+
iterables += (range(nslices_facet),)
398404

399405
# Default behaviour of binary_string: True for RGB images, False for 2D
400406
if binary_string is None:
@@ -451,12 +457,6 @@ def imshow(
451457
"The length of the x vector must match the length of the second "
452458
+ "dimension of the img matrix."
453459
)
454-
iterables = ()
455-
if slice_through:
456-
if animation_frame is not None:
457-
iterables += (range(nslices_animation),)
458-
if facet_col is not None:
459-
iterables += (range(nslices_facet),)
460460
traces = [
461461
go.Heatmap(x=x, y=y, z=img[index_tup], coloraxis="coloraxis1", name=str(i))
462462
for i, index_tup in enumerate(itertools.product(*iterables))
@@ -488,12 +488,6 @@ def imshow(
488488
_vectorize_zvalue(zmin, mode="min"),
489489
_vectorize_zvalue(zmax, mode="max"),
490490
)
491-
iterables = ()
492-
if slice_through:
493-
if animation_frame is not None:
494-
iterables += (range(nslices_animation),)
495-
if facet_col is not None:
496-
iterables += (range(nslices_facet),)
497491
if binary_string:
498492
if zmin is None and zmax is None: # no rescaling, faster
499493
img_rescaled = img

0 commit comments

Comments
 (0)