Python numpy.testing 模块,assert_approx_equal() 实例源码

我们从Python开源项目中,提取了以下2个代码示例,用于说明如何使用numpy.testing.assert_approx_equal()

项目:mglex    作者:fungs    | 项目源码 | 文件源码
def assert_probmatrix(mat):
    is_sum = mat.sum(dtype=np.float32)
    should_sum = mat.shape[0]
    assert_approx_equal(is_sum, should_sum, significant=0)
    [assert_approx_equal(rowsum, 1., significant=1) for rowsum in mat.sum(axis=1, dtype=np.float32)]
项目:mizani    作者:has2k1    | 项目源码 | 文件源码
def test_seq():
    result = seq(4.1, 5.2, 0.1)
    npt.assert_approx_equal(result[-1], 5.2)

    result = seq(1, 10, length_out=10)
    npt.assert_array_equal(result, range(1, 11))

    with pytest.raises(ValueError):
        seq(1, 10, length_out=0)