1
0
mirror of https://github.com/exaloop/codon.git synced 2025-06-03 15:03:52 +08:00
codon/test/numpy/test_pybridge.codon
A. R. Shajii b8c1eeed36
2025 updates (#619)
* 2025 updates

* Update ci.yml
2025-01-29 15:41:43 -05:00

20 lines
558 B
Python

import numpy as np
import numpy.pybridge
def check_roundtrip(a):
return (type(a).__from_py__(a.__to_py__()) == a).all()
@test
def test_pybridge():
a = np.arange(9).reshape(3, 3)
assert check_roundtrip(a)
assert check_roundtrip(a.astype(float))
assert check_roundtrip(a.astype(np.float32))
assert check_roundtrip(a + a * 2j)
assert check_roundtrip((a + a * 2j).astype(np.complex64))
assert check_roundtrip(a.T)
assert check_roundtrip(a[::2, ::2])
assert check_roundtrip(np.array(['aa', 'bb', 'cc']))
test_pybridge()