Skip to content

Commit f70af59

Browse files
committed
Fix text property dict upon pasting data
1 parent 2d5116a commit f70af59

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/napari_deeplabcut/_widgets.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,21 +140,28 @@ def guess_continuous(property):
140140

141141
def _paste_data(self, store):
142142
"""Paste only currently unannotated data."""
143-
features = self._clipboard.pop("features")
143+
features = self._clipboard.pop("features", None)
144144
if features is None:
145145
return
146+
146147
unannotated = [
147148
keypoints.Keypoint(label, id_) not in store.annotated_keypoints
148149
for label, id_ in zip(features["label"], features["id"])
149150
]
151+
if not any(unannotated):
152+
return
153+
150154
new_features = features.iloc[unannotated]
151155
indices_ = self._clipboard.pop("indices")
152156
text_ = self._clipboard.pop("text")
153157
self._clipboard = {k: v[unannotated] for k, v in self._clipboard.items()}
154158
self._clipboard["features"] = new_features
155159
self._clipboard["indices"] = indices_
156160
if text_ is not None:
157-
new_text = {k: v[unannotated] for k, v in text_.items()}
161+
new_text = {
162+
"string": text_["string"][unannotated],
163+
"color": text_["color"],
164+
}
158165
self._clipboard["text"] = new_text
159166

160167
npoints = len(self._view_data)

0 commit comments

Comments
 (0)