Skip to content
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

Signal __eq__ should provide a control for 'close enough' #931

Open
JGoldstone opened this issue Jan 30, 2022 · 0 comments
Open

Signal __eq__ should provide a control for 'close enough' #931

JGoldstone opened this issue Jan 30, 2022 · 0 comments

Comments

@JGoldstone
Copy link
Contributor

Say you make an out of the DATA_SAMPLE in test_spectrum.py. Make a copy of it, a deep copy if you like. Call the first one s0 and the second s1. == will return True. Now get a value x with x=s0[500]. Turn right around and replace it with itself with s0[500] = x. Now == between s0 and s1 will return False. This is because somewhere in there we introduced a roughly 5e-17 difference into the original and the restored values of s0[500].

If there were a property of Signal that was a tolerance, then instead of calling np.array_equal for the range and domain, it could call np.allclose with that tolerance. The tolerance defaults to exactly 0.0, so if you don't set the tolerance to something else, the behavior is compatible with today's behavior. (It bears investigation as to whether np.allclose is significantly slower than np.array_equal when the tolerance is 0.0)

Ideally the tolerance value could be set in some sort of with block, with automatic cleanup so you don't need to remember to restore the prior value. But I'm not an experienced-enough designer to suggest a code example for that.

@KelSolaar KelSolaar added this to the v0.4.0 milestone Jan 30, 2022
@KelSolaar KelSolaar modified the milestones: v0.4.0, v0.4.1, v0.4.2 Feb 19, 2022
@KelSolaar KelSolaar modified the milestones: v0.4.2, v0.4.3 Nov 27, 2022
@KelSolaar KelSolaar modified the milestones: v0.4.3, v0.4.4 Aug 25, 2023
@KelSolaar KelSolaar modified the milestones: v0.4.4, v0.4.5 Dec 19, 2023
@KelSolaar KelSolaar modified the milestones: v0.4.5, v0.4.6, v0.4.7 Oct 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants