Skip to content

Commit

Permalink
added log and fix pylint
Browse files Browse the repository at this point in the history
  • Loading branch information
tylerflex committed Nov 4, 2021
1 parent aa6705f commit 07bd20e
Show file tree
Hide file tree
Showing 8 changed files with 123 additions and 34 deletions.
6 changes: 5 additions & 1 deletion docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Methods
Simulation.plot_monitors
Simulation.plot_symmetries
Simulation.plot_pml
Simulation.plot_grid
Simulation.grid
Simulation.dt
Simulation.tmesh
Expand Down Expand Up @@ -84,6 +85,7 @@ Geometry
Sphere
Cylinder
PolySlab
PolySlab.from_gdspy

Methods
-------
Expand Down Expand Up @@ -259,7 +261,9 @@ Log
.. autosummary::
:toctree: _autosummary/

logging_level
log
set_logging_level
set_logging_file


Submitting Simulations
Expand Down
1 change: 1 addition & 0 deletions test_static.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ pytest -rA tests/test_plugins.py

pytest --doctest-modules tidy3d \
--ignore=tidy3d/__main__.py \
--ignore=tidy3d/log.py \
--ignore=tidy3d/components/base.py \
--ignore=tidy3d/web/webapi.py \
--ignore=tidy3d/web/container.py \
2 changes: 1 addition & 1 deletion tidy3d/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
from .material_library import material_library

# logging
from .log import log, logging_level
from .log import log, set_logging_level, set_logging_file

# for docs
from .components.medium import AbstractMedium
Expand Down
4 changes: 4 additions & 0 deletions tidy3d/components/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ class MonitorData(Tidy3dData, ABC):

@property
def data(self) -> xr.DataArray:
# pylint:disable=line-too-long
"""Returns an xarray representation of the montitor data.
Returns
Expand All @@ -114,6 +115,7 @@ def data(self) -> xr.DataArray:
Representation of the monitor data using xarray.
For more details refer to `xarray's Documentaton <http://xarray.pydata.org/en/stable/generated/xarray.DataArray.html>`_.
"""
# pylint:enable=line-too-long

data_dict = self.dict()
coords = {dim: data_dict[dim] for dim in self._dims}
Expand Down Expand Up @@ -187,6 +189,7 @@ class CollectionData(Tidy3dData):

@property
def data(self) -> xr.Dataset:
# pylint:disable=line-too-long
"""For field quantities, store a single xarray DataArray for each ``field``.
These all go in a single xarray Dataset, which keeps track of the shared coords.
Expand All @@ -196,6 +199,7 @@ def data(self) -> xr.Dataset:
Representation of the underlying data using xarray.
For more details refer to `xarray's Documentaton <http://xarray.pydata.org/en/stable/generated/xarray.Dataset.html>`_.
"""
# pylint:enable=line-too-long
data_arrays = {name: arr.data for name, arr in self.data_dict.items()}

# make an xarray dataset
Expand Down
33 changes: 23 additions & 10 deletions tidy3d/components/geometry.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# pylint:disable=too-many-lines
"""Defines spatial extent of objects."""

from abc import ABC, abstractmethod
Expand Down Expand Up @@ -65,7 +66,8 @@ def intersections(self, x: float = None, y: float = None, z: float = None) -> Li
-------
List[shapely.geometry.base.BaseGeometry]
List of 2D shapes that intersect plane.
For more details refer to `Shapely's Documentaton <https://shapely.readthedocs.io/en/stable/project.html>`_.
For more details refer to
`Shapely's Documentaton <https://shapely.readthedocs.io/en/stable/project.html>`_.
"""

def intersects(self, other) -> bool:
Expand Down Expand Up @@ -180,6 +182,7 @@ def _pop_bounds(self, axis: Axis) -> Tuple[Coordinate2D, Tuple[Coordinate2D, Coo
def plot(
self, x: float = None, y: float = None, z: float = None, ax: Ax = None, **patch_kwargs
) -> Ax:
# pylint:disable=line-too-long
"""Plot geometry cross section at single (x,y,z) coordinate.
Parameters
Expand All @@ -202,6 +205,7 @@ def plot(
matplotlib.axes._subplots.Axes
The supplied or created matplotlib axes.
"""
# pylint:disable=line-too-long

# find shapes that intersect self at plane
axis, position = self._parse_xyz_kwargs(x=x, y=y, z=z)
Expand Down Expand Up @@ -373,7 +377,8 @@ def intersections(self, x: float = None, y: float = None, z: float = None):
-------
List[shapely.geometry.base.BaseGeometry]
List of 2D shapes that intersect plane.
For more details refer to `Shapely's Documentaton <https://shapely.readthedocs.io/en/stable/project.html>`_.
For more details refer to
`Shapely's Documentaton <https://shapely.readthedocs.io/en/stable/project.html>`_.
"""
axis, position = self._parse_xyz_kwargs(x=x, y=y, z=z)
if axis == self.axis:
Expand All @@ -391,7 +396,8 @@ def _intersections_normal(self) -> list:
-------
List[shapely.geometry.base.BaseGeometry]
List of 2D shapes that intersect plane.
For more details refer to `Shapely's Documentaton <https://shapely.readthedocs.io/en/stable/project.html>`_.
For more details refer to
`Shapely's Documentaton <https://shapely.readthedocs.io/en/stable/project.html>`_.
"""

@abstractmethod
Expand All @@ -409,7 +415,8 @@ def _intersections_side(self, position: float, axis: Axis) -> list:
-------
List[shapely.geometry.base.BaseGeometry]
List of 2D shapes that intersect plane.
For more details refer to `Shapely's Documentaton <https://shapely.readthedocs.io/en/stable/project.html>`_.
For more details refer to
`Shapely's Documentaton <https://shapely.readthedocs.io/en/stable/project.html>`_.
"""

@property
Expand Down Expand Up @@ -519,7 +526,8 @@ def intersections(self, x: float = None, y: float = None, z: float = None):
-------
List[shapely.geometry.base.BaseGeometry]
List of 2D shapes that intersect plane.
For more details refer to `Shapely's Documentaton <https://shapely.readthedocs.io/en/stable/project.html>`_.
For more details refer to
`Shapely's Documentaton <https://shapely.readthedocs.io/en/stable/project.html>`_.
"""
axis, position = self._parse_xyz_kwargs(x=x, y=y, z=z)
z0, (x0, y0) = self.pop_axis(self.center, axis=axis)
Expand Down Expand Up @@ -636,7 +644,8 @@ def intersections(self, x: float = None, y: float = None, z: float = None):
-------
List[shapely.geometry.base.BaseGeometry]
List of 2D shapes that intersect plane.
For more details refer to `Shapely's Documentaton <https://shapely.readthedocs.io/en/stable/project.html>`_.
For more details refer to
`Shapely's Documentaton <https://shapely.readthedocs.io/en/stable/project.html>`_.
"""
axis, position = self._parse_xyz_kwargs(x=x, y=y, z=z)
z0, (x0, y0) = self.pop_axis(self.center, axis=axis)
Expand Down Expand Up @@ -688,7 +697,8 @@ def _intersections_normal(self):
-------
List[shapely.geometry.base.BaseGeometry]
List of 2D shapes that intersect plane.
For more details refer to `Shapely's Documentaton <https://shapely.readthedocs.io/en/stable/project.html>`_.
For more details refer to
`Shapely's Documentaton <https://shapely.readthedocs.io/en/stable/project.html>`_.
"""
_, (x0, y0) = self.pop_axis(self.center, axis=self.axis)
return [Point(x0, y0).buffer(self.radius)]
Expand All @@ -707,7 +717,8 @@ def _intersections_side(self, position, axis):
-------
List[shapely.geometry.base.BaseGeometry]
List of 2D shapes that intersect plane.
For more details refer to `Shapely's Documentaton <https://shapely.readthedocs.io/en/stable/project.html>`_.
For more details refer to
`Shapely's Documentaton <https://shapely.readthedocs.io/en/stable/project.html>`_.
"""
z0_axis, _ = self.pop_axis(self.center, axis=self.axis)
intersect_dist = self._intersect_dist(position, z0_axis)
Expand Down Expand Up @@ -912,7 +923,8 @@ def _intersections_normal(self):
-------
List[shapely.geometry.base.BaseGeometry]
List of 2D shapes that intersect plane.
For more details refer to `Shapely's Documentaton <https://shapely.readthedocs.io/en/stable/project.html>`_.
For more details refer to
`Shapely's Documentaton <https://shapely.readthedocs.io/en/stable/project.html>`_.
"""
return [Polygon(self.vertices)]

Expand All @@ -930,7 +942,8 @@ def _intersections_side(self, position, axis) -> list: # pylint:disable=too-man
-------
List[shapely.geometry.base.BaseGeometry]
List of 2D shapes that intersect plane.
For more details refer to `Shapely's Documentaton <https://shapely.readthedocs.io/en/stable/project.html>`_.
For more details refer to
`Shapely's Documentaton <https://shapely.readthedocs.io/en/stable/project.html>`_.
"""

z0, _ = self.pop_axis(self.center, axis=self.axis)
Expand Down
2 changes: 1 addition & 1 deletion tidy3d/components/monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Monitor(Box, ABC):
_name_validator = validate_name_str()

@add_ax_if_none
def plot( #pylint:disable=duplicate-code
def plot( # pylint:disable=duplicate-code
self, x: float = None, y: float = None, z: float = None, ax: Ax = None, **kwargs
) -> Ax:
"""Plot the monitor geometry on a cross section plane.
Expand Down
Loading

0 comments on commit 07bd20e

Please sign in to comment.