Exemple #1
0
def test_histogramdd_bins_array_of_scalars(bins):
    rng = np.random.RandomState(42)
    sample = rng.randn(1024 * 128 // len(bins), len(bins))
    H_np, edges_np = np.histogramdd(sample, bins)
    H_mp, edges_mp = mp.histogramdd(sample, bins)
    assert type(edges_np) == type(edges_mp)
    assert len(edges_np) == len(edges_mp)
    assert all(n.dtype == m.dtype for n, m in zip(edges_np, edges_mp))
    assert all(n.ndim == m.ndim for n, m in zip(edges_np, edges_mp))
    assert all(n.shape == m.shape for n, m in zip(edges_np, edges_mp))
    assert all(np.allclose(n, m) for n, m in zip(edges_np, edges_mp))
    assert H_np.dtype == H_mp.dtype
    assert H_np.ndim == H_mp.ndim
    assert H_np.shape == H_mp.shape
    assert H_np.sum() == H_mp.sum()
    assert np.allclose(H_np, H_mp)
Exemple #2
0
def test_histogramdd_sample_ndarray():
    rng = np.random.RandomState(42)
    sample = rng.randn(100, 3)
    H_np, edges_np = np.histogramdd(sample)
    H_mp, edges_mp = mp.histogramdd(sample)
    assert type(edges_np) == type(edges_mp)
    assert len(edges_np) == len(edges_mp)
    assert all(n.dtype == m.dtype for n, m in zip(edges_np, edges_mp))
    assert all(n.ndim == m.ndim for n, m in zip(edges_np, edges_mp))
    assert all(n.shape == m.shape for n, m in zip(edges_np, edges_mp))
    assert all(np.allclose(n, m) for n, m in zip(edges_np, edges_mp))
    assert H_np.dtype == H_mp.dtype
    assert H_np.ndim == H_mp.ndim
    assert H_np.shape == H_mp.shape
    assert H_np.sum() == H_mp.sum()
    assert np.allclose(H_np, H_mp)
Exemple #3
0
def test_histogramdd_bins_ndarray():
    rng = np.random.RandomState(42)
    sample = rng.randn(100, 3)
    bins = (np.arange(3), np.arange(5), np.arange(7))
    H_mp, edges_mp = mp.histogramdd(sample, bins)
Exemple #4
0
def test_histogramdd_sample_list():
    sample = [[1, 1, 2, 2, 3], [1, 2, 2, 3, 3], [2, 2, 3, 3, 4]]
    H_mp, edges_mp = mp.histogramdd(sample)