Commit 6f85b0f6 authored by Bas Nijholt's avatar Bas Nijholt
Browse files

use 'x is None' instead of 'x == None'

parent 5be0a9cd
...@@ -169,7 +169,7 @@ def test_edge_ids(): ...@@ -169,7 +169,7 @@ def test_edge_ids():
for i, edge_id in enumerate(g.all_edge_ids(-1, 0)): for i, edge_id in enumerate(g.all_edge_ids(-1, 0)):
if i == 0: if i == 0:
assert edge_id == g.first_edge_id(-1, 0) assert edge_id == g.first_edge_id(-1, 0)
assert g.tail(edge_id) == None assert g.tail(edge_id) is None
assert g.head(edge_id) == 0 assert g.head(edge_id) == 0
assert i == 2 assert i == 2
......
...@@ -910,7 +910,7 @@ def plot(sys, num_lead_cells=2, unit=None, ...@@ -910,7 +910,7 @@ def plot(sys, num_lead_cells=2, unit=None,
lead_hop_lw, pos_transform, lead_hop_lw, pos_transform,
cmap, colorbar, file, cmap, colorbar, file,
show) show)
elif _p.engine == None: elif _p.engine is None:
raise RuntimeError("Cannot use plot() without a plotting lib installed") raise RuntimeError("Cannot use plot() without a plotting lib installed")
else: else:
raise RuntimeError("plot() does not support engine '{}'".format(_p.engine)) raise RuntimeError("plot() does not support engine '{}'".format(_p.engine))
...@@ -980,7 +980,7 @@ def _plot_plotly(sys, num_lead_cells, unit, ...@@ -980,7 +980,7 @@ def _plot_plotly(sys, num_lead_cells, unit,
cmap, colorbar, file, cmap, colorbar, file,
show, fig=None): show, fig=None):
if unit == None: if unit is None:
unit = 'pt' unit = 'pt'
syst = sys # for naming consistency inside function bodies syst = sys # for naming consistency inside function bodies
...@@ -1278,7 +1278,7 @@ def _plot_plotly(sys, num_lead_cells, unit, ...@@ -1278,7 +1278,7 @@ def _plot_plotly(sys, num_lead_cells, unit,
showticklabels=True), showticklabels=True),
yaxis=dict(showgrid=False, zeroline=False, yaxis=dict(showgrid=False, zeroline=False,
showticklabels=True)) showticklabels=True))
if fig == None: if fig is None:
full_trace = list(itertools.chain.from_iterable([site_edge_trace, full_trace = list(itertools.chain.from_iterable([site_edge_trace,
site_node_trace, lead_edge_trace, site_node_trace, lead_edge_trace,
lead_node_trace])) lead_node_trace]))
...@@ -1306,7 +1306,7 @@ def _plot_matplotlib(sys, num_lead_cells, unit, ...@@ -1306,7 +1306,7 @@ def _plot_matplotlib(sys, num_lead_cells, unit,
cmap, colorbar, file, cmap, colorbar, file,
show, dpi, fig_size, ax): show, dpi, fig_size, ax):
if unit == None: if unit is None:
unit = 'nn' unit = 'nn'
syst = sys # for naming consistency inside function bodies syst = sys # for naming consistency inside function bodies
...@@ -1766,7 +1766,7 @@ def map(sys, value, colorbar=True, cmap=None, vmin=None, vmax=None, a=None, ...@@ -1766,7 +1766,7 @@ def map(sys, value, colorbar=True, cmap=None, vmin=None, vmax=None, a=None,
fig = _map_plotly(syst, img, colorbar, _max, _min, vmin, vmax, fig = _map_plotly(syst, img, colorbar, _max, _min, vmin, vmax,
overflow_pct, underflow_pct, cmap, num_lead_cells, overflow_pct, underflow_pct, cmap, num_lead_cells,
background) background)
elif _p.engine == None: elif _p.engine is None:
raise RuntimeError("Cannot use map() without a plotting lib installed") raise RuntimeError("Cannot use map() without a plotting lib installed")
else: else:
raise RuntimeError("map() does not support engine '{}'".format(_p.engine)) raise RuntimeError("map() does not support engine '{}'".format(_p.engine))
...@@ -2011,7 +2011,7 @@ def spectrum(syst, x, y=None, params=None, mask=None, file=None, ...@@ -2011,7 +2011,7 @@ def spectrum(syst, x, y=None, params=None, mask=None, file=None,
elif _p.engine == "plotly": elif _p.engine == "plotly":
_check_incompatible_args_plotly(dpi, fig_size, ax) _check_incompatible_args_plotly(dpi, fig_size, ax)
return _spectrum_plotly(syst, x, y, params, mask, file, show) return _spectrum_plotly(syst, x, y, params, mask, file, show)
elif _p.engine == None: elif _p.engine is None:
raise RuntimeError("Cannot use spectrum() without a plotting lib installed") raise RuntimeError("Cannot use spectrum() without a plotting lib installed")
else: else:
raise RuntimeError("spectrum() does not support engine '{}'".format(_p.engine)) raise RuntimeError("spectrum() does not support engine '{}'".format(_p.engine))
...@@ -2566,7 +2566,7 @@ def streamplot(field, box, cmap=None, bgcolor=None, linecolor='k', ...@@ -2566,7 +2566,7 @@ def streamplot(field, box, cmap=None, bgcolor=None, linecolor='k',
fig = _streamplot_plotly(field, box, cmap, bgcolor, linecolor, fig = _streamplot_plotly(field, box, cmap, bgcolor, linecolor,
max_linewidth, min_linewidth, density, max_linewidth, min_linewidth, density,
colorbar, file, show, vmax) colorbar, file, show, vmax)
elif _p.engine == None: elif _p.engine is None:
raise RuntimeError("Cannot use streamplot() without a plotting lib installed") raise RuntimeError("Cannot use streamplot() without a plotting lib installed")
else: else:
raise RuntimeError("streamplot() does not support engine '{}'".format(_p.engine)) raise RuntimeError("streamplot() does not support engine '{}'".format(_p.engine))
...@@ -2776,7 +2776,7 @@ def scalarplot(field, box, ...@@ -2776,7 +2776,7 @@ def scalarplot(field, box,
_check_incompatible_args_plotly(dpi, fig_size, ax) _check_incompatible_args_plotly(dpi, fig_size, ax)
fig = _scalarplot_plotly(field, box, cmap, colorbar, file, fig = _scalarplot_plotly(field, box, cmap, colorbar, file,
show, vmin, vmax, background) show, vmin, vmax, background)
elif _p.engine == None: elif _p.engine is None:
raise RuntimeError("Cannot use scalarplot() without a plotting lib installed") raise RuntimeError("Cannot use scalarplot() without a plotting lib installed")
else: else:
raise RuntimeError("scalarplot() does not support engine '{}'".format(_p.engine)) raise RuntimeError("scalarplot() does not support engine '{}'".format(_p.engine))
......
...@@ -118,7 +118,7 @@ class LeadWithOnlySelfEnergy: ...@@ -118,7 +118,7 @@ class LeadWithOnlySelfEnergy:
def selfenergy(self, energy, args=(), *, params=None): def selfenergy(self, energy, args=(), *, params=None):
assert args == () assert args == ()
assert params == None assert params is None
return self.lead.selfenergy(energy) return self.lead.selfenergy(energy)
......
...@@ -144,7 +144,7 @@ def test_site_families(): ...@@ -144,7 +144,7 @@ def test_site_families():
# test site families compare equal/not-equal # test site families compare equal/not-equal
assert fam == ofam assert fam == ofam
assert fam != yafam assert fam != yafam
assert fam != None assert fam is not None
assert fam != 'a' assert fam != 'a'
# test site families sorting # test site families sorting
......
...@@ -222,7 +222,7 @@ def test_norbs(): ...@@ -222,7 +222,7 @@ def test_norbs():
# Catch deprecation warning # Catch deprecation warning
with warnings.catch_warnings(): with warnings.catch_warnings():
warnings.simplefilter("ignore") warnings.simplefilter("ignore")
assert lattice.general(id_mat).norbs == None assert lattice.general(id_mat).norbs is None
assert lattice.general(id_mat, norbs=2).norbs == 2 assert lattice.general(id_mat, norbs=2).norbs == 2
# Polyatomic lattices # Polyatomic lattices
# Catch deprecation warning # Catch deprecation warning
...@@ -230,7 +230,7 @@ def test_norbs(): ...@@ -230,7 +230,7 @@ def test_norbs():
warnings.simplefilter("ignore") warnings.simplefilter("ignore")
lat = lattice.general(id_mat, basis=id_mat, norbs=None) lat = lattice.general(id_mat, basis=id_mat, norbs=None)
for l in lat.sublattices: for l in lat.sublattices:
assert l.norbs == None assert l.norbs is None
lat = lattice.general(id_mat, basis=id_mat, norbs=2) lat = lattice.general(id_mat, basis=id_mat, norbs=2)
for l in lat.sublattices: for l in lat.sublattices:
assert l.norbs == 2 assert l.norbs == 2
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment