def test_numpy_wrappers():
    a1 = YTArray([1, 2, 3], 'cm')
    a2 = YTArray([2, 3, 4, 5, 6], 'cm')
    a3 = YTArray([7, 8, 9, 10, 11], 'cm')
    catenate_answer = [1, 2, 3, 2, 3, 4, 5, 6]
    intersect_answer = [2, 3]
    union_answer = [1, 2, 3, 4, 5, 6]
    vstack_answer = [[2, 3, 4, 5, 6], [7, 8, 9, 10, 11]]

    assert_array_equal(YTArray(catenate_answer, 'cm'), uconcatenate((a1, a2)))
    assert_array_equal(catenate_answer, np.concatenate((a1, a2)))

    assert_array_equal(YTArray(intersect_answer, 'cm'), uintersect1d(a1, a2))
    assert_array_equal(intersect_answer, np.intersect1d(a1, a2))

    assert_array_equal(YTArray(union_answer, 'cm'), uunion1d(a1, a2))
    assert_array_equal(union_answer, np.union1d(a1, a2))

    assert_array_equal(YTArray(catenate_answer, 'cm'), uhstack([a1, a2]))
    assert_array_equal(catenate_answer, np.hstack([a1, a2]))

    assert_array_equal(YTArray(vstack_answer, 'cm'), uvstack([a2, a3]))
    assert_array_equal(vstack_answer, np.vstack([a2, a3]))

    assert_array_equal(YTArray(vstack_answer, 'cm'), ustack([a2, a3]))
    assert_array_equal(vstack_answer, np.stack([a2, a3]))
예제 #2
0
def test_numpy_wrappers():
    a1 = YTArray([1, 2, 3], 'cm')
    a2 = YTArray([2, 3, 4, 5, 6], 'cm')
    catenate_answer = [1, 2, 3, 2, 3, 4, 5, 6]
    intersect_answer = [2, 3]
    union_answer = [1, 2, 3, 4, 5, 6]

    assert_array_equal(YTArray(catenate_answer, 'cm'), uconcatenate((a1, a2)))
    assert_array_equal(catenate_answer, np.concatenate((a1, a2)))

    assert_array_equal(YTArray(intersect_answer, 'cm'), uintersect1d(a1, a2))
    assert_array_equal(intersect_answer, np.intersect1d(a1, a2))

    assert_array_equal(YTArray(union_answer, 'cm'), uunion1d(a1, a2))
    assert_array_equal(union_answer, np.union1d(a1, a2))
def test_numpy_wrappers():
    a1 = YTArray([1, 2, 3], 'cm')
    a2 = YTArray([2, 3, 4, 5, 6], 'cm')
    catenate_answer = [1, 2, 3, 2, 3, 4, 5, 6]
    intersect_answer = [2, 3]
    union_answer = [1, 2, 3, 4, 5, 6]

    yield (assert_array_equal, YTArray(catenate_answer, 'cm'),
           uconcatenate((a1, a2)))
    yield assert_array_equal, catenate_answer, np.concatenate((a1, a2))

    yield (assert_array_equal, YTArray(intersect_answer, 'cm'),
           uintersect1d(a1, a2))
    yield assert_array_equal, intersect_answer, np.intersect1d(a1, a2)

    yield assert_array_equal, YTArray(union_answer, 'cm'), uunion1d(a1, a2)
    yield assert_array_equal, union_answer, np.union1d(a1, a2)