Example #1
0
def test_Z2Charge_raises():
    np.random.seed(10)
    charges = np.array([-1, 0, 1, 2])
    with pytest.raises(ValueError):
        Z2Charge(charges)
    with pytest.raises(ValueError, match="Z2 charges can only"):
        Z2Charge.random(10, -1, 1)
    with pytest.raises(ValueError, match="Z2 charges can only"):
        Z2Charge.random(10, 0, 2)
Example #2
0
def test_Z2Charge_random():
    np.random.seed(10)
    z2 = Z2Charge.random(10, 0, 1)
    assert np.all(np.isin(z2.charges.ravel(), [0, 1]))