Skip to content

Pin down z-scale normalized to integer (!) failure by separating the tests - #1971

Merged
alejoe91 merged 3 commits into
SpikeInterface:mainfrom
h-mayorquin:separate_scaling_test
Sep 11, 2023
Merged

alejoe91 merged 3 commits into
SpikeInterface:mainfrom
h-mayorquin:separate_scaling_test

Conversation

@h-mayorquin

Copy link
Copy Markdown
Contributor

I have this tests failing in #1970 which I have seen failing before. It is not failing in my computer so I want to separate it in its own test to hopefully isolate the failure.

@h-mayorquin h-mayorquin added the testing Related to test routines label Sep 6, 2023
@h-mayorquin

Copy link
Copy Markdown
Contributor Author

OK, I pined down an example of failure.

from spikeinterface.preprocessing import normalize_by_quantile, scale, center, zscore
from spikeinterface.core import generate_recording

seed = 1
rec = generate_recording(seed=seed, mode="lazy")
rec_int = scale(rec, dtype="int16", gain=100)

zscore_recording = zscore(rec_int, dtype="int16", int_scale=256, mode="mean+std", seed=seed)
traces = zscore_recording.get_traces(segment_index=0)
trace_mean = np.mean(traces, axis=0)
trace_std = np.std(traces, axis=0)
assert np.all(np.abs(trace_mean) < 1)
assert np.all(np.abs(trace_std - 256) < 1)

I am confused about this:

#1437

@h-mayorquin

Copy link
Copy Markdown
Contributor Author

OK, restoring this to legacy. I think this fails because of a mathematical program / lack of continuity correction. I opened a bug for this #1972

We should merge this so we can work on other stuff without getting bothered by the CI:

stds = np.std(random_data, axis=0)
stds = stds[None, :]
gain = 1 / stds
gain = 1.0 / stds

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch!

@samuelgarcia

Copy link
Copy Markdown
Member

assert np.all(np.abs(trace_std - 256) < 1) was too strong maybe 2% tolrance error with this
assert np.all(np.abs(trace_std - 256) < 5) should be better

@samuelgarcia

Copy link
Copy Markdown
Member

OK for me.
@alejoe91 do you want to check ?

@h-mayorquin

Copy link
Copy Markdown
Contributor Author

assert np.all(np.abs(trace_std - 256) < 1) was too strong maybe 2% tolrance error with this assert np.all(np.abs(trace_std - 256) < 5) should be better

In my simulations the std is fine, is the mean estimate that has a lot of variability.

@alejoe91
alejoe91 merged commit a26cb84 into SpikeInterface:main Sep 11, 2023
@h-mayorquin
h-mayorquin deleted the separate_scaling_test branch November 29, 2023 06:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

testing Related to test routines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants