コード例 #1
0
ファイル: optional.py プロジェクト: fremakvi/galois_compute
def ex_gcd(a, b=0b100011011):  # 采用书上的递归方法
    if b == 0:
        return a, 1, 0
    else:
        gcd, x_temp, y_temp = ex_gcd(b, compute.mod(a, b))
        x = y_temp
        y = x_temp ^ compute.mul(y_temp, compute.divide(a, b))

        return [gcd, x, y]
コード例 #2
0
def test_divide_zero():
    assert np.isinf(divide(1, 0))
コード例 #3
0
def test_divide(a, b, x):
    res = divide(a, b)
    assert res == pytest.approx(x)
コード例 #4
0
def test_divide():
    x = divide(1, 2)
    assert x == 0.5
コード例 #5
0
def test_divide():
    x = divide(1, 2)
    assert x == pytest.approx(0.5)
コード例 #6
0
def test_divide_array():
    a = np.array([1, 1, 1])
    b = np.array([2, 2, 2])
    x = divide(a, b)
    assert_allclose(x, np.array([0.5, 0.5, 0.5]))
コード例 #7
0
def test_divide():
    x = divide(1,2)
    print(x)
    assert x == 0.5
コード例 #8
0
def test_divide_array(a, b, x):
    assert_allclose(divide(a, b), x, rtol=1e-4)
コード例 #9
0
def test_multiply():
    x = divide(2, 2)
    assert x == 4
コード例 #10
0
def test_divide_zero():
    x = divide(2, 0)
    assert np.isinf(x)
コード例 #11
0
def test_divide(a, b, x, dtype):
    res = divide(a, b)
    assert res == pytest.approx(x)
    assert np.dtype(type(res)) == dtype
コード例 #12
0
def test_divide :
    res=divide(1,2)
    assert res==pytest.approx(x)
コード例 #13
0
ファイル: test_compute.py プロジェクト: glemaitre/tmp
def test_divide(lop, rop, res):
    x = divide(lop, rop)
    assert x == pytest.approx(res)
コード例 #14
0
def test_divide(a, b, x):
    res = divide(a, b)
    print(x)
    assert res == pytest.approx(
        x)  #better, because can occur some imprecisions due to type