Example #1
0
    def test_ufunc_custom_out(self):
        # Test ufunc with built in input types and custom output type

        a = np.array([0, 1, 2], dtype='i8')
        b = np.array([0, 1, 2], dtype='i8')
        c = np.empty(3, dtype=rational)

        # Output must be specified so numpy knows what
        # ufunc signature to look for
        result = test_add(a, b, c)
        assert_equal(result, np.array([0, 2, 4], dtype=rational))

        # no output type should raise TypeError
        assert_raises(TypeError, test_add, a, b)
Example #2
0
    def test_ufunc_custom_out(self):
        # Test ufunc with built in input types and custom output type

        a = np.array([0, 1, 2], dtype='i8')
        b = np.array([0, 1, 2], dtype='i8')
        c = np.empty(3, dtype=rational)

        # Output must be specified so numpy knows what
        # ufunc signature to look for
        result = test_add(a, b, c)
        assert_equal(result, np.array([0, 2, 4], dtype=rational))

        # no output type should raise TypeError
        assert_raises(TypeError, test_add, a, b)