Use dict.copy().items() instead of list(.items()) (#9868)

This commit is contained in:
Adriane Boyd 2021-12-16 09:17:33 +01:00 committed by GitHub
parent 018827e9fd
commit 94fbd88521
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View File

@ -604,7 +604,7 @@ cdef class ArcEager(TransitionSystem):
actions[SHIFT][''] += 1 actions[SHIFT][''] += 1
if min_freq is not None: if min_freq is not None:
for action, label_freqs in actions.items(): for action, label_freqs in actions.items():
for label, freq in list(label_freqs.items()): for label, freq in label_freqs.copy().items():
if freq < min_freq: if freq < min_freq:
label_freqs.pop(label) label_freqs.pop(label)
# Ensure these actions are present # Ensure these actions are present

View File

@ -274,7 +274,7 @@ cdef class Vectors:
self.data = resized_array self.data = resized_array
self._sync_unset() self._sync_unset()
removed_items = [] removed_items = []
for key, row in list(self.key2row.items()): for key, row in self.key2row.copy().items():
if row >= shape[0]: if row >= shape[0]:
self.key2row.pop(key) self.key2row.pop(key)
removed_items.append((key, row)) removed_items.append((key, row))