Skip to content

Commit

Permalink
removed integrate completely
Browse files Browse the repository at this point in the history
  • Loading branch information
nuniz committed Jul 13, 2024
1 parent 6195ce1 commit b8429e5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 17 deletions.
14 changes: 2 additions & 12 deletions cd_network/coincidence_integral.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from typing import Callable

import numpy as np
from scipy import integrate, signal
from scipy import signal

from .utils import hashable_input

Expand Down Expand Up @@ -66,17 +66,7 @@ def coincidence_integral(
if method in filter_methods:
return filter_methods[method](x)

num_inputs, num_samples = x.shape
output = np.zeros((num_inputs, num_samples))

for i in range(num_inputs):
if method == "cumtrapz":
output[i, :] = integrate.cumtrapz(y=x[i, :], dx=dt, initial=0)
output[i, samples_integral:] -= output[i, :-samples_integral]
else:
raise ValueError(f'method {method} is not supported.')

return output
raise ValueError(f'method {method} is not supported.')


@lru_cache(maxsize=None)
Expand Down
6 changes: 1 addition & 5 deletions tests/test_cd_integral.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,8 @@ def test_coincidence_integral(self):
x = np.random.randn(3, 100)
integration_duration = 1
fs = 5 # sample frequency
methods = ["filtfilt", "lfilter", "cumtrapz", "trapz", "simps", "romb"]
methods = ["filtfilt", "lfilter"]
for method in methods:
if (
method in ["romb"] and x.shape[1] % 2 == 0
): # Romb requires 2^n + 1 samples
continue
result = coincidence_integral(x, integration_duration, fs, method)
self.assertEqual(result.shape, x.shape)

Expand Down

0 comments on commit b8429e5

Please sign in to comment.