Skip to content

Commit 89af9f1

Browse files
authored
Merge pull request #46 from cifkao/fix-remove-duplicates
Slow but correct implementation of remove_duplicate
2 parents 5025eba + 5bc6c03 commit 89af9f1

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

muspy/base.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -665,13 +665,14 @@ def _remove_duplicate(self, attr: str, recursive: bool):
665665
if not getattr(self, attr):
666666
return
667667

668-
# Replace the old lis with a new list without duplicates
668+
# Replace the old list with a new list without duplicates
669+
# TODO: Speed this up by grouping by time.
669670
attr_type = self._attributes[attr]
670671
value = getattr(self, attr)
671-
new_value = [value[0]]
672-
for item, next_item in zip(value[:-1], value[1:]):
673-
if item != next_item:
674-
new_value.append(next_item)
672+
new_value = []
673+
for item in value:
674+
if item not in new_value:
675+
new_value.append(item)
675676
setattr(self, attr, new_value)
676677

677678
# Apply recursively

0 commit comments

Comments
 (0)