Skip to content

Commit

Permalink
Cache some PT durations
Browse files Browse the repository at this point in the history
  • Loading branch information
terrorfisch committed Aug 23, 2018
1 parent 97336de commit d72813e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion qctoolkit/pulses/loop_pulse_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import warnings

import sympy
from cached_property import cached_property

from qctoolkit.serialization import Serializer, PulseRegistryType
from qctoolkit._program._loop import Loop
Expand Down Expand Up @@ -166,7 +167,7 @@ def loop_range(self) -> ParametrizedRange:
def measurement_names(self) -> Set[str]:
return LoopPulseTemplate.measurement_names.fget(self) | MeasurementDefiner.measurement_names.fget(self)

@property
@cached_property
def duration(self) -> ExpressionScalar:
step_size = self._loop_range.step.sympified_expression
loop_index = sympy.symbols(self._loop_index)
Expand Down
4 changes: 3 additions & 1 deletion qctoolkit/pulses/sequence_pulse_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import functools
import warnings

from cached_property import cached_property

from qctoolkit.serialization import Serializer, PulseRegistryType
from qctoolkit._program._loop import Loop

Expand Down Expand Up @@ -117,7 +119,7 @@ def subtemplates(self) -> List[MappingPulseTemplate]:
def is_interruptable(self) -> bool:
return any(st.is_interruptable for st in self.subtemplates)

@property
@cached_property
def duration(self) -> Expression:
return sum(sub.duration for sub in self.__subtemplates)

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
package_dir={'qctoolkit': 'qctoolkit'},
packages=packages,
tests_require=['pytest'],
install_requires=['sympy>=1.1.1', 'numpy', 'pandas'] + requires_typing,
install_requires=['sympy>=1.1.1', 'numpy', 'pandas', 'cached_property'] + requires_typing,
extras_require={
'testing': ['pytest'],
'plotting': ['matplotlib'],
Expand Down

0 comments on commit d72813e

Please sign in to comment.