Commit 5e8183ce authored by Daniel Brown's avatar Daniel Brown
Browse files

Changing None comparisons to use is instead of ==

parent 135f3669
......@@ -541,7 +541,7 @@ class mirror(AbstractMirrorComponent):
if not USE_GUI:
raise NoGUIException
if self._svgItem == None:
if self._svgItem is None:
self._svgItem = pykat.gui.graphics.ComponentQGraphicsItem(":/resources/mirror_flat.svg", self ,[(-4,15,self.nodes[0]), (14,15,self.nodes[1])])
return self._svgItem
......@@ -647,7 +647,7 @@ class beamSplitter(AbstractMirrorComponent):
if not USE_GUI:
raise NoGUIException
if self._svgItem == None:
if self._svgItem is None:
# FIXME: make proper SVG component for beam splitter
self._svgItem = pykat.gui.graphics.ComponentQGraphicsItem(":/resources/mirror_flat.svg", self ,[(-4,24,self.nodes[0]), (-4,6,self.nodes[1]), (14,6,self.nodes[2]), (14,24,self.nodes[3])])
......@@ -757,7 +757,7 @@ class space(Component):
if not USE_GUI:
raise NoGUIException
if self._QItem == None:
if self._QItem is None:
self._QItem = pykat.gui.graphics.SpaceQGraphicsItem(self)
return self._QItem
......@@ -890,7 +890,7 @@ class grating(Component):
if not USE_GUI:
raise NoGUIException
if self._svgItem == None:
if self._svgItem is None:
self._svgItem = pykat.gui.graphics.SpaceQGraphicsItem(self) # TODO: make SVG graphic for grating
return self._svgItem
......@@ -965,7 +965,7 @@ class isolator(Component):
if not USE_GUI:
raise NoGUIException
if self._svgItem == None:
if self._svgItem is None:
self._svgItem = pykat.gui.graphics.ComponentQGraphicsItem(":/resources/isolator.svg", self ,[(-4,15,self.nodes[0]), (14,15,self.nodes[1]), (14,24,self.nodes[2])])
return self._svgItem
......@@ -1035,7 +1035,7 @@ class lens(Component):
if not USE_GUI:
raise NoGUIException
if self._svgItem == None:
if self._svgItem is None:
self._svgItem = pykat.gui.graphics.ComponentQGraphicsItem(":/resources/lens.svg", self ,[(-4,15,self.nodes[0]), (14,15,self.nodes[1])])
return self._svgItem
......@@ -1141,7 +1141,7 @@ class modulator(Component):
if not USE_GUI:
raise NoGUIException
if self._svgItem == None:
if self._svgItem is None:
self._svgItem = pykat.gui.graphics.ComponentQGraphicsItem(":/resources/modulator.svg", self ,[(-4,15,self.nodes[0]), (14,15,self.nodes[1])])
return self._svgItem
......@@ -1233,7 +1233,7 @@ class laser(Component):
if not USE_GUI:
raise NoGUIException
if self._svgItem == None:
if self._svgItem is None:
self._svgItem = pykat.gui.graphics.ComponentQGraphicsItem(":/resources/laser.svg", self, [(65,25,self.nodes[0])])
return self._svgItem
......@@ -1299,7 +1299,7 @@ class squeezer(Component):
if not USE_GUI:
raise NoGUIException
if self._svgItem == None:
if self._svgItem is None:
self._svgItem = pykat.gui.graphics.ComponentQGraphicsItem(":/resources/laser.svg", self, [(65,25,self.nodes[0])])
return self._svgItem
......
......@@ -167,7 +167,7 @@ class BaseDetector(object) :
self._mask[_id] = factor
def _set_node(value, index):
if self._kat == None:
if self._kat is None:
raise pkex.BasePyKatException("This detector has not been added to a kat object yet")
else:
if value[-1] == '*':
......@@ -267,7 +267,7 @@ class ad(Detector1):
else:
alt = ''
if self.mode == None:
if self.mode is None:
rtn.append("ad {name} {f} {node}{alt}".format(name=self.name, f=str(self.f.value), node=self.node.name, alt=alt))
else:
rtn.append("ad {name} {n} {m} {f} {node}{alt}".format(name=self.name, n=str(self.mode[0]), m=str(self.mode[1]), f=str(self.f.value), node=self.node.name, alt=alt))
......@@ -289,7 +289,7 @@ class gouy(Detector1):
def direction(self): return self.__dir
@direction.setter
def direction(self, value):
if value == None or (value != 'x' and value != 'y'):
if value is None or (value != 'x' and value != 'y'):
raise pkex.BasePyKatException('Direction must be either x or y')
self.__dir = value
......@@ -299,7 +299,7 @@ class gouy(Detector1):
@spaces.setter
def spaces(self, value):
if value == None or len(value) < 1:
if value is None or len(value) < 1:
raise pkex.BasePyKatException('Must be a list of space names')
self.__spaces = value
......@@ -338,7 +338,7 @@ class bp(Detector1):
def direction(self): return self.__dir
@direction.setter
def direction(self, value):
if value == None or (value != 'x' and value != 'y'):
if value is None or (value != 'x' and value != 'y'):
raise pkex.BasePyKatException('Direction must be either x or y')
self.__dir = value
......@@ -348,7 +348,7 @@ class bp(Detector1):
@parameter.setter
def parameter(self, value):
if value == None or (value not in self.acceptedParameters) :
if value is None or (value not in self.acceptedParameters) :
raise pkex.BasePyKatException('Parameter must be one of: %s'%(", ".join(self.acceptedParameters)))
self.__param = value
......@@ -450,7 +450,7 @@ class pd(Detector1):
p = 'phi{0}'.format(i+1)
if p in kwargs:
if kwargs[p] == None and i<num_demods-1:
if kwargs[p] is None and i<num_demods-1:
raise pkex.BasePyKatException("Missing demodulation phase {0} (phi{0})".format(i+1))
ps[i].value = kwargs[p]
......@@ -498,7 +498,7 @@ class pd(Detector1):
def __set_phi(self, num, value):
value = SIfloat(value)
if value == None and num != self.num_demods:
if value is None and num != self.num_demods:
# check if we are setting no phase that this is only on the last
# demodulation phase.
raise pkex.BasePyKatException("Only last demodulation phase can be set to None")
......@@ -608,7 +608,7 @@ class pd(Detector1):
senstype = self.senstype
if senstype == None:
if senstype is None:
senstype = ""
rtn.append("pd{0}{1} {2}{3} {4}{5}".format(senstype, self.num_demods, self.name, fphi_str, self.node.name, alt_str))
......@@ -714,7 +714,7 @@ class qnoised(pd):
senstype = self.senstype
if senstype == None:
if senstype is None:
senstype = ""
rtn.append("qnoised{5} {0} {1} {2} {3}{4}".format(self.name, self.num_demods, fphi_str, self.node.name, alt_str, senstype))
......@@ -806,7 +806,7 @@ class qshot(pd):
senstype = self.senstype
if senstype == None:
if senstype is None:
senstype = ""
rtn.append("qshot{5} {0} {1} {2} {3}{4}".format(self.name, self.num_demods, fphi_str, self.node.name, alt_str,senstype))
......@@ -915,7 +915,7 @@ class qhd(Detector2):
def sensitivity(self, value):
if value == 'S' or value == 'N':
self.__sensitivity = value
elif value == None or value == '':
elif value is None or value == '':
self.__sensitivity = ""
else:
raise pkex.BasePyKatException("qhd (%s) sensitivity option '%s' is not available, use either 'S' or 'N'." % (self.name, value))
......
......@@ -108,7 +108,7 @@ def f__lkat_process(callback, cmd, kwargs):
"""
"""
if lkat_location == None:
if lkat_location is None:
raise RuntimeError("Could not find shared library 'libkat', please install to a system location or copy to the same directory as this script")
lkat = ctypes.PyDLL(lkat_location)
......@@ -238,7 +238,7 @@ class katRun(object):
elif self.yaxis == "re:im":
out = self.y[:, idx[0]] + 1j*self.y[:, idx[1]]
if out == None:
if out is None:
out = self.y[:, idx]
if out.size == 1:
......@@ -379,10 +379,10 @@ class Signals(object):
def apply(self, target, amplitude, phase, name=None):
if target == None:
if target is None:
raise pkex.BasePyKatException("No target was specified for signal to be applied")
if name == None:
if name is None:
name = "sig_" + target._owner().name + "_" + target.name
self.targets.append(Signals.fsig(target, name, amplitude, phase, self))
......@@ -899,14 +899,14 @@ class kat(object):
comp = self.__components[v[2]]
if comp._default_fsig() == None:
if comp._default_fsig() is None:
raise pkex.BasePyKatException("Component '{0}' cannot be fsig'd. Line: '{1}'".format(comp.name, line))
param = None
amp = None
if len(v) == 5:
param == None
param is None
freq = float(v[3])
phase = float(v[4])
elif len(v) == 6:
......@@ -990,7 +990,7 @@ class kat(object):
# Get the environment variable for where Finesse is stored
self.__finesse_dir = os.environ.get('FINESSE_DIR')
if self.__finesse_dir == None :
if self.__finesse_dir is None :
raise pkex.MissingFinesseEnvVar()
else:
self.__finesse_dir = self.__katdir
......@@ -1031,7 +1031,7 @@ class kat(object):
r.katScript+=(plot+"\n")
# create a kat file which we will write the script into
if self.__tempname == None:
if self.__tempname is None:
katfile = tempfile.NamedTemporaryFile(mode ='w', suffix=".kat", dir=self.__tempdir)
else:
filepath =os.path.join(self.__tempdir, self.__tempname+".kat" )
......@@ -1220,7 +1220,7 @@ class kat(object):
#r.ylabels = map(str.strip, hdr[1:]) // replaced 090415 adf
if save_kat:
if kat_name == None:
if kat_name is None:
kat_name = "pykat_output"
cwd = os.path.os.getcwd()
......@@ -1334,7 +1334,7 @@ class kat(object):
self.printmatrix = None
self.noxaxis = prev
if self.__prevrunfilename == None:
if self.__prevrunfilename is None:
return None
else:
......@@ -1771,11 +1771,11 @@ class kat(object):
self.app = QCoreApplication.instance()
created = False
if self.app == None:
if self.app is None:
created = True
self.app = QApplication([""])
if self.pykatgui == None:
if self.pykatgui is None:
self.pykatgui = pyKatGUI(self)
self.pykatgui.main()
else:
......@@ -1842,7 +1842,7 @@ class kat(object):
from the beam tracing routine for each node and space components defined as well as cavity
commands.
"""
if lkat_location == None:
if lkat_location is None:
raise RuntimeError("Could not find shared library 'libkat', please install to a system location or copy to the same directory as this script")
trace_info = Manager().dict()
......
......@@ -163,9 +163,9 @@ class NodeNetwork(object):
l = list(comps)
if l[0] == None:
if l[0] is None:
l[0] = comp
elif l[1] == None:
elif l[1] is None:
l[1] = comp
else:
raise pkex.BasePyKatException("Connected to two coponents already")
......@@ -420,7 +420,7 @@ class NodeNetwork(object):
else:
raise pkex.BasePyKatException("Did not handle component {0} correctly, has more or less than 2 nodes.".format(currcomp))
if nextnode == None:
if nextnode is None:
branches[-1][0] = True
return False
elif nextnode == tnode:
......@@ -437,7 +437,7 @@ class NodeNetwork(object):
else:
raise pkex.BasePyKatException("Unexpeceted condition")
if nextcomp == None:
if nextcomp is None:
branches[-1][0] = True
return False
......@@ -606,7 +606,7 @@ class Node(object):
if not USE_GUI:
raise NoGUIException
if self._item == None:
if self._item is None:
self._item = pykat.gui.graphics.NodeQGraphicItem(self,
dx,dy,
-nsize/2,-nsize/2,
......@@ -625,7 +625,7 @@ class Node(object):
comps = self.components
if obj == comps[0]:
if comps[1] == None:
if comps[1] is None:
ix = -1
else:
ix = comps[1].nodes.index(self)
......@@ -633,7 +633,7 @@ class Node(object):
return [True, comps[1], ix]
elif obj == comps[1]:
if comps[0] == None:
if comps[0] is None:
ix = -1
else:
ix = comps[0].nodes.index(self)
......
......@@ -85,22 +85,22 @@ class gauss_param(object):
def beamsize(self, z=None, wavelength=None, nr=None, w0=None):
if z == None:
if z is None:
z = self.z
else:
z = np.array(z)
if wavelength == None:
if wavelength is None:
wavelength = self.wavelength
else:
wavelength = np.array(wavelength)
if nr == None:
if nr is None:
nr = self.nr
else:
nr = np.array(nr)
if w0 == None:
if w0 is None:
w0 = self.w0
else:
w0 = np.array(w0)
......@@ -110,22 +110,22 @@ class gauss_param(object):
return np.abs(q)*np.sqrt(wavelength / (nr * math.pi * q.imag))
def gouy(self, z=None, wavelength=None, nr=None, w0=None):
if z == None:
if z is None:
z = self.z
else:
z = np.array(z)
if wavelength == None:
if wavelength is None:
wavelength = self.wavelength
else:
wavelength = np.array(wavelength)
if nr == None:
if nr is None:
nr = self.nr
else:
nr = np.array(nr)
if w0 == None:
if w0 is None:
w0 = self.w0
else:
w0 = np.array(w0)
......@@ -151,22 +151,22 @@ class gauss_param(object):
return v(self.z, self.zr)
def curvature(self, z=None, wavelength=None, nr=None, w0=None):
if z == None:
if z is None:
z = self.z
else:
z = np.array(z)
if wavelength == None:
if wavelength is None:
wavelength = self.wavelength
else:
wavelength = np.array(wavelength)
if nr == None:
if nr is None:
nr = self.nr
else:
nr = np.array(nr)
if w0 == None:
if w0 is None:
w0 = self.w0
else:
w0 = np.array(w0)
......@@ -226,7 +226,7 @@ class gauss_param(object):
return beam_param(self.__lambda, self.__nr, -self.__q)
def __eq__(self, q):
if q == None:
if q is None:
return False
return complex(q) == self.__q
......@@ -255,7 +255,7 @@ class HG_beam(object):
self._qx = copy.deepcopy(qx)
self._2pi_qrt = math.pow(2.0/math.pi, 0.25)
if qy == None:
if qy is None:
self._qy = copy.deepcopy(qx)
else:
self._qy = copy.deepcopy(qy)
......
......@@ -52,10 +52,10 @@ def makeCouplingMatrix(max_order, Neven=True, Nodd=True, Meven=True, Modd=True):
def adaptive_knm(mode_in, mode_out, q1, q2, q1y=None, q2y=None, smap=None, delta=(0,0), params={}):
if q1y == None:
if q1y is None:
q1y = q1
if q2y == None:
if q2y is None:
q2y = q2
if "epsabs" not in params: params["epsabs"] = 1e-6
......@@ -71,7 +71,7 @@ def adaptive_knm(mode_in, mode_out, q1, q2, q1y=None, q2y=None, smap=None, delta
Nfuncs = []
Nfuncs.append(0)
if smap != None:
if smap is not None:
if not params["usepolar"]:
xlims = (min(smap.x), max(smap.x))
......@@ -167,7 +167,7 @@ def riemann_HG_knm(x, y, mode_in, mode_out, q1, q2, q1y=None, q2y=None,
dx = abs(x[1] - x[0])
dy = abs(y[1] - y[0])
if cache == None:
if cache is None:
Hg_in = HG_beam(qx=q1, qy=q1y, n=mode_in[0], m=mode_in[1])
Hg_out = HG_beam(qx=q2, qy=q2y, n=mode_out[0], m=mode_out[1])
......@@ -210,10 +210,10 @@ def riemann_HG_knm(x, y, mode_in, mode_out, q1, q2, q1y=None, q2y=None,
def __gen_riemann_knm_cache(x, y, couplings, q1, q2, q1y=None, q2y=None, delta=(0,0), params={}):
if q1y == None:
if q1y is None:
q1y = q1
if q2y == None:
if q2y is None:
q2y = q2
it = np.nditer(couplings, flags=['refs_ok','f_index'])
......@@ -248,10 +248,10 @@ def __gen_riemann_knm_cache(x, y, couplings, q1, q2, q1y=None, q2y=None, delta=(
def __gen_ROM_HG_knm_cache(weights, couplings, q1, q2, q1y=None, q2y=None):
if q1y == None:
if q1y is None:
q1y = q1
if q2y == None:
if q2y is None:
q2y = q2
it = np.nditer(couplings, flags=['refs_ok','f_index'])
......@@ -288,10 +288,10 @@ def __gen_ROM_HG_knm_cache(weights, couplings, q1, q2, q1y=None, q2y=None):
def ROM_HG_knm(weights, mode_in, mode_out, q1, q2, q1y=None, q2y=None, cache=None):
if q1y == None:
if q1y is None:
q1y = q1
if q2y == None:
if q2y is None:
q2y = q2
# x modes
......@@ -303,7 +303,7 @@ def ROM_HG_knm(weights, mode_in, mode_out, q1, q2, q1y=None, q2y=None, cache=Non
mpr = mode_out[1]
if isinstance(weights, ROMWeights):
if cache == None:
if cache is None:
u_x_nodes = u_star_u(q1.z, q2.z, q1.w0, q2.w0, n, m, weights.EIx.nodes)
u_y_nodes = u_star_u(q1y.z, q2y.z, q1y.w0, q2y.w0, npr, mpr, weights.EIy.nodes)
......@@ -353,7 +353,7 @@ def ROM_HG_knm(weights, mode_in, mode_out, q1, q2, q1y=None, q2y=None, cache=Non
k_ROQ = np.einsum('ij,ij', u_xy_nodes, w_ij_Q2Q4) - np.einsum('ij,ij', u_xy_nodes, w_ij_Q1Q3)
else:
if cache == None:
if cache is None:
u_x_nodes = u_star_u(q1.z, q2.z, q1.w0, q2.w0, n, m, weights.EIx.nodes)
u_y_nodes = u_star_u(q1y.z, q2y.z, q1y.w0, q2y.w0, npr, mpr, weights.EIy.nodes)
......@@ -451,10 +451,10 @@ def __bayerhelms_kn(n, _n, q1, q2, gamma=0.0):
def bayerhelms_HG_knm(mode_in, mode_out, q1, q2, q1y=None, q2y=None, gamma=(0,0)):
if q1y == None:
if q1y is None:
q1y = q1
if q2y == None:
if q2y is None:
q2y = q2
# x modes
......@@ -525,10 +525,10 @@ def square_aperture_HG_knm(mode_in, mode_out, q, R):
def knmHG(couplings, q1, q2, surface_map=None, q1y=None, q2y=None, method="riemann", verbose=False, profile=False, gamma=(0,0), delta=(0,0), params={}):
if q1y == None:
if q1y is None:
q1y = q1
if q2y == None:
if q2y is None:
q2y = q2
assert q1.wavelength == q2.wavelength and q1y.wavelength == q2y.wavelength and q1y.wavelength == q1.wavelength
......@@ -551,7 +551,7 @@ def knmHG(couplings, q1, q2, surface_map=None, q1y=None, q2y=None, method="riema
for n in range(0, maxtem+1):
__fac_cache.append(math.factorial(n))
if surface_map != None:
if surface_map is not None:
Axy = surface_map.z_xy(wavelength=q1.wavelength)
x = surface_map.x
......@@ -567,18 +567,18 @@ def knmHG(couplings, q1, q2, surface_map=None, q1y=None, q2y=None, method="riema
t0 = time.time()
if method == "romhom":
if surface_map == None:
if surface_map is None:
raise BasePyKatException("Using 'romhom' method requires a surface map to be specified")
weights = surface_map.ROMWeights
if weights == None:
if weights is None:
raise BasePyKatException("The ROM weights need to be generated for this map before use.")
cache = __gen_ROM_HG_knm_cache(weights, couplings, q1=q1, q2=q2, q1y=q1y, q2y=q2y)
elif method == "riemann":
if surface_map == None:
if surface_map is None:
raise BasePyKatException("Using 'riemann' method requires a surface map to be specified")
cache = __gen_riemann_knm_cache(x, y, couplings, q1, q2, q1y=None, q2y=None, delta=delta)
......
......@@ -169,7 +169,7 @@ def u(re_q1, w0_1, n1, x):
def u_star_u(re_q1, re_q2, w0_1, w0_2, n1, n2, x, x2=None):
if x2 == None:
if x2 is None:
x2 = x
return u(re_q1, w0_1, n1, x) * u(re_q2, w0_2, n2, x2).conjugate()
......@@ -183,7 +183,7 @@ def u_star_u_mm(z, w0, n1, n2, x):
def makeReducedBasis(x, isModeMatched=True, tolerance = 1e-12, sigma = 1, greedyfile=None):
if greedyfile != None:
if greedyfile is not None:
greedypts = str(greedyfile)
else:
if isModeMatched:
......
......@@ -80,13 +80,13 @@ class Param(putable, putter):
if canFsig:
self._canFsig = True
if fsig_name == None:
if fsig_name is None:
raise pkex.BasePyKatException("If parameter is a possible fsig target the fsig_name argument must be set")
self.__fsig_name = fsig_name
if isPutter:
if var_name == None:
if var_name is None:
var_name = "var_{0}_{1}".format(owner.name, name)
putter.__init__(self, var_name, isPutter)
......
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