-
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
Conversation
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.
Please review @sbillinge
@@ -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 comment
The 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 # noqa: E731
as well.
This is the last PR for flake8. We shall implement CI/pre-commit very soon. |
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.
Please see comments. I am not a fan of lots of lambdas. I like them for sort keys and things like that where they are much more readable having the logic in place (not assigned) but elsewhere I think they rarely make things clearer than clearly written code with explicit functions and well chosen function names
@@ -661,7 +661,7 @@ def __wrapSrFitOperators(): | |||
opmod = literals.operators | |||
excluded_types = set((opmod.CustomOperator, opmod.UFuncOperator)) | |||
# check if opmod member should be wrapped as OperatorBuilder | |||
is_exported_type = lambda cls: ( | |||
is_exported_type = lambda cls: ( # noqa: E731 |
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?
@@ -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) | |||
calculate_pr = lambda x: self._invertor.pr(c, x) # noqa: E731 |
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.
This one also better to put it in the map directly? Or maybe as an explicit function
@@ -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 comment
The 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
Noted. I will address these later in the afternoon. |
@sbillinge I will close this PR and make separate PRs address each file or so. I will refer back to your in-line comments. |
Tests pass: