33from __future__ import annotations
44
55from abc import ABC , abstractmethod
6- from typing import Any , Callable , Dict , Optional , Union , get_args
6+ from typing import Any , Callable , Optional , Union , get_args
77
88import numpy as np
99import pydantic .v1 as pd
1010import xarray as xr
1111
12- from ...constants import C_0 , PICOSECOND_PER_NANOMETER_PER_KILOMETER , UnitScaling
13- from ...exceptions import DataError
14- from ...log import log
15- from ..base import Tidy3dBaseModel
16- from ..types import Axis , xyz
12+ from tidy3d .components .base import Tidy3dBaseModel
13+ from tidy3d .components .types import Axis , xyz
14+ from tidy3d .constants import C_0 , PICOSECOND_PER_NANOMETER_PER_KILOMETER , UnitScaling
15+ from tidy3d .exceptions import DataError
16+ from tidy3d .log import log
17+
1718from .data_array import (
1819 DataArray ,
1920 EMEScalarFieldDataArray ,
@@ -44,7 +45,7 @@ class AbstractFieldDataset(Dataset, ABC):
4445
4546 @property
4647 @abstractmethod
47- def field_components (self ) -> Dict [str , DataArray ]:
48+ def field_components (self ) -> dict [str , DataArray ]:
4849 """Maps the field components to their associated data."""
4950
5051 def apply_phase (self , phase : float ) -> AbstractFieldDataset :
@@ -60,15 +61,15 @@ def apply_phase(self, phase: float) -> AbstractFieldDataset:
6061
6162 @property
6263 @abstractmethod
63- def grid_locations (self ) -> Dict [str , str ]:
64+ def grid_locations (self ) -> dict [str , str ]:
6465 """Maps field components to the string key of their grid locations on the yee lattice."""
6566
6667 @property
6768 @abstractmethod
68- def symmetry_eigenvalues (self ) -> Dict [str , Callable [[Axis ], float ]]:
69+ def symmetry_eigenvalues (self ) -> dict [str , Callable [[Axis ], float ]]:
6970 """Maps field components to their (positive) symmetry eigenvalues."""
7071
71- def package_colocate_results (self , centered_fields : Dict [str , ScalarFieldDataArray ]) -> Any :
72+ def package_colocate_results (self , centered_fields : dict [str , ScalarFieldDataArray ]) -> Any :
7273 """How to package the dictionary of fields computed via self.colocate()."""
7374 return xr .Dataset (centered_fields )
7475
@@ -182,7 +183,7 @@ class ElectromagneticFieldDataset(AbstractFieldDataset, ABC):
182183 )
183184
184185 @property
185- def field_components (self ) -> Dict [str , DataArray ]:
186+ def field_components (self ) -> dict [str , DataArray ]:
186187 """Maps the field components to their associated data."""
187188 fields = {
188189 "Ex" : self .Ex ,
@@ -195,22 +196,22 @@ def field_components(self) -> Dict[str, DataArray]:
195196 return {field_name : field for field_name , field in fields .items () if field is not None }
196197
197198 @property
198- def grid_locations (self ) -> Dict [str , str ]:
199+ def grid_locations (self ) -> dict [str , str ]:
199200 """Maps field components to the string key of their grid locations on the yee lattice."""
200- return dict ( Ex = " Ex" , Ey = " Ey" , Ez = " Ez" , Hx = " Hx" , Hy = " Hy" , Hz = " Hz")
201+ return { "Ex" : " Ex" , "Ey" : " Ey" , "Ez" : " Ez" , "Hx" : " Hx" , "Hy" : " Hy" , "Hz" : " Hz"}
201202
202203 @property
203- def symmetry_eigenvalues (self ) -> Dict [str , Callable [[Axis ], float ]]:
204+ def symmetry_eigenvalues (self ) -> dict [str , Callable [[Axis ], float ]]:
204205 """Maps field components to their (positive) symmetry eigenvalues."""
205206
206- return dict (
207- Ex = lambda dim : - 1 if (dim == 0 ) else + 1 ,
208- Ey = lambda dim : - 1 if (dim == 1 ) else + 1 ,
209- Ez = lambda dim : - 1 if (dim == 2 ) else + 1 ,
210- Hx = lambda dim : + 1 if (dim == 0 ) else - 1 ,
211- Hy = lambda dim : + 1 if (dim == 1 ) else - 1 ,
212- Hz = lambda dim : + 1 if (dim == 2 ) else - 1 ,
213- )
207+ return {
208+ "Ex" : lambda dim : - 1 if (dim == 0 ) else + 1 ,
209+ "Ey" : lambda dim : - 1 if (dim == 1 ) else + 1 ,
210+ "Ez" : lambda dim : - 1 if (dim == 2 ) else + 1 ,
211+ "Hx" : lambda dim : + 1 if (dim == 0 ) else - 1 ,
212+ "Hy" : lambda dim : + 1 if (dim == 1 ) else - 1 ,
213+ "Hz" : lambda dim : + 1 if (dim == 2 ) else - 1 ,
214+ }
214215
215216
216217class FieldDataset (ElectromagneticFieldDataset ):
@@ -422,7 +423,7 @@ class AuxFieldDataset(AbstractFieldDataset, ABC):
422423 )
423424
424425 @property
425- def field_components (self ) -> Dict [str , DataArray ]:
426+ def field_components (self ) -> dict [str , DataArray ]:
426427 """Maps the field components to their associated data."""
427428 fields = {
428429 "Nfx" : self .Nfx ,
@@ -432,19 +433,19 @@ def field_components(self) -> Dict[str, DataArray]:
432433 return {field_name : field for field_name , field in fields .items () if field is not None }
433434
434435 @property
435- def grid_locations (self ) -> Dict [str , str ]:
436+ def grid_locations (self ) -> dict [str , str ]:
436437 """Maps field components to the string key of their grid locations on the yee lattice."""
437- return dict ( Nfx = " Ex" , Nfy = " Ey" , Nfz = " Ez")
438+ return { " Nfx" : " Ex" , " Nfy" : " Ey" , " Nfz" : " Ez"}
438439
439440 @property
440- def symmetry_eigenvalues (self ) -> Dict [str , Callable [[Axis ], float ]]:
441+ def symmetry_eigenvalues (self ) -> dict [str , Callable [[Axis ], float ]]:
441442 """Maps field components to their (positive) symmetry eigenvalues."""
442443
443- return dict (
444- Nfx = lambda dim : + 1 ,
445- Nfy = lambda dim : + 1 ,
446- Nfz = lambda dim : + 1 ,
447- )
444+ return {
445+ " Nfx" : lambda dim : + 1 ,
446+ " Nfy" : lambda dim : + 1 ,
447+ " Nfz" : lambda dim : + 1 ,
448+ }
448449
449450
450451class AuxFieldTimeDataset (AuxFieldDataset ):
@@ -559,7 +560,7 @@ class ModeSolverDataset(ElectromagneticFieldDataset):
559560 )
560561
561562 @property
562- def field_components (self ) -> Dict [str , DataArray ]:
563+ def field_components (self ) -> dict [str , DataArray ]:
563564 """Maps the field components to their associated data."""
564565 fields = {
565566 "Ex" : self .Ex ,
@@ -632,19 +633,19 @@ class PermittivityDataset(AbstractFieldDataset):
632633 """
633634
634635 @property
635- def field_components (self ) -> Dict [str , ScalarFieldDataArray ]:
636+ def field_components (self ) -> dict [str , ScalarFieldDataArray ]:
636637 """Maps the field components to their associated data."""
637- return dict ( eps_xx = self .eps_xx , eps_yy = self .eps_yy , eps_zz = self .eps_zz )
638+ return { " eps_xx" : self .eps_xx , " eps_yy" : self .eps_yy , " eps_zz" : self .eps_zz }
638639
639640 @property
640- def grid_locations (self ) -> Dict [str , str ]:
641+ def grid_locations (self ) -> dict [str , str ]:
641642 """Maps field components to the string key of their grid locations on the yee lattice."""
642- return dict ( eps_xx = " Ex" , eps_yy = " Ey" , eps_zz = " Ez")
643+ return { " eps_xx" : " Ex" , " eps_yy" : " Ey" , " eps_zz" : " Ez"}
643644
644645 @property
645- def symmetry_eigenvalues (self ) -> Dict [str , Callable [[Axis ], float ]]:
646+ def symmetry_eigenvalues (self ) -> dict [str , Callable [[Axis ], float ]]:
646647 """Maps field components to their (positive) symmetry eigenvalues."""
647- return dict ( eps_xx = None , eps_yy = None , eps_zz = None )
648+ return { " eps_xx" : None , " eps_yy" : None , " eps_zz" : None }
648649
649650 eps_xx : ScalarFieldDataArray = pd .Field (
650651 ...,
0 commit comments