Exemplo n.º 1
0
 def test_bug_8278(self):
     check_free_memory(8000)
     use_solver(useUmfpack=True)
     A, b = setup_bug_8278()
     A = A.tocsc()
     f = factorized(A)
     x = f(b)
     assert_array_almost_equal(A @ x, b)
Exemplo n.º 2
0
 def test_ilp64_bisplrep(self):
     check_free_memory(28000)  # VM size, doesn't actually use the pages
     x = np.linspace(0, 1, 400)
     y = np.linspace(0, 1, 400)
     x, y = np.meshgrid(x, y)
     z = np.zeros_like(x)
     tck = bisplrep(x, y, z, kx=3, ky=3, s=0)
     assert_allclose(bisplev(0.5, 0.5, tck), 0.0)
Exemplo n.º 3
0
    def setup_method(self):
        assert self.n**2 > np.iinfo(np.int32).max

        # check there's enough memory even if everything is run at the
        # same time
        try:
            parallel_count = int(os.environ.get('PYTEST_XDIST_WORKER_COUNT', '1'))
        except ValueError:
            parallel_count = np.inf

        check_free_memory(3000 * parallel_count)
Exemplo n.º 4
0
    def test_concatenate_int32_overflow(self):
        """ test for indptr overflow when concatenating matrices """
        check_free_memory(30000)

        n = 33000
        A = csr_matrix(np.ones((n, n), dtype=bool))
        B = A.copy()
        C = construct._compressed_sparse_stack((A, B), 0)

        assert_(np.all(np.equal(np.diff(C.indptr), n)))
        assert_equal(C.indices.dtype, np.int64)
        assert_equal(C.indptr.dtype, np.int64)
Exemplo n.º 5
0
 def test_concatenate_int32_overflow(self):
     """ test for indptr overflow when concatenating matrices """
     check_free_memory(30000)
     
     n = 33000
     A = csr_matrix(np.ones((n, n), dtype=bool))
     B = A.copy()
     C = construct._compressed_sparse_stack((A,B), 0)
     
     assert_(np.all(np.equal(np.diff(C.indptr), n)))
     assert_equal(C.indices.dtype, np.int64)
     assert_equal(C.indptr.dtype, np.int64)
Exemplo n.º 6
0
def test_csr_matmat_int64_overflow():
    n = 3037000500
    assert n**2 > np.iinfo(np.int64).max

    # the test would take crazy amounts of memory
    check_free_memory(n * (8*2 + 1) * 3 / 1e6)

    # int64 overflow
    data = np.ones((n,), dtype=np.int8)
    indptr = np.arange(n+1, dtype=np.int64)
    indices = np.zeros(n, dtype=np.int64)
    a = csr_matrix((data, indices, indptr))
    b = a.T

    assert_raises(RuntimeError, a.dot, b)
Exemplo n.º 7
0
def test_nnz_overflow():
    # Regression test for gh-7230 / gh-7871, checking that coo_todense
    # with nnz > int32max doesn't overflow.
    nnz = np.iinfo(np.int32).max + 1
    # Ensure ~20 GB of RAM is free to run this test.
    check_free_memory((4 + 4 + 1) * nnz / 1e6 + 0.5)

    # Use nnz duplicate entries to keep the dense version small.
    row = np.zeros(nnz, dtype=np.int32)
    col = np.zeros(nnz, dtype=np.int32)
    data = np.zeros(nnz, dtype=np.int8)
    data[-1] = 4
    s = coo_matrix((data, (row, col)), shape=(1, 1), copy=False)
    # Sums nnz duplicates to produce a 1x1 array containing 4.
    d = s.toarray()

    assert_allclose(d, [[4]])
Exemplo n.º 8
0
 def test_bug_8278(self):
     check_free_memory(8000)
     use_solver(useUmfpack=True)
     A, b = setup_bug_8278()
     x = spsolve(A, b)
     assert_array_almost_equal(A @ x, b)