Skip to content

fix: handle phi wraparound in rhophi isclose - #763

Open
abhishekcpp007 wants to merge 1 commit into
scikit-hep:mainfrom
abhishekcpp007:fix/isclose-phi-wraparound
Open

abhishekcpp007 wants to merge 1 commit into
scikit-hep:mainfrom
abhishekcpp007:fix/isclose-phi-wraparound

Conversation

@abhishekcpp007

Copy link
Copy Markdown

When both vectors are rho-phi, isclose compares phi directly, so two vectors on either side of the ±pi seam aren't close. The mixed xy/rhophi paths go through x and y, so they get it right:

a = vector.obj(rho=1.0, phi=math.pi - 1e-10)
b = a.rotateZ(2e-10)  # phi is now -pi + 1e-10
a.isclose(b)          # False
a.to_xy().isclose(b)  # True

The same happens for rhophi-z, rhophi-theta and rhophi-eta, and through them for 4D. Each one now compares phi1 with phi2 shifted next to it using deltaphi.rhophi_rhophi, so rtol still applies as before.

Added test_phi_wraparound, which checks the 2D case and every 3D pair of coordinate systems.

This branch has not been deployed

No deployments
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.

1 participant