Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increase program creation performance #354

Merged
merged 1 commit into from
Aug 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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