Skip to content

Commit

Permalink
Type hinting (#2176)
Browse files Browse the repository at this point in the history
* add type hinting to visualization

* import visualization on-the-fly in Simulation
  • Loading branch information
thomasdorch authored Jul 30, 2022
1 parent 881d0f7 commit 442b921
Show file tree
Hide file tree
Showing 2 changed files with 178 additions and 121 deletions.
9 changes: 8 additions & 1 deletion python/simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
except ImportError:
from collections.abc import Sequence

import meep.visualization as vis
import numpy as np
from meep.geom import GeometricObject, Medium, Vector3, init_do_averaging
from meep.source import (
Expand Down Expand Up @@ -4680,6 +4679,8 @@ def plot2D(
- `post_process=np.real`: post processing function to apply to fields (must be
a function object)
"""
import meep.visualization as vis

return vis.plot2D(
self,
ax=ax,
Expand All @@ -4700,13 +4701,17 @@ def plot2D(
)

def plot_fields(self, **kwargs):
import meep.visualization as vis

return vis.plot_fields(self, **kwargs)

def plot3D(self):
"""
Uses Mayavi to render a 3D simulation domain. The simulation object must be 3D.
Can also be embedded in Jupyter notebooks.
"""
import meep.visualization as vis

return vis.plot3D(self)

def visualize_chunks(self):
Expand All @@ -4715,6 +4720,8 @@ def visualize_chunks(self):
rectangular region is a chunk, and each color represents a different processor.
Requires [matplotlib](https://matplotlib.org).
"""
import meep.visualization as vis

vis.visualize_chunks(self)


Expand Down
Loading

0 comments on commit 442b921

Please sign in to comment.