Skip to content

Commit b8e0832

Browse files
committed
fix array conversion
1 parent 569db62 commit b8e0832

File tree

3 files changed

+14
-13
lines changed

3 files changed

+14
-13
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "wslfp"
3-
version = "0.2.0"
3+
version = "0.2.1"
44
description = "Weighted Sum Local Field Potentials - Implementation of the proxy method for point neurons from Mazzoni, Lindén et al., 2015"
55
authors = [
66
"Kyle Johnsen <kyle@kjohnsen.org>",

tests/test_wslfp.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,26 +19,27 @@
1919
# length of time and current array must equal
2020
([1, 2, 4], [1, 2, 10], [9], True),
2121
# missing I_gaba at t=9
22-
([1, 2, 10], [1, 2, 4], [9], False),
22+
([1, 2, 10], [1, 2, 4], 9, False),
2323
([3, 2, 1], [3, 2, 1], [2], False), # Non-increasing order, should fail
2424
([], [], [], False), # Empty arrays, should fail
2525
([1, 5, 9, 12, 17], [1, 3, 5, 9, 12], [8, 11], True),
2626
([1, 5, 9, 12, 17], [1, 3, 5, 9, 12], [], False),
2727
([2, 4, 6, 23, 25], [7, 10, 15, 21, 25], [12, 20, 24], True),
2828
([2, 3, 4, 5, 6], [50, 60, 70, 80, 90], [70, 100], False),
2929
([0], [6], [6], True),
30-
([6], [6], [6], False),
31-
([6], [0], [6], False),
30+
(0, 6, 6, True),
31+
([6], 6, [6], False),
32+
(6, [0], [6], False),
3233
],
3334
)
3435
def test_calculate(t_ampa, t_gaba, t_eval, success, n_elec, seed):
3536
rng = np.random.default_rng(seed)
3637
# Dummy data for currents and coordinates
3738
n_src = 3
3839
n_elec = 2
39-
I_ampa = np.arange(len(t_ampa))
40+
I_ampa = np.arange(np.size(t_ampa))
4041
I_ampa = I_ampa[:, np.newaxis] + np.arange(n_src)
41-
I_gaba = -np.arange(len(t_gaba)) - 2
42+
I_gaba = -np.arange(np.size(t_gaba)) - 2
4243
I_gaba = I_gaba[:, np.newaxis] - np.arange(n_src)
4344

4445
source_coords = rng.uniform(-10, 10, (n_src, 3))
@@ -47,7 +48,7 @@ def test_calculate(t_ampa, t_gaba, t_eval, success, n_elec, seed):
4748
calc = wslfp.from_xyz_coords(elec_coords, source_coords, strict_boundaries=True)
4849
if success:
4950
lfp_values = calc.calculate(t_eval, t_ampa, I_ampa, t_gaba, I_gaba)
50-
assert lfp_values.shape == (len(t_eval), n_elec)
51+
assert lfp_values.shape == (np.size(t_eval), n_elec)
5152
# increasing could be negative or positive
5253
# can't use np.abs since normalization can put values on either side of 0
5354
assert np.all(

wslfp/__init__.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -144,12 +144,12 @@ def calculate(
144144
each electrode
145145
"""
146146
# convert t to arrays if needed
147-
if isinstance(t_eval_ms, (list, tuple, int, float)):
148-
t_eval_ms = np.array(t_eval_ms)
149-
if isinstance(t_ampa_ms, (list, tuple, int, float)):
150-
t_ampa_ms = np.array(t_ampa_ms)
151-
if isinstance(t_gaba_ms, (list, tuple, int, float)):
152-
t_gaba_ms = np.array(t_gaba_ms)
147+
if isinstance(t_eval_ms, (int, float)):
148+
t_eval_ms = np.array([t_eval_ms])
149+
if isinstance(t_ampa_ms, (int, float)):
150+
t_ampa_ms = np.array([t_ampa_ms])
151+
if isinstance(t_gaba_ms, (int, float)):
152+
t_gaba_ms = np.array([t_gaba_ms])
153153

154154
I_ampa = np.reshape(I_ampa, (-1, self.n_sources))
155155
assert I_ampa.shape == (

0 commit comments

Comments
 (0)