-
Notifications
You must be signed in to change notification settings - Fork 22
Address flake8 error lambda functions (E731) #78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
bobleesj marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -92,7 +92,7 @@ def __call__(self, r): | |
self._invertor.y = iq | ||
self._invertor.err = diq | ||
c, c_cov = self._invertor.invert_optimize() | ||
calculate_pr = lambda x: self._invertor.pr(c, x) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think using lambda functions that are short and concise actually increase readability... Hence adding |
||
calculate_pr = lambda x: self._invertor.pr(c, x) # noqa: E731 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This one also better to put it in the map directly? Or maybe as an explicit function |
||
pr = map(calculate_pr, r) | ||
|
||
pr = numpy.array(pr) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -157,7 +157,7 @@ def testParseEquation(self): | |
eq.x.setValue(x) | ||
eq.B.setValue(B) | ||
eq.C.setValue(C) | ||
f = lambda A, x, B, C: A * sin(0.5 * x) + divide(B, C) | ||
f = lambda A, x, B, C: A * sin(0.5 * x) + divide(B, C) # noqa: E731 | ||
self.assertTrue(array_equal(eq(), f(A, x, B, C))) | ||
|
||
# Make sure that the arguments of eq are listed in the order in which | ||
|
@@ -170,7 +170,7 @@ def testParseEquation(self): | |
sigma = 0.1 | ||
eq.x.setValue(x) | ||
eq.sigma.setValue(sigma) | ||
f = lambda x, sigma: sqrt(e ** (-0.5 * (x / sigma) ** 2)) | ||
f = lambda x, sigma: sqrt(e ** (-0.5 * (x / sigma) ** 2)) # noqa: E731 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here in the tests they are quite readable and not doing much harm so I suggest leaving with noqa |
||
self.assertTrue(numpy.allclose(eq(), f(x, sigma))) | ||
|
||
self.assertEqual(eq.args, [eq.x, eq.sigma]) | ||
|
@@ -246,7 +246,7 @@ def _f(a, b): | |
sigma = builder.ArgumentBuilder(name="sigma", value=0.1) | ||
beq = sqrt(e ** (-0.5 * (x / sigma) ** 2)) | ||
eq = beq.getEquation() | ||
f = lambda x, sigma: sqrt(e ** (-0.5 * (x / sigma) ** 2)) | ||
f = lambda x, sigma: sqrt(e ** (-0.5 * (x / sigma) ** 2)) # noqa: E731 | ||
self.assertTrue(numpy.allclose(eq(), numpy.sqrt(e ** (-0.5 * (_x / 0.1) ** 2)))) | ||
|
||
# Equation with Equation | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't find this very readable. We can't do better here?