You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thanks @NiekWielders! Before merging I wanted to double-check one specific concern that's bitten us in this area before: the threshold value flowing into min(threshold, maximum_threshold) can be either a numpy scalar or a JAX 0-d array depending on whether the Analysis was constructed with use_jax=True or use_jax=False, and Python's min() can behave differently on the two.
I traced and tested it:
threshold is produced by positions_threshold_from via factor * np.nanmax(positions_fits.max_separation_of_plane_positions). np.nanmax always returns a numpy scalar even when given a concrete JAX array, so threshold arrives here as a numpy scalar (or a Python float in the minimum_threshold early-return branch) regardless of the backend.
I empirically tested min(threshold, maximum_threshold) against numpy scalar, numpy 0-d array, JAX 0-d array (fp32 and fp64), and Python float — all combinations work and return a usable numeric value.
positions_likelihood_from is only called on a Result after the fit completes (i.e. outside any jax.jit boundary), so JAX tracer concretization isn't a concern.
Conclusion: the code is safe for both use_jax=True and use_jax=False. Merging as-is.
Minor style nit (not blocking, just for future reference): the existing minimum_threshold clamp lives inside positions_threshold_from using an if threshold < minimum_threshold: return minimum_threshold pattern, while this PR adds the symmetric maximum_threshold clamp inside positions_likelihood_from using min(). Asymmetric placement but functionally equivalent — happy to leave as-is.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
added a maximum threshold to the positions_likelihood_from
Changes
only positions_likelihood_from
Testing
no extra tests added
Related Issues