Example #1
0
 def test_duck(self):
     class DummyComplexArray:
         @property
         def dtype(self):
             return np.dtype(complex)
     dummy = DummyComplexArray()
     assert_(iscomplexobj(dummy))
Example #2
0
 def test_duck(self):
     class DummyComplexArray:
         @property
         def dtype(self):
             return np.dtype(complex)
     dummy = DummyComplexArray()
     assert_(iscomplexobj(dummy))
Example #3
0
    def test_custom_dtype_duck(self):
        class MyArray(list):
            @property
            def dtype(self):
                return complex

        a = MyArray([1 + 0j, 2 + 0j, 3 + 0j])
        assert_(iscomplexobj(a))
Example #4
0
    def test_custom_dtype_duck(self):
        class MyArray(list):
            @property
            def dtype(self):
                return complex

        a = MyArray([1+0j, 2+0j, 3+0j])
        assert_(iscomplexobj(a))
Example #5
0
 def test_basic(self):
     a = np.random.rand(10)
     b = real_if_close(a+1e-15j)
     assert_all(isrealobj(b))
     assert_array_equal(a, b)
     b = real_if_close(a+1e-7j)
     assert_all(iscomplexobj(b))
     b = real_if_close(a+1e-7j, tol=1e-6)
     assert_all(isrealobj(b))
Example #6
0
 def test_basic(self):
     a = np.random.rand(10)
     b = real_if_close(a + 1e-15j)
     assert_all(isrealobj(b))
     assert_array_equal(a, b)
     b = real_if_close(a + 1e-7j)
     assert_all(iscomplexobj(b))
     b = real_if_close(a + 1e-7j, tol=1e-6)
     assert_all(isrealobj(b))
Example #7
0
 def test_pandas_duck(self):
     # This tests a custom np.dtype duck-typed class, such as used by pandas
     # (pandas.core.dtypes)
     class PdComplex(np.complex128):
         pass
     class PdDtype(object):
         name = 'category'
         names = None
         type = PdComplex
         kind = 'c'
         str = '<c16'
         base = np.dtype('complex128')
     class DummyPd:
         @property
         def dtype(self):
             return PdDtype
     dummy = DummyPd()
     assert_(iscomplexobj(dummy))
Example #8
0
 def test_pandas_duck(self):
     # This tests a custom np.dtype duck-typed class, such as used by pandas
     # (pandas.core.dtypes)
     class PdComplex(np.complex128):
         pass
     class PdDtype(object):
         name = 'category'
         names = None
         type = PdComplex
         kind = 'c'
         str = '<c16'
         base = np.dtype('complex128')
     class DummyPd:
         @property
         def dtype(self):
             return PdDtype
     dummy = DummyPd()
     assert_(iscomplexobj(dummy))
    def test_pandas_duck(self):
        # This tests a custom np.dtype duck-typed class, such as used by pandas
        # (pandas.core.dtypes)
        class PdComplex(np.complex128):
            pass

        class PdDtype:
            name = "category"
            names = None
            type = PdComplex
            kind = "c"
            str = "<c16"
            base = np.dtype("complex128")

        class DummyPd:
            @property
            def dtype(self):
                return PdDtype

        dummy = DummyPd()
        assert_(iscomplexobj(dummy))
Example #10
0
 def test_basic(self):
     z = np.array([-1, 0, 1])
     assert_(not iscomplexobj(z))
     z = np.array([-1j, 0, -1])
     assert_(iscomplexobj(z))
Example #11
0
 def test_list(self):
     assert_(iscomplexobj([3, 1 + 0j, True]))
     assert_(not iscomplexobj([3, 1, True]))
Example #12
0
 def test_scalar(self):
     assert_(not iscomplexobj(1.0))
     assert_(iscomplexobj(1 + 0j))
Example #13
0
 def test_basic(self):
     z = np.array([-1, 0, 1])
     assert_(not iscomplexobj(z))
     z = np.array([-1j, 0, -1])
     assert_(iscomplexobj(z))
Example #14
0
 def test_list(self):
     assert_(iscomplexobj([3, 1+0j, True]))
     assert_(not iscomplexobj([3, 1, True]))
Example #15
0
 def test_scalar(self):
     assert_(not iscomplexobj(1.0))
     assert_(iscomplexobj(1+0j))