Skip to content

Commit

Permalink
Fix OS-precision-dependent unit test (#694)
Browse files Browse the repository at this point in the history
* Fix OS-precision-dependant unit test

* Run full test suit

* Revert "Run full test suit"

This reverts commit 94d5327.
  • Loading branch information
HGSilveri authored Jun 13, 2024
1 parent a410687 commit df8a77b
Showing 1 changed file with 11 additions and 4 deletions.
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

0 comments on commit df8a77b

Please sign in to comment.