Skip to content

Commit 5f417b2

Browse files
committed
Fixing tests
1 parent c4119b5 commit 5f417b2

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

pynapple/process/tuning_curves.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# @Author: gviejo
55
# @Date: 2022-01-02 23:33:42
66
# @Last Modified by: Guillaume Viejo
7-
# @Last Modified time: 2024-01-26 15:12:33
7+
# @Last Modified time: 2024-01-26 15:28:51
88

99
import warnings
1010

@@ -58,7 +58,7 @@ def compute_discrete_tuning_curves(group, dict_ep):
5858
for k in idx:
5959
assert isinstance(
6060
dict_ep[k], nap.IntervalSet
61-
), "dict_ep argument should contain only IntervalSet. \n Key {} in dict_ep is not an IntervalSet".format(
61+
), "dict_ep argument should contain only IntervalSet. Key {} in dict_ep is not an IntervalSet".format(
6262
k
6363
)
6464

@@ -112,7 +112,11 @@ def compute_1d_tuning_curves(group, feature, nb_bins, ep=None, minmax=None):
112112
feature.shape[1] == 1
113113
), "feature should be a Tsd (or TsdFrame with 1 column only)"
114114
assert isinstance(nb_bins, int)
115-
assert isinstance(ep, nap.IntervalSet), "ep should be an IntervalSet"
115+
116+
if ep is None:
117+
ep = feature.time_support
118+
else:
119+
assert isinstance(ep, nap.IntervalSet), "ep should be an IntervalSet"
116120

117121
if minmax is None:
118122
bins = np.linspace(np.min(feature), np.max(feature), nb_bins + 1)

tests/test_tuning_curves.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# @Author: gviejo
33
# @Date: 2022-03-30 11:16:30
44
# @Last Modified by: Guillaume Viejo
5-
# @Last Modified time: 2024-01-26 15:09:42
5+
# @Last Modified time: 2024-01-26 15:23:20
66

77
"""Tests of tuning curves for `pynapple` package."""
88

@@ -36,7 +36,7 @@ def test_compute_discrete_tuning_curves_with_strings():
3636
def test_compute_discrete_tuning_curves_error():
3737
dict_ep = { "0":nap.IntervalSet(start=0, end=50),
3838
"1":nap.IntervalSet(start=50, end=100)}
39-
with pytest.raises(RuntimeError) as e_info:
39+
with pytest.raises(AssertionError) as e_info:
4040
nap.compute_discrete_tuning_curves([1,2,3], dict_ep)
4141
assert str(e_info.value) == "group should be a TsGroup."
4242

@@ -45,9 +45,9 @@ def test_compute_discrete_tuning_curves_error():
4545
"1":nap.IntervalSet(start=50, end=100)}
4646
k = [1,2,3]
4747
dict_ep["2"] = k
48-
with pytest.raises(RuntimeError) as e_info:
48+
with pytest.raises(AssertionError) as e_info:
4949
nap.compute_discrete_tuning_curves(tsgroup, dict_ep)
50-
assert str(e_info.value) == "dict_ep argument should contain only IntervalSet. \n Key 2 in dict_ep is not an IntervalSet"
50+
assert str(e_info.value) == "dict_ep argument should contain only IntervalSet. Key 2 in dict_ep is not an IntervalSet"
5151

5252
def test_compute_1d_tuning_curves():
5353
tsgroup = nap.TsGroup({0: nap.Ts(t=np.arange(0, 100))})
@@ -61,7 +61,7 @@ def test_compute_1d_tuning_curves():
6161

6262
def test_compute_1d_tuning_curves_error():
6363
feature = nap.Tsd(t=np.arange(0, 100, 0.1), d=np.arange(0, 100, 0.1) % 1.0)
64-
with pytest.raises(RuntimeError) as e_info:
64+
with pytest.raises(AssertionError) as e_info:
6565
nap.compute_1d_tuning_curves([1,2,3], feature, nb_bins=10)
6666
assert str(e_info.value) == "group should be a TsGroup."
6767

@@ -110,15 +110,15 @@ def test_compute_2d_tuning_curves_error():
110110
(np.repeat(np.arange(0, 100), 10), np.tile(np.arange(0, 100), 10))
111111
).T
112112
features = nap.TsdFrame(t=np.arange(0, 200, 0.1), d=np.vstack((tmp, tmp[::-1])))
113-
with pytest.raises(RuntimeError) as e_info:
113+
with pytest.raises(AssertionError) as e_info:
114114
nap.compute_2d_tuning_curves([1,2,3], features, 10)
115115
assert str(e_info.value) == "group should be a TsGroup."
116116

117117
tsgroup = nap.TsGroup(
118118
{0: nap.Ts(t=np.arange(0, 100, 10)), 1: nap.Ts(t=np.array([50, 149]))}
119119
)
120120
features = nap.TsdFrame(t=np.arange(100), d=np.random.rand(100, 3))
121-
with pytest.raises(RuntimeError) as e_info:
121+
with pytest.raises(AssertionError) as e_info:
122122
nap.compute_2d_tuning_curves(tsgroup, features, 10)
123123
assert str(e_info.value) == "feature should have 2 columns only."
124124

0 commit comments

Comments
 (0)