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

Fix OS-precision-dependent unit test #694

Merged
merged 3 commits into from
Jun 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions tests/test_pulse.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
import numpy as np
import pytest

from pulser import Pulse
from pulser.channels import Rydberg
from pulser.channels.eom import RydbergBeam, RydbergEOM
from pulser.parametrized import ParamObj, Variable
from pulser.pulse import PHASE_PRECISION, Pulse
from pulser.waveforms import (
BlackmanWaveform,
ConstantWaveform,
Expand Down Expand Up @@ -166,10 +166,17 @@ def test_arbitrary_phase(phase_wf, det_wf, phase_0):

pls_ = Pulse.ArbitraryPhase(bwf, phase_wf)
assert pls_ == Pulse(bwf, det_wf, phase_0)
np.testing.assert_allclose(
(-np.cumsum(pls_.detuning.samples * 1e-3) + phase_0) % (2 * np.pi),

calculated_phase = -np.cumsum(pls_.detuning.samples * 1e-3) + phase_0
assert np.allclose(
calculated_phase % (2 * np.pi),
phase_wf.samples % (2 * np.pi),
atol=1e-14,
atol=PHASE_PRECISION,
# The shift makes sure we don't fail around the wrapping point
) or np.allclose(
(calculated_phase + 1) % (2 * np.pi),
(phase_wf.samples + 1) % (2 * np.pi),
atol=PHASE_PRECISION,
)


Expand Down