netgen/tests/pytest/test_array.py

18 lines
388 B
Python
Raw Normal View History

2019-09-11 02:01:05 +05:00
from pyngcore import *
from numpy import sort, array
def test_array_numpy():
2019-09-11 11:27:04 +05:00
a = Array_int_unsigned_long(5)
2019-09-11 02:01:05 +05:00
a[:] = 0
a[3:] = 2
assert(sum(a) == 4)
a[1] = 5
b = sort(a)
assert(all(b == array([0,0,2,2,5])))
assert(all(a == array([0,5,0,2,2])))
a.NumPy().sort()
assert(all(a == array([0,0,2,2,5])))
if __name__ == "__main__":
test_array_numpy()