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

Use None instead of empty list in constructors #1846

Merged
merged 2 commits into from
Dec 7, 2021
Merged
Show file tree
Hide file tree
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
18 changes: 9 additions & 9 deletions doc/docs/Python_User_Interface.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,18 +89,18 @@ control various parameters of the Meep computation.
def __init__(self,
cell_size,
resolution,
geometry=[],
sources=[],
geometry=None,
sources=None,
eps_averaging=True,
dimensions=3,
boundary_layers=[],
symmetries=[],
boundary_layers=None,
symmetries=None,
force_complex_fields=False,
default_material=Medium(),
m=0,
k_point=False,
kz_2d='complex',
extra_materials=[],
extra_materials=None,
material_function=None,
epsilon_func=None,
epsilon_input_file='',
Expand Down Expand Up @@ -4216,8 +4216,8 @@ def __init__(self,
epsilon_offdiag=Vector3<0.0, 0.0, 0.0>,
mu_diag=Vector3<1.0, 1.0, 1.0>,
mu_offdiag=Vector3<0.0, 0.0, 0.0>,
E_susceptibilities=[],
H_susceptibilities=[],
E_susceptibilities=None,
H_susceptibilities=None,
E_chi2_diag=Vector3<0.0, 0.0, 0.0>,
E_chi3_diag=Vector3<0.0, 0.0, 0.0>,
H_chi2_diag=Vector3<0.0, 0.0, 0.0>,
Expand Down Expand Up @@ -4638,8 +4638,8 @@ Absorption](Materials.md#saturable-gain-and-absorption).

```python
def __init__(self,
initial_populations=[],
transitions=[],
initial_populations=None,
transitions=None,
**kwargs):
```

Expand Down
14 changes: 7 additions & 7 deletions python/geom.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,8 +313,8 @@ def __init__(self, epsilon_diag=Vector3(1, 1, 1),
epsilon_offdiag=Vector3(),
mu_diag=Vector3(1, 1, 1),
mu_offdiag=Vector3(),
E_susceptibilities=[],
H_susceptibilities=[],
E_susceptibilities=None,
H_susceptibilities=None,
E_chi2_diag=Vector3(),
E_chi3_diag=Vector3(),
H_chi2_diag=Vector3(),
Expand Down Expand Up @@ -425,8 +425,8 @@ def __init__(self, epsilon_diag=Vector3(1, 1, 1),
self.epsilon_offdiag = Vector3(*epsilon_offdiag)
self.mu_diag = Vector3(*mu_diag)
self.mu_offdiag = Vector3(*mu_offdiag)
self.E_susceptibilities = E_susceptibilities
self.H_susceptibilities = H_susceptibilities
self.E_susceptibilities = E_susceptibilities if E_susceptibilities else []
self.H_susceptibilities = H_susceptibilities if H_susceptibilities else []
self.E_chi2_diag = Vector3(chi2, chi2, chi2) if chi2 else Vector3(*E_chi2_diag)
self.E_chi3_diag = Vector3(chi3, chi3, chi3) if chi3 else Vector3(*E_chi3_diag)
self.H_chi2_diag = Vector3(*H_chi2_diag)
Expand Down Expand Up @@ -842,10 +842,10 @@ class MultilevelAtom(Susceptibility):
atomic level. See [Materials/Saturable Gain and
Absorption](Materials.md#saturable-gain-and-absorption).
"""
def __init__(self, initial_populations=[], transitions=[], **kwargs):
def __init__(self, initial_populations=None, transitions=None, **kwargs):
super(MultilevelAtom, self).__init__(**kwargs)
self.initial_populations = initial_populations
self.transitions = transitions
self.initial_populations = initial_populations if initial_populations else []
self.transitions = transitions if transitions else []


class Transition(object):
Expand Down
20 changes: 10 additions & 10 deletions python/simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -935,18 +935,18 @@ class Simulation(object):
def __init__(self,
cell_size,
resolution,
geometry=[],
sources=[],
geometry=None,
sources=None,
eps_averaging=True,
dimensions=3,
boundary_layers=[],
symmetries=[],
boundary_layers=None,
symmetries=None,
force_complex_fields=False,
default_material=mp.Medium(),
m=0,
k_point=False,
kz_2d="complex",
extra_materials=[],
extra_materials=None,
material_function=None,
epsilon_func=None,
epsilon_input_file='',
Expand Down Expand Up @@ -1198,20 +1198,20 @@ def __init__(self,
"""

self.cell_size = Vector3(*cell_size)
self.geometry = geometry
self.sources = sources
self.geometry = geometry if geometry else []
self.sources = sources if sources else []
self.resolution = resolution
self.dimensions = dimensions
self.boundary_layers = boundary_layers
self.symmetries = symmetries
self.boundary_layers = boundary_layers if boundary_layers else []
self.symmetries = symmetries if symmetries else []
self.geometry_center = Vector3(*geometry_center)
self.eps_averaging = eps_averaging
self.subpixel_tol = subpixel_tol
self.subpixel_maxeval = subpixel_maxeval
self.loop_tile_base_db = loop_tile_base_db
self.loop_tile_base_eh = loop_tile_base_eh
self.ensure_periodicity = ensure_periodicity
self.extra_materials = extra_materials
self.extra_materials = extra_materials if extra_materials else []
self.default_material = default_material
self.epsilon_input_file = epsilon_input_file
self.num_chunks = chunk_layout.numchunks() if isinstance(chunk_layout,mp.BinaryPartition) else num_chunks
Expand Down
8 changes: 4 additions & 4 deletions python/solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ def __init__(self,
target_freq=0.0,
tolerance=1.0e-7,
num_bands=1,
k_points=[],
k_points=None,
ensure_periodicity=True,
geometry=[],
geometry=None,
geometry_lattice=mp.Lattice(),
geometry_center=mp.Vector3(0, 0, 0),
default_material=mp.Medium(epsilon=1),
Expand All @@ -104,8 +104,8 @@ def __init__(self,
self.mode_solver = None
self.resolution = resolution
self.eigensolver_flags = eigensolver_flags
self.k_points = k_points
self.geometry = geometry
self.k_points = k_points if k_points else []
self.geometry = geometry if geometry else []
self.geometry_lattice = geometry_lattice
self.geometry_center = mp.Vector3(*geometry_center)
self.default_material = default_material
Expand Down