-
Notifications
You must be signed in to change notification settings - Fork 7
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
Avoid lambda flake8 error with private function #56
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.
I nervous that this is not the right design here. this function seems to be doing a very shallow wrap of np.interpolate. Can't we just call np.interpolate?
Why don't you think about it for a sec and propose something cleaner?
diffpy/snmf/containers.py
Outdated
@@ -25,6 +25,23 @@ def __init__(self, grid, number_of_signals, id_number, perturbation=1e-3): | |||
self.stretching_factors = np.ones(number_of_signals) + np.random.randn(number_of_signals) * perturbation | |||
self.id = int(id_number) | |||
|
|||
def _interpolate_stretching_factor(self, stretching_factor): | |||
"""Interpolates the intensity values over a normalized grid scaled by a given stretching factor. |
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.
Private functions don't need docstrings
The original First, the derivative of
Second, the expression is simply computed:
Due to the first usage, it is required that we express the To me personally, I would have maintined the lambda expression as it was originally. To avoid the flake8 error, I would use I am aware using this specific tag to avoid errors should be used as the last resort and it may not be the best practice (in most cases). However, we do not want to have a private function or nested function block either since it's a very simple function. How is my thought? @sbillinge |
Thanks Bob, great analysis. It is not a huge deal here, so I would probably go with the lambda as you recommend. I might take the opportunity to make the code more readable and call it something other than "func" which is not very descriptive. |
Requesting a pull request:
|
nicely done ! |
As provided in the previous comment: #54 (comment)
I created a private function called
_interpolate_stretching_factor
in theComponentSignal
class since the function has been used more than once. Thank you for the feedback.Please confirm my function description.