Skip to content

Commit

Permalink
Updated pylint; fixed the errors (#105)
Browse files Browse the repository at this point in the history
  • Loading branch information
pgkirsch committed Aug 23, 2021
1 parent f76899f commit 0fb6b6f
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
7 changes: 4 additions & 3 deletions gpfit/classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,13 +156,14 @@ def plot_slices(self):

def save(self, filename="fit.pkl"):
"""Save Fit object to pickle"""
pickle.dump(self, open(filename, "wb"))
with open(filename, "wb") as f:
pickle.dump(self, f)

def savetxt(self, filename="fit.txt"):
"""Save string of fit to text file using python math convention (**)"""
fitstr = self.__repr__().replace("^", "**")
with open(filename, "w") as f:
f.write(fitstr)
with open(filename, "w", encoding="utf-8") as textfile:
textfile.write(fitstr)

def constraint_set(self, **kwargs):
"""Returns constraint set"""
Expand Down
Binary file modified gpfit/tests/artifacts/fit.pkl
Binary file not shown.
7 changes: 4 additions & 3 deletions gpfit/tests/t_fit.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ def test_save_and_load(self):
f1 = ImplicitSoftmaxAffine(self.x, self.y, self.K)
f1.save("artifacts/fit.pkl")
strings1 = f1.__repr__()
f2 = pickle.load(open("artifacts/fit.pkl", "rb"))
with open("artifacts/fit.pkl", "rb") as picklefile:
f2 = pickle.load(picklefile)
self.assertTrue(f2.errors["rms_rel"] < 1e-5)
strings2 = f2.__repr__()
self.assertEqual(strings1, strings2)
Expand All @@ -98,8 +99,8 @@ def test_savetxt(self):
np.random.seed(SEED)
f = ImplicitSoftmaxAffine(self.x, self.y, self.K)
f.savetxt("artifacts/fit.txt")
with open("artifacts/fit.txt", "r") as f:
fitstring = f.read()
with open("artifacts/fit.txt", "r", encoding="utf-8") as textfile:
fitstring = textfile.read()
self.assertEqual(fitstring, (
"1 = (0.947385/w**0.0920329)*(u_1)**0.0176859\n"
" + (0.992721/w**0.349639)*(u_1)**-0.201861\n"
Expand Down
2 changes: 1 addition & 1 deletion gpfit/xfoil/wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@


# pylint: disable=invalid-name, bare-except, too-many-locals
# pylint: disable=too-many-arguments
# pylint: disable=too-many-arguments, consider-using-with


def xfoil_comparison(airfoil, Cl, Re, Cd):
Expand Down

0 comments on commit 0fb6b6f

Please sign in to comment.