update type hints and formatting

master
Jan Petykiewicz 1 year ago
parent 68a9818388
commit bec0137c99

@ -413,8 +413,8 @@ def find_k(
band: int = 0,
k_bounds: Tuple[float, float] = (0, 0.5),
k_guess: Optional[float] = None,
solve_callback: Optional[Callable[[...], None]] = None,
iter_callback: Optional[Callable[[...], None]] = None,
solve_callback: Optional[Callable[..., None]] = None,
iter_callback: Optional[Callable[..., None]] = None,
) -> Tuple[float, float, NDArray[numpy.complex128], NDArray[numpy.complex128]]:
"""
Search for a bloch vector that has a given frequency.
@ -440,7 +440,7 @@ def find_k(
"""
direction = numpy.array(direction) / norm(direction)
k_bounds = tuple(sorted(k_bounds))
k_bounds = tuple(sorted(k_bounds)) # type: ignore # we know the length already...
assert len(k_bounds) == 2
if k_guess is None:
@ -481,7 +481,7 @@ def eigsolve(
max_iters: int = 10000,
reset_iters: int = 100,
y0: Optional[ArrayLike] = None,
callback: Optional[Callable[[...], None]] = None,
callback: Optional[Callable[..., None]] = None,
) -> Tuple[NDArray[numpy.complex128], NDArray[numpy.complex128]]:
"""
Find the first (lowest-frequency) num_modes eigenmodes with Bloch wavevector
@ -531,7 +531,7 @@ def eigsolve(
if y0 is None:
Z = numpy.random.rand(*y_shape) + 1j * numpy.random.rand(*y_shape)
else:
Z = y0
Z = numpy.array(y0, copy=False)
while True:
Z *= num_modes / norm(Z)

@ -1,7 +1,7 @@
"""
Functions for performing near-to-farfield transformation (and the reverse).
"""
from typing import Dict, List, Any
from typing import Dict, List, Any, Union, Sequence
import numpy
from numpy.fft import fft2, fftshift, fftfreq, ifft2, ifftshift
from numpy import pi
@ -14,7 +14,7 @@ def near_to_farfield(
H_near: cfdfield_t,
dx: float,
dy: float,
padded_size: List[int] = None
padded_size: Union[List[int], int, None] = None
) -> Dict[str, Any]:
"""
Compute the farfield, i.e. the distribution of the fields after propagation
@ -126,7 +126,7 @@ def far_to_nearfield(
H_far: cfdfield_t,
dkx: float,
dky: float,
padded_size: List[int] = None
padded_size: Union[List[int], int, None] = None
) -> Dict[str, Any]:
"""
Compute the farfield, i.e. the distribution of the fields after propagation

@ -19,7 +19,7 @@ def e_full(
omega: complex,
dxes: dx_lists_t,
epsilon: fdfield_t,
mu: Optional[fdfield_t] = None
mu: Optional[fdfield_t] = None,
) -> cfdfield_updater_t:
"""
Wave operator for use with E-field. See `operators.e_full` for details.
@ -55,7 +55,7 @@ def eh_full(
omega: complex,
dxes: dx_lists_t,
epsilon: fdfield_t,
mu: fdfield_t = None
mu: Optional[fdfield_t] = None,
) -> Callable[[cfdfield_t, cfdfield_t], Tuple[cfdfield_t, cfdfield_t]]:
"""
Wave operator for full (both E and H) field representation.

@ -67,9 +67,9 @@ def generic(
dxes: dx_lists_t,
J: vcfdfield_t,
epsilon: vfdfield_t,
mu: vfdfield_t = None,
pec: vfdfield_t = None,
pmc: vfdfield_t = None,
mu: Optional[vfdfield_t] = None,
pec: Optional[vfdfield_t] = None,
pmc: Optional[vfdfield_t] = None,
adjoint: bool = False,
matrix_solver: Callable[..., ArrayLike] = _scipy_qmr,
matrix_solver_opts: Optional[Dict[str, Any]] = None,

@ -722,7 +722,7 @@ def solve_modes(
omega: complex,
dxes: dx_lists_t,
epsilon: vfdfield_t,
mu: vfdfield_t = None,
mu: Optional[vfdfield_t] = None,
mode_margin: int = 2,
) -> Tuple[NDArray[numpy.float64], NDArray[numpy.complex128]]:
"""

@ -3,7 +3,7 @@ Basic FDTD field updates
"""
from typing import Union
from typing import Union, Optional
from ..fdmath import dx_lists_t, fdfield_t, fdfield_updater_t
from ..fdmath.functional import curl_forward, curl_back
@ -12,7 +12,10 @@ from ..fdmath.functional import curl_forward, curl_back
__author__ = 'Jan Petykiewicz'
def maxwell_e(dt: float, dxes: dx_lists_t = None) -> fdfield_updater_t:
def maxwell_e(
dt: float,
dxes: Optional[dx_lists_t] = None,
) -> fdfield_updater_t:
"""
Build a function which performs a portion the time-domain E-field update,
@ -64,7 +67,10 @@ def maxwell_e(dt: float, dxes: dx_lists_t = None) -> fdfield_updater_t:
return me_fun
def maxwell_h(dt: float, dxes: dx_lists_t = None) -> fdfield_updater_t:
def maxwell_h(
dt: float,
dxes: Optional[dx_lists_t] = None,
) -> fdfield_updater_t:
"""
Build a function which performs part of the time-domain H-field update,

Loading…
Cancel
Save