Skip to content

Commit

Permalink
Cache more properties when locked
Browse files Browse the repository at this point in the history
  • Loading branch information
schmoelder committed Mar 16, 2024
1 parent ff060ef commit 441fba8
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions CADETProcess/dynamicEvents/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def __init__(self, *args, **kwargs):
self._durations = []
self._lock = False

@property
@cached_property_if_locked
def events(self):
"""list: All Events ordered by event time.
Expand All @@ -109,7 +109,7 @@ def events(self):
"""
return sorted(self._events, key=lambda evt: evt.time)

@property
@cached_property_if_locked
def events_dict(self):
"""dict: Events and Durations orderd by name."""
evts = {evt.name: evt for evt in self.events}
Expand Down Expand Up @@ -276,7 +276,7 @@ def remove_duration(self, duration_name):
self._durations.remove(dur)
self.__dict__.pop(duration_name)

@property
@cached_property_if_locked
def durations(self):
"""List of all durations in the process."""
return self._durations
Expand Down Expand Up @@ -392,37 +392,37 @@ def remove_event_dependency(self, dependent_event, independent_events):
for indep in independent_events:
self.events[dependent_event].remove_dependency(indep)

@property
@cached_property_if_locked
def independent_events(self):
"""list: All events that are not dependent on other events."""
return list(filter(lambda evt: evt.is_independent, self.events))

@property
@cached_property_if_locked
def dependent_events(self):
"""list: All events that are dependent on other events."""
return list(
filter(lambda evt: evt.is_independent is False, self.events)
)

@property
@cached_property_if_locked
def event_parameters(self):
"""list: Event parameters."""
return list({evt.parameter_path for evt in self.events})

@property
@cached_property_if_locked
def event_performers(self):
"""list: Event peformers."""
return list({evt.performer for evt in self.events})

@property
@cached_property_if_locked
def event_times(self):
"""list: Time of events, sorted by Event time."""
event_times = list({evt.time for evt in self.events})
event_times.sort()

return event_times

@property
@cached_property_if_locked
def section_times(self):
"""list: Section times.
Expand Down

0 comments on commit 441fba8

Please sign in to comment.