Skip to content

Conversation

@brdenzer
Copy link

@brdenzer brdenzer commented Nov 1, 2025

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

Copy link
Owner

@hexane360 hexane360 left a 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]:
Copy link
Owner

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)

Copy link
Owner

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

brdenzer and others added 5 commits November 8, 2025 15:09
Co-authored-by: Colin Gilgenbach <colin@gilgenbach.net>
Co-authored-by: Colin Gilgenbach <colin@gilgenbach.net>
Co-authored-by: Colin Gilgenbach <colin@gilgenbach.net>
@hexane360
Copy link
Owner

Did my previous comments make sense? I re-requested the same changes to the code

@brdenzer
Copy link
Author

brdenzer commented Nov 9, 2025

Yes I thought I had changed them according to what you suggested? Did they not go through?

@hexane360
Copy link
Owner

hexane360 commented Nov 11, 2025

Specifically this: #38 (comment)

@brdenzer
Copy link
Author

I thought I did (see change and git push).
Screenshot 2025-11-11 at 1 25 06 PM
Screenshot 2025-11-11 at 1 25 54 PM

@hexane360
Copy link
Owner

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?

hexane360 pushed a commit that referenced this pull request Nov 12, 2025
can accept either a list [lower_bound, upper_bound] or a single value which is the upper bound

Merges pull request #38
@hexane360 hexane360 closed this Nov 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants