Skip to content

Avoid lambda flake8 error with private function #56

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

Merged
merged 4 commits into from
Aug 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 8 additions & 13 deletions diffpy/snmf/containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class ComponentSignal:
----------
grid: 1d array of floats
The vector containing the grid points of the component.

iq: 1d array of floats
The intensity/g(r) values of the component.
weights: 1d array of floats
The vector containing the weight of the component signal for each signal.
Expand Down Expand Up @@ -36,22 +36,17 @@ def apply_stretch(self, m):
Returns
-------
tuple of 1d arrays
The tuple of vectors where one vector is the stretched component, one vector is the 1st derivative
of the stretching operation, and one vector is the second derivative of the stretching operation.
The tuple of vectors where one vector is the stretched component, one vector is the 1st derivative of the
stretching operation, and one vector is the second derivative of the stretching operation.
"""
normalized_grid = np.arange(len(self.grid))
# func = lambda stretching_factor: np.interp(
# normalized_grid / stretching_factor, normalized_grid, self.iq, left=0, right=0
# )

# E731 do not assign a lambda expression, use a def
def func(stretching_factor):
return np.interp(normalized_grid / stretching_factor, normalized_grid, self.iq, left=0, right=0)

derivative_func = numdifftools.Derivative(func)
interpolate_intensity = lambda stretching_factor: np.interp( # noqa: E731
normalized_grid / stretching_factor, normalized_grid, self.iq, left=0, right=0
)
derivative_func = numdifftools.Derivative(interpolate_intensity)
second_derivative_func = numdifftools.Derivative(derivative_func)

stretched_component = func(self.stretching_factors[m])
stretched_component = interpolate_intensity(self.stretching_factors[m])
stretched_component_gra = derivative_func(self.stretching_factors[m])
stretched_component_hess = second_derivative_func(self.stretching_factors[m])

Expand Down
Loading