def test_add(): assert Timestamp(picos=1) + Duration(picos=2) == Timestamp(picos=3) assert Duration(picos=3) + Timestamp(picos=-5) == Timestamp(picos=-2) with pytest.raises(TypeError): assert Timestamp() + Timestamp() == Timestamp() with pytest.raises(TypeError): _ = 1 + Timestamp() with pytest.raises(TypeError): _ = Timestamp() + 1
def test_sub(): assert Timestamp() - Timestamp() == Duration() assert Timestamp(picos=1) - Timestamp(picos=2) == Duration(picos=-1) assert Timestamp(picos=5) - Duration(picos=2) == Timestamp(picos=3) with pytest.raises(TypeError): _ = Duration() - Timestamp() with pytest.raises(TypeError): _ = 1 - Timestamp() with pytest.raises(TypeError): _ = Timestamp() - 1
def test_sub(): assert Timestamp() - Timestamp() == Duration() assert Timestamp(picos=1) - Timestamp(picos=2) == Duration(picos=-1) assert Timestamp(picos=5) - Duration(picos=2) == Timestamp(picos=3) assert Timestamp(picos=5) - timedelta(microseconds=2) == Timestamp(picos=-1999995) with pytest.raises(TypeError): _ = Duration() - Timestamp() with pytest.raises(TypeError): _ = 1 - Timestamp() with pytest.raises(TypeError): _ = Timestamp() - 1
def test_add(): assert Timestamp(picos=1) + Duration(picos=2) == Timestamp(picos=3) assert Duration(picos=3) + Timestamp(picos=-5) == Timestamp(picos=-2) assert Timestamp(picos=1) + timedelta(microseconds=2) == Timestamp(picos=2000001) assert timedelta(microseconds=3) + Timestamp(picos=-5) == Timestamp(picos=2999995) with pytest.raises(TypeError): assert Timestamp() + Timestamp() == Timestamp() with pytest.raises(TypeError): _ = 1 + Timestamp() with pytest.raises(TypeError): _ = Timestamp() + 1
def test_cmp_vs_other_type(): with pytest.raises(TypeError): _ = Timestamp() < Duration() with pytest.raises(TypeError): _ = Timestamp() < 0 with pytest.raises(TypeError): _ = Timestamp() <= 0 with pytest.raises(TypeError): _ = Timestamp() >= 0 with pytest.raises(TypeError): _ = Timestamp() > 0
def get_aqt_device(num_qubits: int) -> Tuple[IonDevice, List[LineQubit]]: """Returns an AQT ion device Args: num_qubits: number of qubits Returns: IonDevice, qubit_list """ qubit_list = LineQubit.range(num_qubits) us = 1000 * Duration(nanos=1) ion_device = IonDevice(measurement_duration=100 * us, twoq_gates_duration=200 * us, oneq_gates_duration=10 * us, qubits=qubit_list) return ion_device, qubit_list
def test_cmp(): ordered_groups = [ Timestamp(picos=-1), Timestamp(), Timestamp(picos=1), Timestamp(nanos=1), Timestamp(picos=2000), ] for i in range(len(ordered_groups)): for j in range(len(ordered_groups)): a = ordered_groups[i] b = ordered_groups[j] assert (i < j) == (a < b) assert (i <= j) == (a <= b) assert (i == j) == (a == b) assert (i != j) == (a != b) assert (i >= j) == (a >= b) assert (i > j) == (a > b) assert not (Timestamp() == 0) assert Timestamp() != 0 assert not (Timestamp() == Duration()) assert Timestamp() != Duration()