Skip to content

Commit

Permalink
Add PEP-3118 complex tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
skrah committed Mar 19, 2019
1 parent 0956c62 commit 9e2b49b
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion python/test_xnd.py
Original file line number Diff line number Diff line change
Expand Up @@ -3096,10 +3096,11 @@ def test_endian(self):
'h', 'i', 'l', 'q',
'H', 'I', 'L', 'Q',
'f', 'd',
'F', 'D',
]

if HAVE_PYTHON_36:
standard += 'e'
standard += ['e']

modifiers = ['', '<', '>']

Expand Down Expand Up @@ -3132,6 +3133,24 @@ def test_readonly(self):
self.assertEqual(x.tolist(), [1000, 2000, 3000])
check_copy_contiguous(self, y)

@unittest.skipIf(np is None, "numpy not found")
def test_complex(self):
x = xnd([1, 2, 3], dtype="complex64")
y = np.array(x)
self.assertEqual(memoryview(y).format, "Zf")

x = xnd([1, 2, 3], dtype="complex128")
y = np.array(x)
self.assertEqual(memoryview(y).format, "Zd")

x = np.array([1, 2, 3], dtype="complex64")
y = xnd.from_buffer(x)
self.assertEqual(memoryview(y).format, "=Zf")

x = np.array([1, 2, 3], dtype="complex128")
y = xnd.from_buffer(x)
self.assertEqual(memoryview(y).format, "=Zd")


class TestReshape(XndTestCase):

Expand Down

0 comments on commit 9e2b49b

Please sign in to comment.