Beispiel #1
0
 def test_random_accept_str_dtype(self):
     # anything that np.dtype can convert to a dtype should be accepted
     # for the dtype
     construct.random(10, 10, dtype='d')
Beispiel #2
0
 def test_random_sparse_matrix_returns_correct_number_of_non_zero_elements(
         self):
     # A 10 x 10 matrix, with density of 12.65%, should have 13 nonzero elements.
     # 10 x 10 x 0.1265 = 12.65, which should be rounded up to 13, not 12.
     sparse_matrix = construct.random(10, 10, density=0.1265)
     assert_equal(sparse_matrix.count_nonzero(), 13)
Beispiel #3
0
def _sprandn(m, n, density=0.01, format="coo", dtype=None, random_state=None):
    # Helper function for testing.
    random_state = check_random_state(random_state)
    data_rvs = random_state.standard_normal
    return construct.random(m, n, density, format, dtype, random_state,
                            data_rvs)