Skip to content

Commit

Permalink
Compile info and target to TDMProgram.compile (#659)
Browse files Browse the repository at this point in the history
* add compile info and target

* update changelog

* Update .github/CHANGELOG.md

Co-authored-by: Mikhail Andrenkov <Mandrenkov@users.noreply.github.com>

* update docstring

* update docstring again

Co-authored-by: Mikhail Andrenkov <Mandrenkov@users.noreply.github.com>
  • Loading branch information
thisac and Mandrenkov committed Nov 24, 2021
1 parent 2c27f1c commit 5c2aeb3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
6 changes: 6 additions & 0 deletions .github/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,18 @@

<h3>Bug fixes</h3>

* The `TDMProgram.compile_info` and `TDMProgram.target` fields are now set when
a `TDMProgram` is compiled using the "TDM" compiler.
[(#659)](https://github.com/XanaduAI/strawberryfields/pull/659)

<h3>Documentation</h3>

<h3>Contributors</h3>

This release contains contributions from (in alphabetical order):

Theodor Isacsson

# Release 0.20.0 (current release)

<h3>New features since last release</h3>
Expand Down
2 changes: 1 addition & 1 deletion strawberryfields/program.py
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@ def compile(self, *, device=None, compiler=None, **kwargs):
program compilation
compiler (str, ~strawberryfields.compilers.Compiler): Compiler name or compile strategy
to use. If a device is specified, this overrides the compile strategy specified by
the hardware :class:`~.DevicSpec`.
the hardware :class:`~.DeviceSpec`.
Keyword Args:
optimize (bool): If True, try to optimize the program by merging and canceling gates.
Expand Down
8 changes: 6 additions & 2 deletions strawberryfields/tdm/tdmprogram.py
Original file line number Diff line number Diff line change
Expand Up @@ -437,9 +437,11 @@ def context(self, *args, shift="default"):

# pylint: disable=too-many-branches
def compile(self, *, device=None, compiler=None):
"""Compile the time-domain program given a Strawberry Fields photonic hardware device specification.
"""Compile the time-domain program given a Strawberry Fields photonic hardware device
specification.
Currently, the compilation is simply a check that the program matches the device.
The compilation checks that the program matches the device and sets the compile information
and the program target to the correct device target.
Args:
device (~strawberryfields.DeviceSpec): device specification object to use for
Expand Down Expand Up @@ -557,6 +559,8 @@ def compile(self, *, device=None, compiler=None):
device.target, program_param, param_range
)
)
self._compile_info = (device, "TDM")
self._target = device.target
return self

raise CircuitError("TDM programs cannot be compiled without a valid device specification.")
Expand Down

0 comments on commit 5c2aeb3

Please sign in to comment.