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

Enh/benchmarks #100

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jobs:
strategy:
matrix:
# python versions for elephant: [3.8, 3.9, "3.10", 3.11]
python-version: [3.8, 3.9, "3.10", 3.11]
python-version: [3.11]
# OS [ubuntu-latest, macos-latest, windows-latest]
os: [ubuntu-latest]
# do not cancel all in-progress jobs if any matrix job fails
Expand Down
34 changes: 34 additions & 0 deletions elephant/test/test_spike_train_surrogates.py
Original file line number Diff line number Diff line change
Expand Up @@ -702,3 +702,37 @@ def test_trial_shuffling_empty_train_concatenated(self):

if __name__ == "__main__":
unittest.main(verbosity=2)

"""
BENCHMARKS

"""


def benchmark_surrogates():
"""
Function that needs some serious benchmarking.
"""
st = neo.SpikeTrain([90, 150, 180, 350] * pq.ms, t_stop=500 * pq.ms)

n_surrogates = 2
dither = 10 * pq.ms
np.random.seed(42)
surrogate_trains = surr.dither_spikes(
st, dither=dither, decimals=3, n_surrogates=n_surrogates)

np.random.seed(42)
dither_values = np.random.random_sample((n_surrogates, len(st)))
expected_non_dithered = np.sum(dither_values == 0)

observed_non_dithered = 0
for surrogate_train in surrogate_trains:
for i in range(len(surrogate_train)):
if surrogate_train[i] - int(surrogate_train[i]) * \
pq.ms == surrogate_train[i] - surrogate_train[i]:
observed_non_dithered += 1


def test_benchmark_surrogates(benchmark):
# benchmark surrogates
benchmark(benchmark_surrogates)