Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add type hints for MaterialGrid class #2395

Merged
merged 1 commit into from
Feb 9, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 11 additions & 12 deletions python/geom.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from typing import Union, Tuple
import functools
import math
import numbers
Expand All @@ -6,9 +7,7 @@
from collections import namedtuple
from copy import deepcopy
from numbers import Number

import numpy as np

import meep as mp

FreqRange = namedtuple("FreqRange", ["min", "max"])
Expand Down Expand Up @@ -587,15 +586,15 @@ def check_weights(self, w):

def __init__(
self,
grid_size,
medium1,
medium2,
weights=None,
grid_type="U_DEFAULT",
do_averaging=True,
beta=0,
eta=0.5,
damping=0,
grid_size: Union[Vector3, Tuple[float, ...]],
medium1: Medium,
medium2: Medium,
weights: np.ndarray = None,
grid_type: str = "U_DEFAULT",
do_averaging: bool = True,
beta: float = 0,
eta: float = 0.5,
damping: float = 0,
):
"""
Creates a `MaterialGrid` object.
Expand Down Expand Up @@ -691,7 +690,7 @@ def isclose(a, b, rel_tol=1e-09, abs_tol=0.0):

self.swigobj = None

def update_weights(self, x):
def update_weights(self, x: np.ndarray):
"""
Reset the `weights` to `x`.
"""
Expand Down