Skip to content

ImageWidget.set_data() for a subset of the data arrays #901

@kushalkolar

Description

@kushalkolar
Subject: [PATCH] ImageWidget.set_data() for some of the data arrays
---
Index: fastplotlib/widgets/image_widget/_widget.py
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/fastplotlib/widgets/image_widget/_widget.py b/fastplotlib/widgets/image_widget/_widget.py
--- a/fastplotlib/widgets/image_widget/_widget.py	(revision df922879c143b4079ee4dd1b5903d7784e7f95f2)
+++ b/fastplotlib/widgets/image_widget/_widget.py	(date 1758359542366)
@@ -929,6 +929,11 @@
         for i, (new_array, current_array, subplot) in enumerate(
             zip(new_data, self._data, self.figure)
         ):
+            # if the new array is the same as the existing array, skip
+            # this allows setting just a subset of the arrays in the ImageWidget
+            if new_data is self._data[i]:
+                continue
+
             # check last two dims (x and y) to see if data shape is changing
             old_data_shape = self._data[i].shape[-self.n_img_dims[i] :]
             self._data[i] = new_array

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions