Skip to content

Commit

Permalink
Draw the phase curve by default in Sequence.draw() (#771)
Browse files Browse the repository at this point in the history
* Set draw_phase_curve to True by default

* Fix phase curve

* Always display phase in draw_phase_area
  • Loading branch information
a-corni authored Dec 3, 2024
1 parent 5a58264 commit dd40da7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 21 deletions.
24 changes: 7 additions & 17 deletions pulser-core/pulser/sequence/_seq_drawer.py
Original file line number Diff line number Diff line change
Expand Up @@ -540,8 +540,7 @@ def _draw_channel_content(
the solver. If present, plots the effective pulse alongside the
input pulse.
draw_phase_area: Whether phase and area values need to be shown
as text on the plot, defaults to False. If `draw_phase_curve=True`,
phase values are ommited.
as text on the plot, defaults to False.
draw_phase_shifts: Whether phase shift and reference information
should be added to the plot, defaults to False.
draw_input: Draws the programmed pulses on the channels, defaults
Expand Down Expand Up @@ -732,10 +731,6 @@ def phase_str(phi: Any) -> str:

if draw_phase_area:
top = False # Variable to track position of box, top or center.
print_phase = not draw_phase_curve and any(
np.any(ch_data.samples.phase[slot.ti : slot.tf] != 0)
for slot in ch_data.samples.slots
)

for slot in ch_data.samples.slots:
if sampling_rate:
Expand Down Expand Up @@ -767,11 +762,8 @@ def phase_str(phi: Any) -> str:
if round(area_val, 2) == 1
else rf"A: {float(area_val):.2g}$\pi$"
)
if not print_phase:
txt = area_fmt
else:
phase_fmt = rf"$\phi$: {phase_str(phase_val)}"
txt = "\n".join([phase_fmt, area_fmt])
phase_fmt = rf"$\phi$: {phase_str(phase_val)}"
txt = "\n".join([phase_fmt, area_fmt])
axes[0].text(
x_plot,
y_plot,
Expand Down Expand Up @@ -1246,7 +1238,7 @@ def draw_samples(
sampling_rate: Optional[float] = None,
draw_phase_area: bool = False,
draw_phase_shifts: bool = False,
draw_phase_curve: bool = False,
draw_phase_curve: bool = True,
draw_detuning_maps: bool = False,
draw_qubit_amp: bool = False,
draw_qubit_det: bool = False,
Expand All @@ -1263,8 +1255,7 @@ def draw_samples(
the solver. If present, plots the effective pulse alongside the
input pulse.
draw_phase_area: Whether phase and area values need to be shown
as text on the plot, defaults to False. If `draw_phase_curve=True`,
phase values are ommited.
as text on the plot, defaults to False.
draw_phase_shifts: Whether phase shift and reference information
should be added to the plot, defaults to False.
draw_phase_curve: Draws the changes in phase in its own curve (ignored
Expand Down Expand Up @@ -1322,7 +1313,7 @@ def draw_sequence(
draw_register: bool = False,
draw_input: bool = True,
draw_modulation: bool = False,
draw_phase_curve: bool = False,
draw_phase_curve: bool = True,
draw_detuning_maps: bool = False,
draw_qubit_amp: bool = False,
draw_qubit_det: bool = False,
Expand All @@ -1336,8 +1327,7 @@ def draw_sequence(
the solver. If present, plots the effective pulse alongside the
input pulse.
draw_phase_area: Whether phase and area values need to be shown
as text on the plot, defaults to False. If `draw_phase_curve=True`,
phase values are ommited.
as text on the plot, defaults to False.
draw_interp_pts: When the sequence has pulses with waveforms of
type InterpolatedWaveform, draws the points of interpolation on
top of the respective waveforms (defaults to True).
Expand Down
5 changes: 2 additions & 3 deletions pulser-core/pulser/sequence/sequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -1734,7 +1734,7 @@ def draw(
draw_interp_pts: bool = True,
draw_phase_shifts: bool = False,
draw_register: bool = False,
draw_phase_curve: bool = False,
draw_phase_curve: bool = True,
draw_detuning_maps: bool = False,
draw_qubit_amp: bool = False,
draw_qubit_det: bool = False,
Expand All @@ -1754,8 +1754,7 @@ def draw(
offsets, displays the equivalent phase modulation.
draw_phase_area: Whether phase and area values need to be
shown as text on the plot, defaults to False. Doesn't work in
'output' mode. If `draw_phase_curve=True`, phase values are
ommited.
'output' mode.
draw_interp_pts: When the sequence has pulses with waveforms
of type InterpolatedWaveform, draws the points of interpolation
on top of the respective input waveforms (defaults to True).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@
"seq.disable_eom_mode(\"rydberg\")\n",
"seq.add(Pulse.ConstantPulse(100, 1, 0, 0), \"rydberg\")\n",
"\n",
"seq.draw(draw_phase_curve=True)"
"seq.draw()"
]
},
{
Expand Down

0 comments on commit dd40da7

Please sign in to comment.