Skip to content

Commit 00d1280

Browse files
committed
fix docstring tests
1 parent a0cb079 commit 00d1280

File tree

3 files changed

+25
-8
lines changed

3 files changed

+25
-8
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1212
### Fixed
1313
- Port name duplication in smatrix plugin for multimode ports.
1414
- Web functions create the leading directories for the supplied filename if they don't exist.
15+
- Some docstring examples that were giving warnings.
1516

1617
## [2.0.2] - 2023-4-3
1718

tidy3d/components/boundary.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def from_source(
9797
>>> from tidy3d import GaussianPulse, PlaneWave, inf
9898
>>> pulse = GaussianPulse(freq0=200e12, fwidth=20e12)
9999
>>> pw_source = PlaneWave(
100-
... size=(inf,inf,0), source_time=pulse, direction='+', angle_theta=1.5, angle_phi=0.3)
100+
... size=(inf,inf,0), source_time=pulse, direction='+', angle_theta=0.2, angle_phi=0.3)
101101
>>> bloch = BlochBoundary.from_source(source=pw_source, domain_size=5, axis=0)
102102
"""
103103

@@ -457,7 +457,7 @@ def bloch_from_source(
457457
>>> from tidy3d import GaussianPulse, PlaneWave, inf
458458
>>> pulse = GaussianPulse(freq0=200e12, fwidth=20e12)
459459
>>> pw_source = PlaneWave(
460-
... size=(inf,inf,0), source_time=pulse, direction='+', angle_theta=1.5, angle_phi=0.3)
460+
... size=(inf,inf,0), source_time=pulse, direction='+', angle_theta=0.2, angle_phi=0.3)
461461
>>> bloch = Boundary.bloch_from_source(source=pw_source, domain_size=5, axis=0)
462462
"""
463463
plus = BlochBoundary.from_source(

tidy3d/components/data/sim_data.py

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class SimulationData(Tidy3dBaseModel):
2525
2626
Example
2727
-------
28-
>>> from tidy3d import ModeSpec, GridSpec, ScalarFieldDataArray, FieldMonitor, FieldData
28+
>>> import tidy3d as td
2929
>>> num_modes = 5
3030
>>> x = [-1,1]
3131
>>> y = [-2,0,2]
@@ -35,16 +35,32 @@ class SimulationData(Tidy3dBaseModel):
3535
>>> mode_index = np.arange(num_modes)
3636
>>> direction = ["+", "-"]
3737
>>> coords = dict(x=x, y=y, z=z, f=f)
38-
>>> scalar_field = ScalarFieldDataArray((1+1j) * np.random.random((2,3,4,2)), coords=coords)
39-
>>> field_monitor = FieldMonitor(size=(2,4,6), freqs=[2e14, 3e14], name='field', fields=['Ex'])
38+
>>> scalar_field = td.ScalarFieldDataArray((1+1j) * np.random.random((2,3,4,2)), coords=coords)
39+
>>> field_monitor = td.FieldMonitor(
40+
... size=(2,4,6),
41+
... freqs=[2e14, 3e14],
42+
... name='field',
43+
... fields=['Ex'],
44+
... )
4045
>>> sim = Simulation(
4146
... size=(2, 4, 6),
42-
... grid_spec=GridSpec(wavelength=1.0),
47+
... grid_spec=td.GridSpec(wavelength=1.0),
4348
... monitors=[field_monitor],
4449
... run_time=2e-12,
50+
... sources=[
51+
... td.UniformCurrentSource(
52+
... size=(0, 0, 0),
53+
... center=(0, 0.5, 0),
54+
... polarization="Hx",
55+
... source_time=td.GaussianPulse(
56+
... freq0=2e14,
57+
... fwidth=4e13,
58+
... ),
59+
... )
60+
... ],
4561
... )
46-
>>> field_data = FieldData(monitor=field_monitor, Ex=scalar_field)
47-
>>> sim_data = SimulationData(simulation=sim, data=(field_data,))
62+
>>> field_data = td.FieldData(monitor=field_monitor, Ex=scalar_field)
63+
>>> sim_data = td.SimulationData(simulation=sim, data=(field_data,))
4864
"""
4965

5066
simulation: Simulation = pd.Field(

0 commit comments

Comments
 (0)