Skip to content

Commit

Permalink
fix type comparisons
Browse files Browse the repository at this point in the history
  • Loading branch information
berquist committed Aug 7, 2024
1 parent 74c7b51 commit 7034dec
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
18 changes: 9 additions & 9 deletions cclib/parser/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,15 +227,15 @@ def listify(self) -> None:
attrlist = [k for k in self._attrlist if hasattr(self, k)]
for k in attrlist:
v = self._attributes[k].type
if v == numpy.ndarray:
if v is numpy.ndarray:
setattr(self, k, getattr(self, k).tolist())
elif v == list and k in self._listsofarrays:
elif v is list and k in self._listsofarrays:
setattr(self, k, [x.tolist() for x in getattr(self, k)])
elif v == dict and k in self._dictsofarrays:
elif v is dict and k in self._dictsofarrays:
items = getattr(self, k).items()
pairs = [(key, val.tolist()) for key, val in items]
setattr(self, k, dict(pairs))
elif v == dict and k in self._dictsofdicts:
elif v is dict and k in self._dictsofdicts:
items = getattr(self, k).items()
pairs = [
(key, {subkey: subval.tolist()})
Expand All @@ -253,15 +253,15 @@ def arrayify(self) -> None:
precision = "d"
if k in self._intarrays:
precision = "i"
if v == numpy.ndarray:
if v is numpy.ndarray:
setattr(self, k, numpy.array(getattr(self, k), precision))
elif v == list and k in self._listsofarrays:
elif v is list and k in self._listsofarrays:
setattr(self, k, [numpy.array(x, precision) for x in getattr(self, k)])
elif v == dict and k in self._dictsofarrays:
elif v is dict and k in self._dictsofarrays:
items = getattr(self, k).items()
pairs = [(key, numpy.array(val, precision)) for key, val in items]
setattr(self, k, dict(pairs))
elif v == dict and k in self._dictsofdicts:
elif v is dict and k in self._dictsofdicts:
items = getattr(self, k).items()
pairs = [
(
Expand Down Expand Up @@ -328,7 +328,7 @@ def typecheck(self) -> None:
self.arrayify()
for attr in [a for a in self._attrlist if hasattr(self, a)]:
val = getattr(self, attr)
if type(val) == self._attributes[attr].type:
if type(val) is self._attributes[attr].type:
continue

try:
Expand Down
2 changes: 1 addition & 1 deletion cclib/parser/gaussianparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ def extract(self, inputfile, line):
f"{self.YEAR_SUFFIXES_TO_YEARS[year_suffix]}+{revision}"
)
self.metadata["platform"] = groupdict["platform"]
run_date = next(inputfile).strip()
run_date = next(inputfile).strip() # noqa: F841

if line.strip().startswith("Link1: Proceeding to internal job step number"):
self.new_internal_job()
Expand Down

0 comments on commit 7034dec

Please sign in to comment.