Skip to content

Commit 5e72106

Browse files
authored
Merge pull request #83 from DeepLabCut/fix_copypaste
Fix copy-paste functionality w/ napari 0.4.18
2 parents 48de4a2 + f70af59 commit 5e72106

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

src/napari_deeplabcut/_widgets.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,28 +144,35 @@ def guess_continuous(property):
144144

145145
def _paste_data(self, store):
146146
"""Paste only currently unannotated data."""
147-
features = self._clipboard.pop("features")
147+
features = self._clipboard.pop("features", None)
148148
if features is None:
149149
return
150+
150151
unannotated = [
151152
keypoints.Keypoint(label, id_) not in store.annotated_keypoints
152153
for label, id_ in zip(features["label"], features["id"])
153154
]
155+
if not any(unannotated):
156+
return
157+
154158
new_features = features.iloc[unannotated]
155159
indices_ = self._clipboard.pop("indices")
156160
text_ = self._clipboard.pop("text")
157161
self._clipboard = {k: v[unannotated] for k, v in self._clipboard.items()}
158162
self._clipboard["features"] = new_features
159163
self._clipboard["indices"] = indices_
160164
if text_ is not None:
161-
new_text = {k: v[unannotated] for k, v in text_.items()}
165+
new_text = {
166+
"string": text_["string"][unannotated],
167+
"color": text_["color"],
168+
}
162169
self._clipboard["text"] = new_text
163170

164171
npoints = len(self._view_data)
165172
totpoints = len(self.data)
166173

167174
if len(self._clipboard.keys()) > 0:
168-
not_disp = self._dims_not_displayed
175+
not_disp = self._slice_input.not_displayed
169176
data = deepcopy(self._clipboard['data'])
170177
offset = [
171178
self._slice_indices[i] - self._clipboard['indices'][i]
@@ -179,6 +186,9 @@ def _paste_data(self, store):
179186
self._size = np.append(
180187
self.size, deepcopy(self._clipboard['size']), axis=0
181188
)
189+
self._symbol = np.append(
190+
self.symbol, deepcopy(self._clipboard['symbol']), axis=0
191+
)
182192

183193
self._feature_table.append(self._clipboard['features'])
184194

0 commit comments

Comments
 (0)