Skip to content

Commit

Permalink
Merge pull request #43 from joamatab/numpy2_compat
Browse files Browse the repository at this point in the history
update to numpy2
  • Loading branch information
flaport authored Dec 24, 2024
2 parents 0d17126 + 72c541e commit 27e629e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion meow/eme/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def compute_propagation_s_matrices(


def select_ports(
S: np.ndarray[Any, np.dtype[np.float_]], port_map: Dict[str, int], ports: List[str]
S: np.ndarray[Any, np.dtype[np.float64]], port_map: Dict[str, int], ports: List[str]
):
"""Keep subset of an S-matrix
Expand Down
2 changes: 1 addition & 1 deletion meow/materials.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def from_df(cls, name, df, meta=None):
n = nr + 1j * ni

columns = [c for c in df.columns if c not in ["nr", "ni"]]
params = {c: np.asarray(df[c].values, dtype=np.float_) for c in columns}
params = {c: np.asarray(df[c].values, dtype=np.float64) for c in columns}

# TODO: support complex n
return cls(name=name, params=params, n=np.real(n), meta=meta)
Expand Down
8 changes: 4 additions & 4 deletions meow/mode.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def A(self):
E_qu = E_sq**2
x = self.cs.mesh.x_
y = self.cs.mesh.y_
return np.float_(integrate_2d(x, y, E_sq) ** 2 / integrate_2d(x, y, E_qu))
return np.float64(integrate_2d(x, y, E_sq) ** 2 / integrate_2d(x, y, E_qu))

@property
def env(self):
Expand Down Expand Up @@ -351,7 +351,7 @@ def normalize_product(mode: Mode) -> Mode:

def electric_energy_density(
mode: Mode,
) -> np.ndarray[tuple[int, int], np.dtype[np.float_]]:
) -> np.ndarray[tuple[int, int], np.dtype[np.float64]]:
"""get the electric energy density contained in a `Mode`"""
epsx, epsy, epsz = mode.cs.nx**2, mode.cs.ny**2, mode.cs.nz**2
return (
Expand All @@ -372,7 +372,7 @@ def electric_energy(mode: Mode) -> float:

def magnetic_energy_density(
mode: Mode,
) -> np.ndarray[tuple[int, int], np.dtype[np.float_]]:
) -> np.ndarray[tuple[int, int], np.dtype[np.float64]]:
"""get the magnetic energy density contained in a `Mode`"""
return (
0.5 * mu0 * (np.abs(mode.Hx) ** 2 + np.abs(mode.Hy) ** 2 + np.abs(mode.Hz) ** 2)
Expand All @@ -384,7 +384,7 @@ def magnetic_energy(mode: Mode) -> float:
return magnetic_energy_density(mode).sum()


def energy_density(mode: Mode) -> np.ndarray[tuple[int, int], np.dtype[np.float_]]:
def energy_density(mode: Mode) -> np.ndarray[tuple[int, int], np.dtype[np.float64]]:
"""get the energy density contained in a `Mode`"""
return electric_energy_density(mode) + magnetic_energy_density(mode)

Expand Down

0 comments on commit 27e629e

Please sign in to comment.