11"""Tests mode objects."""
22
33import numpy as np
4- import pydantic . v1 as pydantic
4+ import pydantic as pd
55import pytest
66import tidy3d as td
77from matplotlib import pyplot as plt
@@ -32,29 +32,29 @@ def test_modes():
3232 for opt in options :
3333 _ = td .ModeSpec (num_modes = 3 , track_freq = opt )
3434
35- with pytest .raises (pydantic .ValidationError ):
35+ with pytest .raises (pd .ValidationError ):
3636 _ = td .ModeSpec (num_modes = 3 , track_freq = "middle" )
37- with pytest .raises (pydantic .ValidationError ):
37+ with pytest .raises (pd .ValidationError ):
3838 _ = td .ModeSpec (num_modes = 3 , track_freq = 4 )
3939
4040
4141def test_bend_axis_not_given ():
42- with pytest .raises (pydantic .ValidationError ):
42+ with pytest .raises (pd .ValidationError ):
4343 _ = td .ModeSpec (bend_radius = 1.0 , bend_axis = None )
4444
4545
4646def test_zero_radius ():
47- with pytest .raises (pydantic .ValidationError ):
47+ with pytest .raises (pd .ValidationError ):
4848 _ = td .ModeSpec (bend_radius = 0.0 , bend_axis = 1 )
4949
5050
5151def test_glancing_incidence ():
52- with pytest .raises (pydantic .ValidationError ):
52+ with pytest .raises (pd .ValidationError ):
5353 _ = td .ModeSpec (angle_theta = np .pi / 2 )
5454
5555
5656def test_group_index_step_validation ():
57- with pytest .raises (pydantic .ValidationError ):
57+ with pytest .raises (pd .ValidationError ):
5858 _ = td .ModeSpec (group_index_step = 1.0 )
5959
6060 ms = td .ModeSpec (group_index_step = True )
@@ -71,7 +71,7 @@ def test_angle_rotation_with_phi():
7171 td .ModeSpec (angle_phi = np .pi , angle_rotation = True )
7272
7373 # Case where angle_phi is not a multiple of np.pi and angle_rotation is True
74- with pytest .raises (pydantic .ValidationError ):
74+ with pytest .raises (pd .ValidationError ):
7575 td .ModeSpec (angle_phi = np .pi / 3 , angle_rotation = True )
7676
7777
@@ -110,14 +110,14 @@ def test_mode_sim():
110110 assert sim .plane == sim .geometry
111111
112112 # must be planar or have plane
113- with pytest .raises (pydantic .ValidationError ):
113+ with pytest .raises (pd .ValidationError ):
114114 _ = sim .updated_copy (size = (3 , 3 , 3 ), plane = None )
115- with pytest .raises (pydantic .ValidationError ):
115+ with pytest .raises (pd .ValidationError ):
116116 _ = sim .updated_copy (size = (3 , 3 , 3 ), plane = td .Box (size = (3 , 3 , 3 )))
117117 _ = sim .updated_copy (size = (3 , 3 , 3 ), plane = td .Box (size = (3 , 3 , 0 )))
118118
119119 # plane must intersect sim geometry
120- with pytest .raises (pydantic .ValidationError ):
120+ with pytest .raises (pd .ValidationError ):
121121 _ = sim .updated_copy (size = (3 , 3 , 3 ), plane = td .Box (center = (5 , 5 , 5 ), size = (1 , 1 , 0 )))
122122
123123 # test warning for not providing wavelength in autogrid
@@ -161,7 +161,7 @@ def test_mode_sim():
161161 )
162162
163163 assert td .ModeSimulation .from_simulation (sim ) == sim
164- assert td .ModeSimulation .from_mode_solver (sim ._mode_solver ) == sim .updated_copy (monitors = [] )
164+ assert td .ModeSimulation .from_mode_solver (sim ._mode_solver ) == sim .updated_copy (monitors = () )
165165 _ = td .ModeSimulation .from_simulation (
166166 simulation = fdtd_sim ,
167167 plane = td .Box (size = (4 , 4 , 0 )),
0 commit comments