Skip to content

Commit

Permalink
Fix use_symengine ScheduleBlock
Browse files Browse the repository at this point in the history
  • Loading branch information
mtreinish committed Nov 16, 2023
1 parent d6a964e commit 4bdcc20
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
7 changes: 4 additions & 3 deletions qiskit/qpy/binary_io/schedules.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,13 @@ def _read_discriminator(file_obj, version):
def _loads_symbolic_expr(expr_bytes, use_symengine=False):
if expr_bytes == b"":
return None
expr_bytes = zlib.decompress(expr_bytes)
if use_symengine:
return load_basic(zlib.decompress(expr_bytes))
return load_basic(expr_bytes)
else:
from sympy import parse_expr

expr_txt = zlib.decompress(expr_bytes).decode(common.ENCODE)
expr_txt = expr_bytes.decode(common.ENCODE)
expr = parse_expr(expr_txt)
return sym.sympify(expr)

Expand Down Expand Up @@ -472,7 +473,7 @@ def _dumps_operand(operand, use_symengine):
def _write_element(file_obj, element, metadata_serializer, use_symengine):
if isinstance(element, ScheduleBlock):
common.write_type_key(file_obj, type_keys.Program.SCHEDULE_BLOCK)
write_schedule_block(file_obj, element, metadata_serializer)
write_schedule_block(file_obj, element, metadata_serializer, use_symengine)
else:
type_key = type_keys.ScheduleInstruction.assign(element)
common.write_type_key(file_obj, type_key)
Expand Down
6 changes: 6 additions & 0 deletions releasenotes/notes/platform-support-f7f693aaf5dec044.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,9 @@ upgrade:
build Qiskit from source while the Qiskit MSRV (minimum supported Rust
version) is < 1.74, but the precompiled binaries published to PyPI will
only be compatible with macOS >= 10.12.
fixes:
- |
Fixed an issue with :class:`.qpy.dump` which would cause the function to
potentially ignore the value of ``use_symengine`` when serializing a
:class:`.ScheduleBlock` object.

0 comments on commit 4bdcc20

Please sign in to comment.