-
Notifications
You must be signed in to change notification settings - Fork 12
Clamp amplitude #38
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
Clamp amplitude #38
Conversation
hexane360
left a comment
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.
A small change for clarity, also remove redundant imports
|
|
||
| @partial(jit, donate_argnames=('obj',), cupy_fuse=True) | ||
| def clamp_amplitude(obj: NDArray[numpy.complexfloating], amplitude: t.Union[float, numpy.floating]) -> NDArray[numpy.complexfloating]: | ||
| def clamp_amplitude(obj: NDArray[numpy.complexfloating], amplitude: t.Union[float, numpy.floating, t.List[float]]) -> NDArray[numpy.complexfloating]: |
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.
Cleaner to take min and max as optional parameters.
Then the implementation can be something like:
new_amp = obj_amp
if min is not None and max is not None:
new_amp = xp.clip(new_amp, min_amp, max_amp) # faster than doing sequentially
elif min is not None:
new_amp = xp.maximum(new_amp, min_amp)
elif max is not None:
new_amp = xp.minimum(new_amp, max_amp)
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.
You can split into min and max in the constructor of ClampObjectAmplitude
Co-authored-by: Colin Gilgenbach <colin@gilgenbach.net>
Co-authored-by: Colin Gilgenbach <colin@gilgenbach.net>
Co-authored-by: Colin Gilgenbach <colin@gilgenbach.net>
|
Did my previous comments make sense? I re-requested the same changes to the code |
|
Yes I thought I had changed them according to what you suggested? Did they not go through? |
|
Specifically this: #38 (comment) |
|
None of those changes seem to have to do with ClampObjectAmplitude, and you haven't split the function parameters, did you understand what I was asking? |
can accept either a list [lower_bound, upper_bound] or a single value which is the upper bound Merges pull request #38


Adding lower bound to clamp amplitude -- can accept either a list [lower_bound, upper_bound] or a single value which is the upper bound