Skip to content

Commit 85d1ba6

Browse files
committed
TST: test isreal(real array)
1 parent 69135b9 commit 85d1ba6

File tree

1 file changed

+5
-38
lines changed

1 file changed

+5
-38
lines changed

torch_np/tests/numpy_tests/lib/test_type_check.py

Lines changed: 5 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,6 @@ def test_cmplx(self):
157157
assert_(not isinstance(out, np.ndarray))
158158

159159

160-
@pytest.mark.xfail(reason="not implemented")
161160
class TestIscomplex:
162161

163162
def test_fail(self):
@@ -171,7 +170,6 @@ def test_pass(self):
171170
assert_array_equal(res, [1, 0, 0])
172171

173172

174-
@pytest.mark.xfail(reason="not implemented")
175173
class TestIsreal:
176174

177175
def test_pass(self):
@@ -184,6 +182,11 @@ def test_fail(self):
184182
res = isreal(z)
185183
assert_array_equal(res, [0, 1, 1])
186184

185+
def test_isreal_real(self):
186+
z = np.array([-1, 0, 1])
187+
res = isreal(z)
188+
assert res.all()
189+
187190

188191
@pytest.mark.xfail(reason="not implemented")
189192
class TestIscomplexobj:
@@ -202,42 +205,6 @@ def test_list(self):
202205
assert_(iscomplexobj([3, 1+0j, True]))
203206
assert_(not iscomplexobj([3, 1, True]))
204207

205-
def test_duck(self):
206-
class DummyComplexArray:
207-
@property
208-
def dtype(self):
209-
return np.dtype(complex)
210-
dummy = DummyComplexArray()
211-
assert_(iscomplexobj(dummy))
212-
213-
def test_pandas_duck(self):
214-
# This tests a custom np.dtype duck-typed class, such as used by pandas
215-
# (pandas.core.dtypes)
216-
class PdComplex(np.complex128):
217-
pass
218-
class PdDtype:
219-
name = 'category'
220-
names = None
221-
type = PdComplex
222-
kind = 'c'
223-
str = '<c16'
224-
base = np.dtype('complex128')
225-
class DummyPd:
226-
@property
227-
def dtype(self):
228-
return PdDtype
229-
dummy = DummyPd()
230-
assert_(iscomplexobj(dummy))
231-
232-
def test_custom_dtype_duck(self):
233-
class MyArray(list):
234-
@property
235-
def dtype(self):
236-
return complex
237-
238-
a = MyArray([1+0j, 2+0j, 3+0j])
239-
assert_(iscomplexobj(a))
240-
241208

242209
@pytest.mark.xfail(reason="not implemented")
243210
class TestIsrealobj:

0 commit comments

Comments
 (0)