type hints and lint
This commit is contained in:
parent
eec3fc28a7
commit
c6c9159b13
30 changed files with 198 additions and 136 deletions
|
|
@ -14,6 +14,7 @@ simple straight interface:
|
|||
from __future__ import annotations
|
||||
|
||||
import importlib
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import numpy
|
||||
from numpy import pi
|
||||
|
|
@ -24,6 +25,9 @@ from gridlock import Extent
|
|||
from meanas.fdfd import eme, waveguide_2d
|
||||
from meanas.fdmath import unvec
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from types import ModuleType
|
||||
|
||||
|
||||
WL = 1310.0
|
||||
DX = 40.0
|
||||
|
|
@ -35,7 +39,7 @@ EPS_OX = 1.453 ** 2
|
|||
MODE_NUMBERS = numpy.array([0])
|
||||
|
||||
|
||||
def require_optional(name: str, package_name: str | None = None):
|
||||
def require_optional(name: str, package_name: str | None = None) -> ModuleType:
|
||||
package_name = package_name or name
|
||||
try:
|
||||
return importlib.import_module(name)
|
||||
|
|
@ -159,7 +163,7 @@ def print_summary(ss: numpy.ndarray, wavenumbers_left: numpy.ndarray, wavenumber
|
|||
|
||||
def plot_results(
|
||||
*,
|
||||
pyplot,
|
||||
pyplot: ModuleType,
|
||||
ss: numpy.ndarray,
|
||||
left_mode: tuple[numpy.ndarray, numpy.ndarray],
|
||||
right_mode: tuple[numpy.ndarray, numpy.ndarray],
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ This example demonstrates a cylindrical-waveguide EME workflow:
|
|||
from __future__ import annotations
|
||||
|
||||
import importlib
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import numpy
|
||||
from numpy import pi
|
||||
|
|
@ -26,6 +27,9 @@ from gridlock import Extent
|
|||
from meanas.fdfd import eme, waveguide_2d, waveguide_cyl
|
||||
from meanas.fdmath import unvec
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from types import ModuleType
|
||||
|
||||
|
||||
WL = 1310.0
|
||||
DX = 40.0
|
||||
|
|
@ -40,7 +44,7 @@ STRAIGHT_SECTION_LENGTH = 12e3
|
|||
BEND_ANGLE = pi / 2
|
||||
|
||||
|
||||
def require_optional(name: str, package_name: str | None = None):
|
||||
def require_optional(name: str, package_name: str | None = None) -> ModuleType:
|
||||
package_name = package_name or name
|
||||
try:
|
||||
return importlib.import_module(name)
|
||||
|
|
@ -163,7 +167,7 @@ def solve_bend_modes(
|
|||
|
||||
|
||||
def build_cascaded_network(
|
||||
skrf,
|
||||
skrf: ModuleType,
|
||||
*,
|
||||
interface_s: numpy.ndarray,
|
||||
straight_wavenumbers: numpy.ndarray,
|
||||
|
|
@ -216,7 +220,7 @@ def print_summary(
|
|||
|
||||
def plot_results(
|
||||
*,
|
||||
pyplot,
|
||||
pyplot: ModuleType,
|
||||
interface_s: numpy.ndarray,
|
||||
cascaded_s: numpy.ndarray,
|
||||
straight_mode: tuple[numpy.ndarray, numpy.ndarray],
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ def perturbed_l3(a: float, radius: float, **kwargs) -> Pattern:
|
|||
return pat
|
||||
|
||||
|
||||
def main():
|
||||
def main() -> None:
|
||||
dtype = numpy.float32
|
||||
max_t = 3600 # number of timesteps
|
||||
|
||||
|
|
@ -97,7 +97,6 @@ def main():
|
|||
pml_thickness = 8 # (number of cells)
|
||||
|
||||
wl = 1550 # Excitation wavelength and fwhm
|
||||
dwl = 100
|
||||
|
||||
# Device design parameters
|
||||
xy_size = numpy.array([10, 10])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue