1010import pydantic .v1 as pd
1111import pytest
1212import xarray as xr
13- from shapely .geometry import LineString , Polygon
14- from shapely .plotting import plot_line , plot_polygon
1513
1614import tidy3d as td
1715import tidy3d .components .microwave .path_integrals .current_spec
3028 make_voltage_integral ,
3129)
3230from tidy3d .components .mode .mode_solver import ModeSolver
33- from tidy3d .components .types import Ax , Shapely
3431from tidy3d .constants import EPSILON_0
3532from tidy3d .exceptions import SetupError , ValidationError
3633
3734from ..test_data .test_monitor_data import make_directivity_data
3835
3936mm = 1e3
4037
41- MAKE_PLOTS = True
38+ MAKE_PLOTS = False
4239if MAKE_PLOTS :
4340 # Interactive plotting for debugging
4441 from matplotlib import use
@@ -237,24 +234,6 @@ def make_mw_sim(
237234 return sim
238235
239236
240- def plot_auto_path_spec (
241- path_spec : td .CompositeCurrentIntegralSpec ,
242- geoms : list [Shapely ],
243- ax : Ax = None ,
244- ) -> Ax :
245- """Helper to plot composite path specifications along with the Shapely geometries used to generate them."""
246- if ax is None :
247- _ , ax = plt .subplots (1 , 1 , tight_layout = True , figsize = (15 , 15 ))
248-
249- for geom in geoms :
250- if isinstance (geom , Polygon ):
251- plot_polygon (geom , ax = ax )
252- elif isinstance (geom , LineString ):
253- plot_line (geom , ax = ax )
254- i_integral = make_current_integral (path_spec )
255- i_integral .plot (x = i_integral .center [0 ], ax = ax )
256-
257-
258237def test_inductance_formulas ():
259238 """Run the formulas for inductance and compare to precomputed results."""
260239 bar_size = (1000e4 , 1e4 , 1e4 ) # case from reference
@@ -399,9 +378,7 @@ def test_composite_current_integral_validation():
399378
400379 current_spec = td .CurrentIntegralAxisAlignedSpec (center = (1 , 2 , 3 ), size = (0 , 1 , 1 ), sign = "-" )
401380 voltage_spec = td .VoltageIntegralAxisAlignedSpec (center = (1 , 2 , 3 ), size = (0 , 0 , 1 ), sign = "-" )
402- path_spec = td .CompositeCurrentIntegralSpec (
403- center = (1 , 2 , 3 ), size = (0 , 1 , 1 ), path_specs = [current_spec ], sum_spec = "sum"
404- )
381+ path_spec = td .CompositeCurrentIntegralSpec (path_specs = [current_spec ], sum_spec = "sum" )
405382
406383 with pytest .raises (pd .ValidationError ):
407384 path_spec .updated_copy (path_specs = [])
@@ -519,9 +496,7 @@ def test_path_integral_factory_current_validation():
519496 custom_2d_spec = td .CustomCurrentIntegral2DSpec (
520497 vertices = [(0 , 1 ), (0 , 4 ), (3 , 4 ), (3 , 1 )], axis = 1 , position = 2
521498 )
522- composite_spec = td .CompositeCurrentIntegralSpec (
523- center = (1 , 2 , 3 ), size = (0 , 1 , 1 ), path_specs = [axis_aligned_spec ], sum_spec = "sum"
524- )
499+ composite_spec = td .CompositeCurrentIntegralSpec (path_specs = [axis_aligned_spec ], sum_spec = "sum" )
525500
526501 # Test successful creation with axis-aligned spec
527502 current_integral = make_current_integral (axis_aligned_spec )
@@ -538,7 +513,6 @@ def test_path_integral_factory_current_validation():
538513 # Test successful creation with composite spec
539514 current_integral = make_current_integral (composite_spec )
540515 assert current_integral is not None
541- assert current_integral .center == (1 , 2 , 3 )
542516 assert len (current_integral .path_specs ) == 1
543517
544518 # Test ValidationError with unsupported type
@@ -613,7 +587,7 @@ def mock_make_voltage_integral(path_spec):
613587
614588
615589def test_path_integral_factory_composite_current ():
616- """Test make_current_integral with CompositeCurrentIntegralSpec and integration ."""
590+ """Test make_current_integral with CompositeCurrentIntegralSpec."""
617591
618592 # Create base specs for the composite
619593 axis_aligned_spec1 = td .CurrentIntegralAxisAlignedSpec (
@@ -625,22 +599,17 @@ def test_path_integral_factory_composite_current():
625599
626600 # Test creation of CompositeCurrentIntegralSpec
627601 composite_spec = td .CompositeCurrentIntegralSpec (
628- center = (1.5 , 2 , 3 ),
629- size = (2 , 1 , 1 ),
630602 path_specs = [axis_aligned_spec1 , axis_aligned_spec2 ],
631603 sum_spec = "sum" ,
632604 )
633605
634606 # Test successful creation with composite spec
635607 current_integral = make_current_integral (composite_spec )
636608 assert current_integral is not None
637- assert current_integral .center == (1.5 , 2 , 3 )
638609 assert len (current_integral .path_specs ) == 2
639610
640611 # Test with different sum_spec options
641612 composite_spec_split = td .CompositeCurrentIntegralSpec (
642- center = (1.5 , 2 , 3 ),
643- size = (2 , 1 , 1 ),
644613 path_specs = [axis_aligned_spec1 , axis_aligned_spec2 ],
645614 sum_spec = "split" ,
646615 )
0 commit comments