Skip to content

Commit c46f6b3

Browse files
authored
Merge pull request #1758 from AllenInstitute/rc/2.3.2
Issue #1755
2 parents 18f49c7 + acc0738 commit c46f6b3

File tree

5 files changed

+56
-4
lines changed

5 files changed

+56
-4
lines changed

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
# Change Log
22
All notable changes to this project will be documented in this file.
33

4+
## [2.3.2] = 2020-10-19
5+
6+
### Bug Fixes
7+
- (Internal) Fixed a running\_processing bug for behavior ophys experiments when the input data would have one more encoder entry than timestamp. The behavior of the code now matches what the warning says.
8+
49
## [2.3.1] = 2020-10-13
510

611
### Bug Fixes
7-
- (Internal) Fixed a write_nwb bug for behavior ophys experiments involving the BehaviorOphysJsonApi expecting a mesoscope-specific method.
12+
- (Internal) Fixed a write\_nwb bug for behavior ophys experiments involving the BehaviorOphysJsonApi expecting a mesoscope-specific method.
813

914
## [2.3.0] = 2020-10-09
1015

allensdk/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737

3838

3939

40-
__version__ = '2.3.1'
40+
__version__ = '2.3.2'
4141

4242

4343
try:

allensdk/brain_observatory/behavior/running_processing.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def _shift(
5555
Iterable containing numeric data. If int, will be converted to
5656
float in returned object.
5757
periods: int (default=1)
58-
The number of elements to shift.
58+
The number of elements to shift.
5959
fill_value: float (default=np.nan)
6060
The value to fill at the beginning of the shifted array
6161
Returns
@@ -364,7 +364,9 @@ def get_running_df(data, time: np.ndarray, lowpass: bool = True):
364364
if len(v_in) == len(time) + 1:
365365
warnings.warn(
366366
"Time array is 1 value shorter than encoder array. Last encoder "
367-
"value removed\n", stacklevel=1)
367+
"value removed\n", UserWarning, stacklevel=1)
368+
v_in = v_in[:-1]
369+
v_sig = v_sig[:-1]
368370

369371
# dx = 'd_theta' = angular change
370372
# There are some issues with angular change in the raw data so we

allensdk/test/brain_observatory/behavior/test_running_processing.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,43 @@ def test_get_running_df(running_data, timestamps, lowpass):
7171
assert np.count_nonzero(np.isnan(actual["speed"])) == 0
7272

7373

74+
@pytest.mark.parametrize(
75+
"lowpass", [True, False]
76+
)
77+
def test_get_running_df_one_fewer_timestamp_check_warning(running_data,
78+
timestamps,
79+
lowpass):
80+
with pytest.warns(
81+
UserWarning,
82+
match="Time array is 1 value shorter than encoder array.*"
83+
):
84+
# Call with one fewer timestamp, check for a warning
85+
_ = get_running_df(
86+
data=running_data,
87+
time=timestamps[:-1],
88+
lowpass=lowpass
89+
)
90+
91+
92+
@pytest.mark.parametrize(
93+
"lowpass", [True, False]
94+
)
95+
def test_get_running_df_one_fewer_timestamp_check_truncation(running_data,
96+
timestamps,
97+
lowpass):
98+
# Call with one fewer timestamp
99+
output = get_running_df(
100+
data=running_data,
101+
time=timestamps[:-1],
102+
lowpass=lowpass
103+
)
104+
105+
# Check that the output is actually trimmed, and the values are the same
106+
assert len(output) == len(timestamps) - 1
107+
np.testing.assert_equal(output["v_sig"], running_data["items"]["behavior"]["encoders"][0]["vsig"][:-1])
108+
np.testing.assert_equal(output["v_in"], running_data["items"]["behavior"]["encoders"][0]["vin"][:-1])
109+
110+
74111
@pytest.mark.parametrize(
75112
"arr, periods, fill, expected",
76113
[

doc_template/index.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,20 @@ The Allen SDK provides Python code for accessing experimental metadata along wit
9191
See the `mouse connectivity section <connectivity.html>`_ for more details.
9292

9393

94+
What's New - 2.3.2 (October 19, 2020)
95+
-----------------------------------------------------------------------
96+
As of the 2.3.2 release:
97+
98+
- (Internal) Fixed a running_processing bug for behavior ophys experiments when the input data would have one more encoder entry than timestamp. The behavior of the code now matches what the warning says.
99+
100+
94101
What's New - 2.3.1 (October 13, 2020)
95102
-----------------------------------------------------------------------
96103
As of the 2.3.1 release:
97104

98105
- (Internal) Fixed a write_nwb bug for behavior ophys experiments involving the BehaviorOphysJsonApi expecting a mesoscope-specific method.
99106

107+
100108
What's New - 2.3.0 (October 9, 2020)
101109
-----------------------------------------------------------------------
102110
As of the 2.3.0 release:

0 commit comments

Comments
 (0)