Skip to content

Commit 5cd788d

Browse files
authored
Merge pull request #34 from pyscience-projects/positional_only_example
[tests] call high level funcs with positional args only
2 parents 25fab53 + cc42c91 commit 5cd788d

1 file changed

Lines changed: 40 additions & 0 deletions

File tree

tests/dummy.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import os
33
import runpy
44

5+
import numpy as np
56

67
def test_imports():
78
import pyevtk
@@ -26,3 +27,42 @@ def test_compat_lib():
2627
assert pyevtk.vtk is evtk.vtk
2728
assert pyevtk.xml is evtk.xml
2829

30+
31+
def test_positional_args_only_image():
32+
from pyevtk.hl import imageToVTK
33+
nx, ny, nz = 6, 6, 2
34+
ncells = nx * ny * nz
35+
npoints = (nx + 1) * (ny + 1) * (nz + 1)
36+
37+
# Variables
38+
pressure = np.random.rand(ncells).reshape((nx, ny, nz), order="C")
39+
temp = np.random.rand(npoints).reshape((nx + 1, ny + 1, nz + 1))
40+
41+
imageToVTK(
42+
"./image", (0.0, 0.0, 0.0), (1.0, 1.0, 1.0), {"pressure": pressure}, {"temp": temp}
43+
)
44+
45+
46+
def test_positional_args_only_grid():
47+
from pyevtk.hl import gridToVTK
48+
nx, ny, nz = 6, 6, 2
49+
50+
ncells = nx * ny * nz
51+
npoints = (nx + 1) * (ny + 1) * (nz + 1)
52+
53+
x = np.zeros((nx + 1, ny + 1, nz + 1))
54+
y = np.zeros((nx + 1, ny + 1, nz + 1))
55+
z = np.zeros((nx + 1, ny + 1, nz + 1))
56+
57+
# Variables
58+
pressure = np.random.rand(ncells).reshape((nx, ny, nz))
59+
temp = np.random.rand(npoints).reshape((nx + 1, ny + 1, nz + 1))
60+
61+
gridToVTK(
62+
"./structured",
63+
x,
64+
y,
65+
z,
66+
{"pressure": pressure},
67+
{"temp": temp},
68+
)

0 commit comments

Comments
 (0)