Skip to content

Commit 22e7343

Browse files
committed
update tests
1 parent e341f0e commit 22e7343

File tree

8 files changed

+92
-14
lines changed

8 files changed

+92
-14
lines changed

plotoptix/tests/test_020_scene.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ def test070_start_rt(self):
195195

196196
TestScene.scene.start()
197197
self.assertTrue(TestScene.scene.is_started(), msg="Scene did not flip to _is_started=True state.")
198-
self.assertTrue(TestScene.scene.isAlive(), msg="Raytracing thread is not alive.")
198+
self.assertTrue(TestScene.scene.is_alive(), msg="Raytracing thread is not alive.")
199199
TestScene.is_alive = True
200200

201201
def test080_camera(self):
@@ -263,7 +263,7 @@ def test999_close(self):
263263
TestScene.scene.close()
264264
TestScene.scene.join(10)
265265
self.assertTrue(TestScene.scene.is_closed(), msg="Scene did not flip to _is_closed=True state.")
266-
self.assertFalse(TestScene.scene.isAlive(), msg="Raytracing thread closing timed out.")
266+
self.assertFalse(TestScene.scene.is_alive(), msg="Raytracing thread closing timed out.")
267267
TestScene.is_alive = False
268268

269269
@classmethod

plotoptix/tests/test_030_callbacks.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def test010_setup_and_start(self):
8585

8686
TestCallbacks.scene.start()
8787
self.assertTrue(TestCallbacks.scene.is_started(), msg="Scene did not flip to _is_started=True state.")
88-
self.assertTrue(TestCallbacks.scene.isAlive(), msg="Raytracing thread is not alive.")
88+
self.assertTrue(TestCallbacks.scene.is_alive(), msg="Raytracing thread is not alive.")
8989
TestCallbacks.is_alive = True
9090

9191
self.assertTrue(TestCallbacks.initialization_trigs == 1,
@@ -145,7 +145,7 @@ def test999_close(self):
145145
TestCallbacks.scene.close()
146146
TestCallbacks.scene.join(10)
147147
self.assertTrue(TestCallbacks.scene.is_closed(), msg="Scene did not flip to _is_closed=True state.")
148-
self.assertFalse(TestCallbacks.scene.isAlive(), msg="Raytracing thread closing timed out.")
148+
self.assertFalse(TestCallbacks.scene.is_alive(), msg="Raytracing thread closing timed out.")
149149
TestCallbacks.is_alive = False
150150

151151
@classmethod

plotoptix/tests/test_040_postprocessing.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def test998_start_rt(self):
9292

9393
TestScene.scene.start()
9494
self.assertTrue(TestScene.scene.is_started(), msg="Scene did not flip to _is_started=True state.")
95-
self.assertTrue(TestScene.scene.isAlive(), msg="Raytracing thread is not alive.")
95+
self.assertTrue(TestScene.scene.is_alive(), msg="Raytracing thread is not alive.")
9696
TestScene.is_alive = True
9797

9898

@@ -102,7 +102,7 @@ def test999_close(self):
102102
TestScene.scene.close()
103103
TestScene.scene.join(10)
104104
self.assertTrue(TestScene.scene.is_closed(), msg="Scene did not flip to _is_closed=True state.")
105-
self.assertFalse(TestScene.scene.isAlive(), msg="Raytracing thread closing timed out.")
105+
self.assertFalse(TestScene.scene.is_alive(), msg="Raytracing thread closing timed out.")
106106
TestScene.is_alive = False
107107

108108
@classmethod

plotoptix/tests/test_050_save_output.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def test010_setup_and_start(self):
5353

5454
TestOutput.scene.start()
5555
self.assertTrue(TestOutput.scene.is_started(), msg="Scene did not flip to _is_started=True state.")
56-
self.assertTrue(TestOutput.scene.isAlive(), msg="Raytracing thread is not alive.")
56+
self.assertTrue(TestOutput.scene.is_alive(), msg="Raytracing thread is not alive.")
5757
TestOutput.is_alive = True
5858

5959
self.assertFalse(TestOutput.scene.encoder_is_open(), msg="Encoder is_open is True on startup.")
@@ -102,7 +102,7 @@ def test999_close(self):
102102
TestOutput.scene.close()
103103
TestOutput.scene.join(10)
104104
self.assertTrue(TestOutput.scene.is_closed(), msg="Scene did not flip to _is_closed=True state.")
105-
self.assertFalse(TestOutput.scene.isAlive(), msg="Raytracing thread closing timed out.")
105+
self.assertFalse(TestOutput.scene.is_alive(), msg="Raytracing thread closing timed out.")
106106
TestOutput.is_alive = False
107107

108108
@classmethod

plotoptix/tests/test_070_scene_io.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def test010_setup_and_start(self):
4646

4747
TestOutput.scene.start()
4848
self.assertTrue(TestOutput.scene.is_started(), msg="Scene did not flip to _is_started=True state.")
49-
self.assertTrue(TestOutput.scene.isAlive(), msg="Raytracing thread is not alive.")
49+
self.assertTrue(TestOutput.scene.is_alive(), msg="Raytracing thread is not alive.")
5050
TestOutput.is_alive = True
5151

5252
def test020_save_scene(self):
@@ -95,7 +95,7 @@ def test999_close(self):
9595
TestOutput.scene.close()
9696
TestOutput.scene.join(10)
9797
self.assertTrue(TestOutput.scene.is_closed(), msg="Scene did not flip to _is_closed=True state.")
98-
self.assertFalse(TestOutput.scene.isAlive(), msg="Raytracing thread closing timed out.")
98+
self.assertFalse(TestOutput.scene.is_alive(), msg="Raytracing thread closing timed out.")
9999
TestOutput.is_alive = False
100100

101101
@classmethod

plotoptix/tests/test_080_meshes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def test010_setup_and_start(self):
5050

5151
TestOutput.scene.start()
5252
self.assertTrue(TestOutput.scene.is_started(), msg="Scene did not flip to _is_started=True state.")
53-
self.assertTrue(TestOutput.scene.isAlive(), msg="Raytracing thread is not alive.")
53+
self.assertTrue(TestOutput.scene.is_alive(), msg="Raytracing thread is not alive.")
5454
TestOutput.is_alive = True
5555

5656
def test999_close(self):
@@ -59,7 +59,7 @@ def test999_close(self):
5959
TestOutput.scene.close()
6060
TestOutput.scene.join(10)
6161
self.assertTrue(TestOutput.scene.is_closed(), msg="Scene did not flip to _is_closed=True state.")
62-
self.assertFalse(TestOutput.scene.isAlive(), msg="Raytracing thread closing timed out.")
62+
self.assertFalse(TestOutput.scene.is_alive(), msg="Raytracing thread closing timed out.")
6363
TestOutput.is_alive = False
6464

6565
@classmethod

plotoptix/tests/test_090_buffers_readback.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def test010_setup_and_start(self):
6767

6868
TestCallbacks.scene.start()
6969
self.assertTrue(TestCallbacks.scene.is_started(), msg="Scene did not flip to _is_started=True state.")
70-
self.assertTrue(TestCallbacks.scene.isAlive(), msg="Raytracing thread is not alive.")
70+
self.assertTrue(TestCallbacks.scene.is_alive(), msg="Raytracing thread is not alive.")
7171
TestCallbacks.is_alive = True
7272

7373
t = 0;
@@ -87,7 +87,7 @@ def test999_close(self):
8787
TestCallbacks.scene.close()
8888
TestCallbacks.scene.join(10)
8989
self.assertTrue(TestCallbacks.scene.is_closed(), msg="Scene did not flip to _is_closed=True state.")
90-
self.assertFalse(TestCallbacks.scene.isAlive(), msg="Raytracing thread closing timed out.")
90+
self.assertFalse(TestCallbacks.scene.is_alive(), msg="Raytracing thread closing timed out.")
9191
TestCallbacks.is_alive = False
9292

9393
@classmethod
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
from unittest import TestCase
2+
3+
from plotoptix import NpOptiX
4+
5+
import numpy as np
6+
7+
class AccTestOptiX(NpOptiX):
8+
9+
def __init__(self):
10+
11+
super().__init__(
12+
width=128, height=96,
13+
start_now=False,
14+
log_level='INFO'
15+
)
16+
17+
class TestAccess(TestCase):
18+
19+
scene = None
20+
data = None
21+
r = None
22+
is_alive = False
23+
24+
@classmethod
25+
def setUpClass(cls):
26+
print("################ Test 100: direct access. ###################################")
27+
n = 100
28+
rx = (-10, 10)
29+
30+
TestAccess.r = 0.85 * 0.5 * (rx[1] - rx[0]) / (n - 1)
31+
32+
x = np.linspace(rx[0], rx[1], n)
33+
z = np.linspace(rx[0], rx[1], n)
34+
X, Z = np.meshgrid(x, z)
35+
36+
TestAccess.data = np.stack([X.flatten(), np.zeros(n*n), Z.flatten()], axis=1)
37+
38+
def test010_setup_and_start(self):
39+
TestAccess.scene = AccTestOptiX()
40+
TestAccess.scene.set_param(min_accumulation_step=2, max_accumulation_frames=6)
41+
42+
TestAccess.scene.set_data("balls", pos=TestAccess.data, c=0.82, r=TestAccess.r)
43+
44+
TestAccess.scene.setup_camera("cam1")
45+
TestAccess.scene.setup_light("light1", color=10, radius=3)
46+
TestAccess.scene.set_background(0)
47+
TestAccess.scene.set_ambient(0)
48+
49+
TestAccess.scene.start()
50+
self.assertTrue(TestAccess.scene.is_started(), msg="Scene did not flip to _is_started=True state.")
51+
self.assertTrue(TestAccess.scene.is_alive(), msg="Raytracing thread is not alive.")
52+
TestAccess.is_alive = True
53+
54+
def test020_write_read_geom(self):
55+
rb_data = TestAccess.scene.get_data("balls", "Positions")
56+
self.assertTrue(np.allclose(TestAccess.data, rb_data), msg="Incorrect values in data readback.")
57+
58+
shift = np.linspace(0, 1, TestAccess.data.shape[0])
59+
mod_data = TestAccess.data.copy()
60+
mod_data[:,1] += shift
61+
TestAccess.scene.update_raw_data("balls", pos=mod_data)
62+
rb_data = TestAccess.scene.get_data("balls", "Positions")
63+
self.assertTrue(np.allclose(mod_data, rb_data), msg="Incorrect values in modified data readback.")
64+
65+
def test999_close(self):
66+
self.assertTrue(TestAccess.scene is not None and TestAccess.is_alive, msg="Wrong state of the test class.")
67+
68+
TestAccess.scene.close()
69+
TestAccess.scene.join(10)
70+
self.assertTrue(TestAccess.scene.is_closed(), msg="Scene did not flip to _is_closed=True state.")
71+
self.assertFalse(TestAccess.scene.is_alive(), msg="Raytracing thread closing timed out.")
72+
TestAccess.is_alive = False
73+
74+
@classmethod
75+
def tearDownClass(cls):
76+
cls.assertFalse(cls, cls.is_alive, msg="Wrong state of the test class.")
77+
print("Test 100: completed.")
78+

0 commit comments

Comments
 (0)