Skip to content

Commit

Permalink
trying for more efficiency
Browse files Browse the repository at this point in the history
  • Loading branch information
JoFrhwld committed Nov 12, 2024
1 parent 480e5a9 commit 070c9b8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
19 changes: 10 additions & 9 deletions src/aligned_textgrid/sequence_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,16 @@ def __repr__(self):
return self._values.__repr__()

def _sort(self)->None:
if len(self._values) > 0:
if hasattr(self[0], "start"):
item_starts = np.array([x.start for x in self._values])
if hasattr(self[0], "time"):
item_starts = np.array([x.time for x in self._values])
item_order = np.argsort(item_starts)
self._values = [self._values[idx] for idx in item_order]

if len(self._values) < 1:
return

if np.all(self.starts[:-1] <= self.starts[1:]):
return

item_order = np.argsort(self.starts)
self._values = [self._values[idx] for idx in item_order]

@wrap(log_class.entering, log_class.exiting)
def _entry_class_checker(self, value) -> None:
if self.entry_class is None:
self.entry_class = value.entry_class
Expand Down Expand Up @@ -205,7 +207,6 @@ def append(self:Sequence[SeqVar], value:SeqVar, shift:bool = False, re_init = Fa
return

self._values.append(value)
self._sort()

def concat(self:Sequence[SeqVar], intervals:Sequence[SeqVar])->None:
"""Concatenate two sequence lists
Expand Down
7 changes: 3 additions & 4 deletions src/aligned_textgrid/sequences/sequences.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,10 @@ def set_subset_list(self, subset_list:SequenceList['SequenceInterval'] = None)->
for element in subset_list:
if not self is element.super_instance:
element.remove_superset()
element.set_super_instance(self)
element.super_instance = self

# self.append_subset_list(element)

self._set_within()
#self._set_within()
self.contains = self._subset_list
self._set_subset_precedence()
#self.validate()
else:
Expand Down

0 comments on commit 070c9b8

Please sign in to comment.