1
1
"""Tests visualization operations."""
2
2
3
3
import matplotlib .pyplot as plt
4
- import numpy as np
5
4
import pydantic .v1 as pd
6
5
import pytest
7
6
import tidy3d as td
@@ -147,13 +146,11 @@ def plot_with_viz_spec(alpha, facecolor, edgecolor=None, use_viz_spec=True):
147
146
plt .show ()
148
147
149
148
150
- def plot_with_multi_viz_spec (alphas , facecolors , edgecolors , use_viz_spec = True ):
149
+ def plot_with_multi_viz_spec (alphas , facecolors , edgecolors , rng , use_viz_spec = True ):
151
150
"""
152
151
Helper function for plotting simulations with multiple visulation specs via simluation
153
152
plotting function.
154
153
"""
155
- np .random .seed (3726423 )
156
-
157
154
viz_specs = [
158
155
td .VisualizationSpec (
159
156
facecolor = facecolors [idx ], edgecolor = edgecolors [idx ], alpha = alphas [idx ]
@@ -169,8 +166,8 @@ def plot_with_multi_viz_spec(alphas, facecolors, edgecolors, use_viz_spec=True):
169
166
170
167
structures = []
171
168
for idx in range (0 , len (viz_specs )):
172
- center = tuple (list (np . random .uniform (- 3 , 3 , 2 )) + [0 ])
173
- size = tuple (np . random .uniform (1 , 2 , 3 ))
169
+ center = tuple (list (rng .uniform (- 3 , 3 , 2 )) + [0 ])
170
+ size = tuple (rng .uniform (1 , 2 , 3 ))
174
171
box = td .Box (center = center , size = size )
175
172
176
173
structures .append (td .Structure (geometry = box , medium = media [idx ]))
@@ -180,12 +177,6 @@ def plot_with_multi_viz_spec(alphas, facecolors, edgecolors, use_viz_spec=True):
180
177
run_time = 1e-12 ,
181
178
structures = structures ,
182
179
grid_spec = td .GridSpec (wavelength = 1.0 ),
183
- boundary_spec = td .BoundarySpec (
184
- x = td .Boundary .pml (num_layers = 20 ),
185
- ),
186
- shutoff = 1e-6 ,
187
- courant = 0.8 ,
188
- subpixel = False ,
189
180
)
190
181
191
182
sim .plot (z = 0.0 )
@@ -217,7 +208,7 @@ def test_plot_from_structure_local():
217
208
218
209
219
210
@pytest .mark .skip (reason = "Skipping test for CI, but useful for debugging locally with graphics." )
220
- def test_plot_multi_from_structure_local ():
211
+ def test_plot_multi_from_structure_local (rng ):
221
212
"""
222
213
Local test for visualizing output when creating multiple structures with variety of
223
214
visualization specs.
@@ -226,10 +217,12 @@ def test_plot_multi_from_structure_local():
226
217
alphas = [0.5 , 0.75 , 0.25 , 0.4 ],
227
218
facecolors = ["red" , "green" , "blue" , "orange" ],
228
219
edgecolors = ["black" , "cyan" , "magenta" , "brown" ],
220
+ rng = rng ,
229
221
)
230
222
plot_with_multi_viz_spec (
231
223
alphas = [0.5 , 0.75 , 0.25 , 0.4 ],
232
224
facecolors = ["red" , "green" , "blue" , "orange" ],
233
225
edgecolors = ["black" , "cyan" , "magenta" , "brown" ],
226
+ rng = rng ,
234
227
use_viz_spec = False ,
235
228
)
0 commit comments