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 annotations to Simulation class #1919

Merged
merged 7 commits into from
Feb 4, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
60 changes: 30 additions & 30 deletions doc/docs/Python_User_Interface.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,40 +87,40 @@ control various parameters of the Meep computation.

```python
def __init__(self,
cell_size,
resolution,
geometry=None,
sources=None,
eps_averaging=True,
dimensions=3,
boundary_layers=None,
symmetries=None,
force_complex_fields=False,
default_material=Medium(),
m=0,
k_point=False,
cell_size: meep.geom.Vector3 = None,
stevengj marked this conversation as resolved.
Show resolved Hide resolved
resolution: float = None,
stevengj marked this conversation as resolved.
Show resolved Hide resolved
geometry: List[meep.geom.GeometricObject] = None,
sources: List[meep.source.Source] = None,
eps_averaging: bool = True,
dimensions: int = 3,
boundary_layers: List[meep.simulation.PML] = None,
symmetries: List[meep.simulation.Symmetry] = None,
force_complex_fields: bool = False,
default_material: meep.geom.Medium = Medium(),
m: int = 0,
k_point: bool = False,
kz_2d='complex',
oskooi marked this conversation as resolved.
Show resolved Hide resolved
extra_materials=None,
extra_materials: List[meep.geom.Medium] = None,
material_function=None,
epsilon_func=None,
epsilon_input_file='',
progress_interval=4,
subpixel_tol=0.0001,
subpixel_maxeval=100000,
loop_tile_base_db=0,
loop_tile_base_eh=0,
ensure_periodicity=True,
num_chunks=0,
Courant=0.5,
accurate_fields_near_cylorigin=False,
filename_prefix=None,
output_volume=None,
output_single_precision=False,
geometry_center=Vector3<0.0, 0.0, 0.0>,
force_all_components=False,
split_chunks_evenly=True,
epsilon_input_file: str = '',
progress_interval: float = 4.0,
subpixel_tol: float = 0.0001,
subpixel_maxeval: int = 100000,
loop_tile_base_db: int = 0,
loop_tile_base_eh: int = 0,
ensure_periodicity: bool = True,
num_chunks: int = 0,
Courant: float = 0.5,
accurate_fields_near_cylorigin: bool = False,
filename_prefix: str = None,
output_volume: meep.simulation.Volume = None,
output_single_precision: bool = False,
geometry_center: meep.geom.Vector3 = Vector3<0.0, 0.0, 0.0>,
force_all_components: bool = False,
split_chunks_evenly: bool = True,
chunk_layout=None,
collect_stats=False):
collect_stats: bool = False):
```

<div class="method_docstring" markdown="1">
Expand Down
74 changes: 38 additions & 36 deletions python/simulation.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# -*- coding: utf-8 -*-
from __future__ import division, print_function

from typing import Callable, List, Tuple, Union

import functools
import math
import numbers
Expand All @@ -21,8 +23,8 @@
import numpy as np

import meep as mp
from meep.geom import Vector3, init_do_averaging
from meep.source import EigenModeSource, GaussianBeamSource, IndexedSource, check_positive
from meep.geom import Vector3, init_do_averaging, GeometricObject, Medium
from meep.source import Source, EigenModeSource, GaussianBeamSource, IndexedSource, check_positive
import meep.visualization as vis
from meep.verbosity_mgr import Verbosity

Expand Down Expand Up @@ -933,40 +935,40 @@ class Simulation(object):
control various parameters of the Meep computation.
"""
def __init__(self,
cell_size,
resolution,
geometry=None,
sources=None,
eps_averaging=True,
dimensions=3,
boundary_layers=None,
symmetries=None,
force_complex_fields=False,
default_material=mp.Medium(),
m=0,
k_point=False,
kz_2d="complex",
extra_materials=None,
material_function=None,
epsilon_func=None,
epsilon_input_file='',
progress_interval=4,
subpixel_tol=1e-4,
subpixel_maxeval=100000,
loop_tile_base_db=0,
loop_tile_base_eh=0,
ensure_periodicity=True,
num_chunks=0,
Courant=0.5,
accurate_fields_near_cylorigin=False,
filename_prefix=None,
output_volume=None,
output_single_precision=False,
geometry_center=mp.Vector3(),
force_all_components=False,
split_chunks_evenly=True,
chunk_layout=None,
collect_stats=False):
cell_size: Vector3 = None,
resolution: float = None,
geometry: List[GeometricObject] = None,
sources: List[Source] = None,
eps_averaging: bool = True,
dimensions: int = 3,
boundary_layers: List[PML] = None,
symmetries: List[Symmetry] = None,
force_complex_fields: bool = False,
default_material: Medium = mp.Medium(),
m: int = 0,
oskooi marked this conversation as resolved.
Show resolved Hide resolved
k_point: bool = False,
kz_2d = "complex",
extra_materials: List[Medium] = None,
material_function = None,
epsilon_func = None,
epsilon_input_file: str = '',
progress_interval: float = 4.,
subpixel_tol: float = 1e-4,
subpixel_maxeval: int = 100000,
loop_tile_base_db: int = 0,
loop_tile_base_eh: int = 0,
ensure_periodicity: bool = True,
num_chunks: int = 0,
Courant: float = 0.5,
accurate_fields_near_cylorigin: bool = False,
filename_prefix: str = None,
output_volume: Volume = None,
output_single_precision: bool = False,
geometry_center: Vector3 = Vector3(),
force_all_components: bool = False,
split_chunks_evenly: bool = True,
chunk_layout = None,
collect_stats: bool = False):
"""
All `Simulation` attributes are described in further detail below. In brackets
after each variable is the type of value that it should hold. The classes, complex
Expand Down