Skip to content

Commit dab8050

Browse files
committed
Add mip.replicate
1 parent f0f36fb commit dab8050

7 files changed

Lines changed: 107 additions & 55 deletions

File tree

examples/cells.ipynb

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616
"id": "59e8a2c3",
1717
"metadata": {
1818
"execution": {
19-
"iopub.execute_input": "2025-05-06T12:53:52.433387Z",
20-
"iopub.status.busy": "2025-05-06T12:53:52.433284Z",
21-
"iopub.status.idle": "2025-05-06T12:53:52.838642Z",
22-
"shell.execute_reply": "2025-05-06T12:53:52.838256Z"
19+
"iopub.execute_input": "2025-05-06T13:05:18.607419Z",
20+
"iopub.status.busy": "2025-05-06T13:05:18.607317Z",
21+
"iopub.status.idle": "2025-05-06T13:05:19.011623Z",
22+
"shell.execute_reply": "2025-05-06T13:05:19.011207Z"
2323
},
2424
"vscode": {
2525
"languageId": "plaintext"
@@ -45,10 +45,10 @@
4545
"id": "97c2c4ed",
4646
"metadata": {
4747
"execution": {
48-
"iopub.execute_input": "2025-05-06T12:53:52.840419Z",
49-
"iopub.status.busy": "2025-05-06T12:53:52.840251Z",
50-
"iopub.status.idle": "2025-05-06T12:53:52.908551Z",
51-
"shell.execute_reply": "2025-05-06T12:53:52.908213Z"
48+
"iopub.execute_input": "2025-05-06T13:05:19.013059Z",
49+
"iopub.status.busy": "2025-05-06T13:05:19.012881Z",
50+
"iopub.status.idle": "2025-05-06T13:05:19.081737Z",
51+
"shell.execute_reply": "2025-05-06T13:05:19.081415Z"
5252
},
5353
"vscode": {
5454
"languageId": "plaintext"
@@ -90,10 +90,10 @@
9090
"id": "ed16156a",
9191
"metadata": {
9292
"execution": {
93-
"iopub.execute_input": "2025-05-06T12:53:52.909905Z",
94-
"iopub.status.busy": "2025-05-06T12:53:52.909639Z",
95-
"iopub.status.idle": "2025-05-06T12:53:53.802389Z",
96-
"shell.execute_reply": "2025-05-06T12:53:53.802016Z"
93+
"iopub.execute_input": "2025-05-06T13:05:19.083047Z",
94+
"iopub.status.busy": "2025-05-06T13:05:19.082878Z",
95+
"iopub.status.idle": "2025-05-06T13:05:19.998330Z",
96+
"shell.execute_reply": "2025-05-06T13:05:19.997888Z"
9797
},
9898
"vscode": {
9999
"languageId": "plaintext"
@@ -158,10 +158,10 @@
158158
"id": "d35452de",
159159
"metadata": {
160160
"execution": {
161-
"iopub.execute_input": "2025-05-06T12:53:53.803620Z",
162-
"iopub.status.busy": "2025-05-06T12:53:53.803512Z",
163-
"iopub.status.idle": "2025-05-06T12:53:54.175648Z",
164-
"shell.execute_reply": "2025-05-06T12:53:54.175188Z"
161+
"iopub.execute_input": "2025-05-06T13:05:19.999487Z",
162+
"iopub.status.busy": "2025-05-06T13:05:19.999347Z",
163+
"iopub.status.idle": "2025-05-06T13:05:20.407688Z",
164+
"shell.execute_reply": "2025-05-06T13:05:20.407201Z"
165165
},
166166
"vscode": {
167167
"languageId": "plaintext"
@@ -210,10 +210,10 @@
210210
"id": "c33d38bc",
211211
"metadata": {
212212
"execution": {
213-
"iopub.execute_input": "2025-05-06T12:53:54.177667Z",
214-
"iopub.status.busy": "2025-05-06T12:53:54.177557Z",
215-
"iopub.status.idle": "2025-05-06T12:53:54.182771Z",
216-
"shell.execute_reply": "2025-05-06T12:53:54.182383Z"
213+
"iopub.execute_input": "2025-05-06T13:05:20.411930Z",
214+
"iopub.status.busy": "2025-05-06T13:05:20.411810Z",
215+
"iopub.status.idle": "2025-05-06T13:05:20.417264Z",
216+
"shell.execute_reply": "2025-05-06T13:05:20.416837Z"
217217
},
218218
"vscode": {
219219
"languageId": "plaintext"
@@ -240,10 +240,10 @@
240240
"id": "ea6ed2dd",
241241
"metadata": {
242242
"execution": {
243-
"iopub.execute_input": "2025-05-06T12:53:54.183812Z",
244-
"iopub.status.busy": "2025-05-06T12:53:54.183709Z",
245-
"iopub.status.idle": "2025-05-06T12:53:54.637973Z",
246-
"shell.execute_reply": "2025-05-06T12:53:54.637524Z"
243+
"iopub.execute_input": "2025-05-06T13:05:20.418966Z",
244+
"iopub.status.busy": "2025-05-06T13:05:20.418856Z",
245+
"iopub.status.idle": "2025-05-06T13:05:20.888270Z",
246+
"shell.execute_reply": "2025-05-06T13:05:20.887820Z"
247247
},
248248
"vscode": {
249249
"languageId": "plaintext"
@@ -304,10 +304,10 @@
304304
"id": "b00a9d85",
305305
"metadata": {
306306
"execution": {
307-
"iopub.execute_input": "2025-05-06T12:53:54.639078Z",
308-
"iopub.status.busy": "2025-05-06T12:53:54.638962Z",
309-
"iopub.status.idle": "2025-05-06T12:53:55.175731Z",
310-
"shell.execute_reply": "2025-05-06T12:53:55.175281Z"
307+
"iopub.execute_input": "2025-05-06T13:05:20.890595Z",
308+
"iopub.status.busy": "2025-05-06T13:05:20.890473Z",
309+
"iopub.status.idle": "2025-05-06T13:05:21.440966Z",
310+
"shell.execute_reply": "2025-05-06T13:05:21.440621Z"
311311
},
312312
"vscode": {
313313
"languageId": "plaintext"

examples/cthead.ipynb

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616
"id": "94b5ef80",
1717
"metadata": {
1818
"execution": {
19-
"iopub.execute_input": "2025-05-06T12:53:56.722433Z",
20-
"iopub.status.busy": "2025-05-06T12:53:56.722333Z",
21-
"iopub.status.idle": "2025-05-06T12:53:57.143081Z",
22-
"shell.execute_reply": "2025-05-06T12:53:57.142695Z"
19+
"iopub.execute_input": "2025-05-06T13:05:22.960040Z",
20+
"iopub.status.busy": "2025-05-06T13:05:22.959940Z",
21+
"iopub.status.idle": "2025-05-06T13:05:23.372612Z",
22+
"shell.execute_reply": "2025-05-06T13:05:23.372204Z"
2323
},
2424
"vscode": {
2525
"languageId": "plaintext"
@@ -51,10 +51,10 @@
5151
"id": "1ee080d3",
5252
"metadata": {
5353
"execution": {
54-
"iopub.execute_input": "2025-05-06T12:53:57.144813Z",
55-
"iopub.status.busy": "2025-05-06T12:53:57.144650Z",
56-
"iopub.status.idle": "2025-05-06T12:53:57.270116Z",
57-
"shell.execute_reply": "2025-05-06T12:53:57.269740Z"
54+
"iopub.execute_input": "2025-05-06T13:05:23.374408Z",
55+
"iopub.status.busy": "2025-05-06T13:05:23.374240Z",
56+
"iopub.status.idle": "2025-05-06T13:05:23.498833Z",
57+
"shell.execute_reply": "2025-05-06T13:05:23.498455Z"
5858
},
5959
"vscode": {
6060
"languageId": "plaintext"
@@ -112,10 +112,10 @@
112112
"id": "7af5a922",
113113
"metadata": {
114114
"execution": {
115-
"iopub.execute_input": "2025-05-06T12:53:57.271162Z",
116-
"iopub.status.busy": "2025-05-06T12:53:57.271023Z",
117-
"iopub.status.idle": "2025-05-06T12:53:58.218631Z",
118-
"shell.execute_reply": "2025-05-06T12:53:58.218128Z"
115+
"iopub.execute_input": "2025-05-06T13:05:23.500458Z",
116+
"iopub.status.busy": "2025-05-06T13:05:23.500274Z",
117+
"iopub.status.idle": "2025-05-06T13:05:24.447057Z",
118+
"shell.execute_reply": "2025-05-06T13:05:24.446708Z"
119119
},
120120
"vscode": {
121121
"languageId": "plaintext"
@@ -180,10 +180,10 @@
180180
"id": "493f1153",
181181
"metadata": {
182182
"execution": {
183-
"iopub.execute_input": "2025-05-06T12:53:58.220264Z",
184-
"iopub.status.busy": "2025-05-06T12:53:58.220096Z",
185-
"iopub.status.idle": "2025-05-06T12:53:58.718057Z",
186-
"shell.execute_reply": "2025-05-06T12:53:58.717598Z"
183+
"iopub.execute_input": "2025-05-06T13:05:24.448786Z",
184+
"iopub.status.busy": "2025-05-06T13:05:24.448581Z",
185+
"iopub.status.idle": "2025-05-06T13:05:24.912468Z",
186+
"shell.execute_reply": "2025-05-06T13:05:24.911852Z"
187187
},
188188
"vscode": {
189189
"languageId": "plaintext"
@@ -234,10 +234,10 @@
234234
"id": "6e7f236c",
235235
"metadata": {
236236
"execution": {
237-
"iopub.execute_input": "2025-05-06T12:53:58.720462Z",
238-
"iopub.status.busy": "2025-05-06T12:53:58.720352Z",
239-
"iopub.status.idle": "2025-05-06T12:53:59.537730Z",
240-
"shell.execute_reply": "2025-05-06T12:53:59.537278Z"
237+
"iopub.execute_input": "2025-05-06T13:05:24.914665Z",
238+
"iopub.status.busy": "2025-05-06T13:05:24.914478Z",
239+
"iopub.status.idle": "2025-05-06T13:05:25.751260Z",
240+
"shell.execute_reply": "2025-05-06T13:05:25.750797Z"
241241
},
242242
"vscode": {
243243
"languageId": "plaintext"
@@ -293,14 +293,14 @@
293293
},
294294
{
295295
"cell_type": "code",
296-
"execution_count": null,
296+
"execution_count": 6,
297297
"id": "696c040a",
298298
"metadata": {
299299
"execution": {
300-
"iopub.execute_input": "2025-05-06T12:53:59.539558Z",
301-
"iopub.status.busy": "2025-05-06T12:53:59.539448Z",
302-
"iopub.status.idle": "2025-05-06T12:54:00.377743Z",
303-
"shell.execute_reply": "2025-05-06T12:54:00.377291Z"
300+
"iopub.execute_input": "2025-05-06T13:05:25.753065Z",
301+
"iopub.status.busy": "2025-05-06T13:05:25.752956Z",
302+
"iopub.status.idle": "2025-05-06T13:05:26.588190Z",
303+
"shell.execute_reply": "2025-05-06T13:05:26.587644Z"
304304
},
305305
"vscode": {
306306
"languageId": "plaintext"

misc/libcarna/_mip.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,13 @@ def __init__(
2525
super().__init__(*args, **kwargs)
2626
self.cmap = color_map_helper(self.color_map, cmap)
2727
self.sample_rate = sr
28+
29+
def replicate(self):
30+
"""
31+
Replicate the MIP stage.
32+
"""
33+
return mip(
34+
self.geometry_type,
35+
cmap=self.cmap.color_map,
36+
sr=self.sample_rate,
37+
)

test/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ set( TEST_FILES
1010
test_presets
1111
test_helpers
1212
test_integration
13-
test_py
13+
test_material
14+
test_dvr
15+
test_mip
1416
)
1517

1618
configure_file(

test/test_dvr.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import libcarna
2+
3+
import testsuite
4+
5+
6+
class dvr(testsuite.LibCarnaTestCase):
7+
8+
def test__replicate(self):
9+
GEOMETRY_TYPE_VOLUME = 1
10+
dvr1 = libcarna.dvr(
11+
GEOMETRY_TYPE_VOLUME,
12+
cmap='viridis',
13+
sr=400,
14+
transl=1,
15+
diffuse=0.5,
16+
)
17+
dvr2 = dvr1.replicate()
18+
self.assertEqual(dvr2.geometry_type, GEOMETRY_TYPE_VOLUME)
19+
self.assertEqual(dvr2.cmap.color_map.color_list, dvr1.cmap.color_map.color_list)
20+
self.assertEqual(dvr2.sample_rate, 400)
21+
self.assertEqual(dvr2.translucency, 1)
22+
self.assertEqual(dvr2.diffuse_light, 0.5)

test/test_py.py renamed to test/test_material.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ def test__color__3d(self):
2121
for shader_name in ('unshaded', 'solid'):
2222
with self.subTest(shader_name=shader_name):
2323
with self.assertRaises(ValueError):
24-
libcarna.material('unshaded', color=(1, 0, 0))
24+
libcarna.material('unshaded', color=(1, 0, 0))

test/test_mip.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import libcarna
2+
3+
import testsuite
4+
5+
6+
class mip(testsuite.LibCarnaTestCase):
7+
8+
def test__replicate(self):
9+
GEOMETRY_TYPE_VOLUME = 1
10+
mip1 = libcarna.mip(
11+
GEOMETRY_TYPE_VOLUME,
12+
cmap='jet',
13+
sr=400,
14+
)
15+
mip2 = mip1.replicate()
16+
self.assertEqual(mip2.geometry_type, GEOMETRY_TYPE_VOLUME)
17+
self.assertEqual(mip2.cmap.color_map.color_list, mip1.cmap.color_map.color_list)
18+
self.assertEqual(mip2.sample_rate, 400)

0 commit comments

Comments
 (0)