Permalink
Browse files

Compare to `None` using identity `is` operator

This is a trivial change that replaces `==` operator with `is` operator, following PEP 8 guideline:

> Comparisons to singletons like None should always be done with is or is not, never the equality operators.

https://legacy.python.org/dev/peps/pep-0008/#programming-recommendations
  • Loading branch information...
janisozaur committed Oct 30, 2018
1 parent b39c597 commit 9a8feecbedc8a097ee9707bcfcbf29f2816baca0
@@ -365,7 +365,7 @@ def py_psi_set_global_option_python(key, EXTERN):
if (key != "EXTERN"):
raise ValidationError("Options: set_global_option_python does not recognize keyword %s" % key)
if EXTERN == None:
if EXTERN is None:
core.EXTERN = None
core.set_global_option("EXTERN", False)
elif isinstance(EXTERN, core.ExternalPotential):
@@ -487,15 +487,15 @@ def invalidate(self):
def print_in_input_format(self):
"""Prints the updated geometry, in the format provided by the user"""
text = ""
if self.rto == None and self.ato == None and self.dto == None:
if self.rto is None and self.ato is None and self.dto is None:
# The first atom
text += "\n"
elif self.ato == None and self.dto == None:
elif self.ato is None and self.dto is None:
# The second atom
now_rto = self.rto.entry_number() + 1
now_rval = self.rval.variable_to_string(10)
text += " %5d %11s\n" % (now_rto, now_rval)
elif self.dto == None:
elif self.dto is None:
# The third atom
now_rto = self.rto.entry_number() + 1
now_rval = self.rval.variable_to_string(10)
@@ -518,15 +518,15 @@ def print_in_input_format(self):
def print_in_input_format_cfour(self):
"""Prints the updated geometry, in the format provided by the user"""
text = ""
if self.rto == None and self.ato == None and self.dto == None:
if self.rto is None and self.ato is None and self.dto is None:
# The first atom
text += "\n"
elif self.ato == None and self.dto == None:
elif self.ato is None and self.dto is None:
# The second atom
now_rto = self.rto.entry_number() + 1
now_rval = self.rval.variable_to_string(10)
text += " %d %s\n" % (now_rto, now_rval)
elif self.dto == None:
elif self.dto is None:
# The third atom
now_rto = self.rto.entry_number() + 1
now_rval = self.rval.variable_to_string(10)
@@ -594,21 +594,21 @@ def compute(self):
return self.coordinates
# place first atom at the origin
if self.rto == None and self.ato == None and self.dto == None:
if self.rto is None and self.ato is None and self.dto is None:
self.coordinates[0] = 0.0
self.coordinates[1] = 0.0
self.coordinates[2] = 0.0
# place second atom directly above the first
elif self.ato == None and self.dto == None:
elif self.ato is None and self.dto is None:
self.coordinates[0] = 0.0
self.coordinates[1] = 0.0
self.coordinates[2] = self.rval.compute()
# place third atom pointing upwards
# this rTo rVal aTo aVal
# A B C
elif self.dto == None:
elif self.dto is None:
r = self.rval.compute()
a = self.aval.compute() * math.pi / 180.0
cosABC = math.cos(a)
@@ -1781,7 +1781,7 @@ def rotor_type(self, tol=FULL_PG_TOL):
"""
rot_const = self.rotational_constants()
for i in range(3):
if rot_const[i] == None:
if rot_const[i] is None:
rot_const[i] = 0.0
# Determine degeneracy of rotational constants.
@@ -299,7 +299,7 @@ def query_yes_no(question, default=True):
yes = re.compile(r'^(y|yes|true|on|1)', re.IGNORECASE)
no = re.compile(r'^(n|no|false|off|0)', re.IGNORECASE)
if default == None:
if default is None:
prompt = " [y/n] "
elif default == True:
prompt = " [Y/n] "

0 comments on commit 9a8feec

Please sign in to comment.