예제 #1
0
 def func(dtype):
     d1 = distance(shape, center=center, scale=scale, dtype=dtype)
     d2 = _distance_slow(shape, center, scale, dtype)
     assert_same(d1, ref)
     assert_same(d2, ref)
     distance(shape, center=center, scale=scale, dtype=dtype, out=d1)
     _distance_slow(shape, center, scale, dtype, d2)
     assert_same(d1, ref)
     assert_same(d2, ref)
예제 #2
0
 def func(dtype):
     d1 = distance(shape, center=center, scale=scale, dtype=dtype)
     d2 = _distance_slow(shape, center, scale, dtype)
     assert_same(d1, ref)
     assert_same(d2, ref)
     distance(shape, center=center, scale=scale, dtype=dtype, out=d1)
     _distance_slow(shape, center, scale, dtype, d2)
     assert_same(d1, ref)
     assert_same(d2, ref)
예제 #3
0
 def integrated_profile_slow(input, center=None, scale=1, bin=1):
     d = distance(input.shape, center=center, scale=scale)
     m = int(np.max(d))
     x = np.ndarray(m + 1)
     y = np.ndarray(m + 1)
     for i in range(m + 1):
         x[i] = (i + 1) * bin
         y[i] = np.sum(input[d < x[i]])
     return x * scale, y * scale**2
예제 #4
0
 def integrated_profile_slow(input, center=None, scale=1, bin=1):
     d = distance(input.shape, center=center, scale=scale)
     m = int(np.max(d))
     x = np.ndarray(m + 1)
     y = np.ndarray(m + 1)
     for i in range(m + 1):
         x[i] = (i + 1) * bin
         y[i] = np.sum(input[d < x[i]])
     return x * scale, y * scale**2
예제 #5
0
 def profile_slow(input, center=None, scale=1., bin=1.):
     d = distance(input.shape, center=center, scale=scale)
     d /= bin
     d = d.astype(int)
     m = int(np.max(d))
     p = np.ndarray(m + 1)
     n = np.zeros(m + 1, int)
     for i in range(m + 1):
         mask = d == i
         p[i] = np.mean(input[mask])
         n[i] = np.sum(mask)
     return p, n
예제 #6
0
 def profile_slow(input, center=None, scale=1., bin=1.):
     d = distance(input.shape, center=center, scale=scale)
     d /= bin
     d = d.astype(int)
     m = int(np.max(d))
     p = np.ndarray(m + 1)
     n = np.zeros(m + 1, int)
     for i in range(m + 1):
         mask = d == i
         p[i] = np.mean(input[mask])
         n[i] = np.sum(mask)
     return p, n
예제 #7
0
def test_integrated_profile():
    def integrated_profile_slow(input, center=None, scale=1, bin=1):
        d = distance(input.shape, center=center, scale=scale)
        m = int(np.max(d))
        x = np.ndarray(m + 1)
        y = np.ndarray(m + 1)
        for i in range(m + 1):
            x[i] = (i + 1) * bin
            y[i] = np.sum(input[d < x[i]])
        return x * scale, y * scale**2
    d = distance((10, 20))
    bin = 2
    center = (4, 5)
    scale = 0.4
    x, y = integrated_profile(d, bin=bin, center=center, scale=scale)
    x_ref, y_ref = integrated_profile_slow(d, bin=bin, center=center,
                                           scale=scale)
    assert_same(x, x_ref[0:y.size])
    assert_same(y, y_ref[0:y.size])
예제 #8
0
def test_profile():
    def profile_slow(input, center=None, scale=1., bin=1.):
        d = distance(input.shape, center=center, scale=scale)
        d /= bin
        d = d.astype(int)
        m = int(np.max(d))
        p = np.ndarray(m + 1)
        n = np.zeros(m + 1, int)
        for i in range(m + 1):
            mask = d == i
            p[i] = np.mean(input[mask])
            n[i] = np.sum(mask)
        return p, n
    d = distance((10, 20))
    center = (4, 5)
    scale = 0.4
    bin = 2
    x, y, n = profile(d, center=center, scale=scale, bin=bin, histogram=True)
    y_ref, n_ref = profile_slow(d, center=center, scale=scale, bin=bin)
    assert_same(y, y_ref[0:y.size])
    assert_same(n, n_ref[0:n.size])
예제 #9
0
def test_integrated_profile():
    def integrated_profile_slow(input, center=None, scale=1, bin=1):
        d = distance(input.shape, center=center, scale=scale)
        m = int(np.max(d))
        x = np.ndarray(m + 1)
        y = np.ndarray(m + 1)
        for i in range(m + 1):
            x[i] = (i + 1) * bin
            y[i] = np.sum(input[d < x[i]])
        return x * scale, y * scale**2

    d = distance((10, 20))
    bin = 2
    center = (4, 5)
    scale = 0.4
    x, y = integrated_profile(d, bin=bin, center=center, scale=scale)
    x_ref, y_ref = integrated_profile_slow(d,
                                           bin=bin,
                                           center=center,
                                           scale=scale)
    assert_same(x, x_ref[0:y.size])
    assert_same(y, y_ref[0:y.size])
예제 #10
0
def test_profile():
    def profile_slow(input, center=None, scale=1., bin=1.):
        d = distance(input.shape, center=center, scale=scale)
        d /= bin
        d = d.astype(int)
        m = int(np.max(d))
        p = np.ndarray(m + 1)
        n = np.zeros(m + 1, int)
        for i in range(m + 1):
            mask = d == i
            p[i] = np.mean(input[mask])
            n[i] = np.sum(mask)
        return p, n

    d = distance((10, 20))
    center = (4, 5)
    scale = 0.4
    bin = 2
    x, y, n = profile(d, center=center, scale=scale, bin=bin, histogram=True)
    y_ref, n_ref = profile_slow(d, center=center, scale=scale, bin=bin)
    assert_same(y, y_ref[0:y.size])
    assert_same(n, n_ref[0:n.size])