Skip to content
Merged
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
6 changes: 4 additions & 2 deletions psignifit/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,11 @@ def pool_blocks(data: np.ndarray, max_tol=0, max_gap=np.inf, max_length=np.inf):
block = []
gap = 0
for j in range(i, ndata):
if (cum_ntrials[j + 1] -
cum_ntrials[i]) > max_length or gap > max_gap:
# j > i condition: make sure there is at least one data point per block
if ((cum_ntrials[j + 1] - cum_ntrials[i]) > max_length
or gap > max_gap) and j > i:
break

level, ncorrect, ntrials = data[j, :]
if abs(level - current) <= max_tol and not seen[j]:
seen[j] = True
Expand Down
17 changes: 17 additions & 0 deletions tests/test_pooling.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,23 @@ def test_pooling_big_max_gap():
assert np.allclose(exp, act, rtol=0, atol=1e-04)


def test_pooling_243():
# Reproduces issue #243

data = np.array([
[100, 50, 50],
[101, 51, 51],
[200, 60, 60],
[201, 61, 61],
[300, 70, 70],
[301, 71, 71],
[400, 80, 80]
])

pooled = pool_blocks(data, max_tol=50, max_gap=50, max_length=10)
assert np.allclose(pooled, data)


data = np.array([
[1.3262, 1, 1],
[0.8534, 1, 1],
Expand Down