Skip to content

Commit 201851b

Browse files
authored
Merge pull request #496 from int-brain-lab/hotfix/2.13.6
don't overwrite all settings if iblrig on untagged version
2 parents 359b7a9 + a00692d commit 201851b

25 files changed

+214
-202
lines changed

brainbox/behavior/training.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ def get_training_status(trials, task_protocol, ephys_sess_dates, n_delay):
227227
info.rt) = compute_bias_info(trials, trials_all)
228228
# We are still on training rig and so all sessions should be biased
229229
if len(ephys_sess_dates) == 0:
230-
assert(np.all(np.array(task_protocol) == 'biased'))
230+
assert np.all(np.array(task_protocol) == 'biased')
231231
if criterion_ephys(info.psych_20, info.psych_80, info.n_trials, info.perf_easy,
232232
info.rt):
233233
status = 'ready4ephysrig'

brainbox/plot_base.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def _set_lim(self, axis, lim=None):
109109
:return:
110110
"""
111111
if lim is not None:
112-
assert(len(lim) == 2)
112+
assert len(lim) == 2
113113
else:
114114
lim = (np.nanmin(self.data[axis]), np.nanmax(self.data[axis]))
115115
return lim
@@ -175,7 +175,7 @@ def set_scale(self, scale=None):
175175
"""
176176
# For pyqtgraph implementation
177177
if scale is not None:
178-
assert(len(scale) == 2)
178+
assert len(scale) == 2
179179
self.scale = self._set_default(scale, (self._get_scale('x'), self._get_scale('y')))
180180

181181
def _get_scale(self, axis):
@@ -203,7 +203,7 @@ def set_offset(self, offset=None):
203203
"""
204204
# For pyqtgraph implementation
205205
if offset is not None:
206-
assert(len(offset) == 2)
206+
assert len(offset) == 2
207207
self.offset = self._set_default(offset, (self._get_offset('x'), self._get_offset('y')))
208208

209209
def _get_offset(self, axis):
@@ -229,9 +229,9 @@ def __init__(self, img, x, y, cmap=None):
229229
"""
230230

231231
# Make sure we have inputs as lists, can get input from arrange_channels2banks
232-
assert(type(img) == list)
233-
assert(type(x) == list)
234-
assert(type(y) == list)
232+
assert type(img) == list
233+
assert type(x) == list
234+
assert type(y) == list
235235

236236
data = Bunch({'x': x, 'y': y, 'c': img})
237237
super().__init__('probe', data)
@@ -257,7 +257,7 @@ def _get_scale(self, idx, axis):
257257

258258
def _set_lim_list(self, axis, idx, lim=None):
259259
if lim is not None:
260-
assert(len(lim) == 2)
260+
assert len(lim) == 2
261261
else:
262262
lim = (np.nanmin(self.data[axis][idx]), np.nanmax(self.data[axis][idx]))
263263
return lim

brainbox/quality/lfp_qc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def _plot_rmsmap(outpath, typ, savefig=True):
107107
else:
108108
outpath = Path(sys.argv[1]) # grab from command line input
109109
fbin = glob.glob(os.path.join(outpath, '*.lf.bin'))
110-
assert(len(fbin) > 0)
110+
assert len(fbin) > 0
111111
print('fbin: %s' % fbin)
112112
# make sure you send a path for the time being and not a string
113113
ephysqc.extract_rmsmap(Path(fbin[0]))

brainbox/task/trials.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ def get_event_aligned_raster(times, events, tbin=0.02, values=None, epoch=[-0.4,
173173
if np.sum(out_intervals) > 0:
174174
event_raster = np.r_[event_raster, np.full((np.sum(out_intervals),
175175
event_raster.shape[1]), np.nan)]
176-
assert(event_raster.shape[0] == intervals.shape[0])
176+
assert event_raster.shape[0] == intervals.shape[0]
177177

178178
# Reindex if we have removed any nan values
179179
all_event_raster = np.full((events.shape[0], event_raster.shape[1]), np.nan)

brainbox/tests/test_behavior.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ def test_trained_1b(self):
181181
assert (np.all(np.array(task_protocol) == 'training'))
182182
status, info = train.get_training_status(trials, task_protocol, ephys_sess_dates=[],
183183
n_delay=0)
184-
assert(status == 'trained 1b')
184+
self.assertEqual(status, 'trained 1b')
185185

186186
def test_training_to_bias(self):
187187
trials, task_protocol = self._get_trials(

brainbox/tests/test_metrics.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def test_drift_estimate():
8080
t, a, c = multiple_spike_trains(firing_rates=frs, rec_len_secs=200)
8181
# test negative times, no drift
8282
drift, ts = electrode_drift.estimate_drift(t - 2, a, cells_depth[c])
83-
assert(np.all(np.abs(drift) < 0.01))
83+
assert np.all(np.abs(drift) < 0.01)
8484
# test drift recovery - sinusoid 40 um peak amplitude
8585
dcor = np.sin(2 * np.pi * t / np.max(t) * 2) * 50
8686
drift, ts = electrode_drift.estimate_drift(t, a, cells_depth[c] + dcor, display=False)

brainbox/tests/test_passive.py

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,24 @@ def test_rf_map(self):
2727

2828
rf_map_times, rf_map_pos, rf_stim_frames = passive.get_on_off_times_and_positions(rf_map)
2929

30-
assert(all(rf_map_times == test_times))
31-
assert(rf_map_pos.shape == (15 * 15, 2))
32-
assert(len(rf_stim_frames['on']) == 15 * 15)
33-
assert(len(rf_stim_frames['off']) == 15 * 15)
30+
self.assertTrue(np.all(rf_map_times == test_times))
31+
self.assertEqual(rf_map_pos.shape, (15 * 15, 2))
32+
self.assertEqual(len(rf_stim_frames['on']), 15 * 15)
33+
self.assertEqual(len(rf_stim_frames['off']), 15 * 15)
3434

3535
# Off is for the 0 ones
36-
assert(all(rf_stim_frames['off'][ismember2d(rf_map_pos, np.array([[8, 8]]))[0]][0][0]
37-
== [10, 50]))
38-
assert(rf_stim_frames['off'][ismember2d(rf_map_pos, np.array([[4, 9]]))[0]][0][0] == 40)
39-
assert(rf_stim_frames['off'][ismember2d(rf_map_pos, np.array([[11, 4]]))[0]][0][0] == 42)
36+
idx = ismember2d(rf_map_pos, np.array([[8, 8]]))[0]
37+
self.assertTrue(np.all(rf_stim_frames['off'][idx][0][0] == [10, 50]))
38+
idx = ismember2d(rf_map_pos, np.array([[4, 9]]))[0]
39+
self.assertEqual(rf_stim_frames['off'][idx][0][0], 40)
40+
idx = ismember2d(rf_map_pos, np.array([[11, 4]]))[0]
41+
self.assertEqual(rf_stim_frames['off'][idx][0][0], 42)
4042

4143
# On is for the 255 ones
42-
assert(rf_stim_frames['on'][ismember2d(rf_map_pos, np.array([[10, 13]]))[0]][0][0] == 25)
43-
assert(rf_stim_frames['on'][ismember2d(rf_map_pos, np.array([[6, 10]]))[0]][0][0] == 42)
44+
idx = ismember2d(rf_map_pos, np.array([[10, 13]]))[0]
45+
self.assertEqual(rf_stim_frames['on'][idx][0][0], 25)
46+
idx = ismember2d(rf_map_pos, np.array([[6, 10]]))[0]
47+
self.assertEqual(rf_stim_frames['on'][idx][0][0], 42)
4448

4549
# Next test that the firing rate function works
4650
# Basically just make one square responsive
@@ -51,19 +55,19 @@ def test_rf_map(self):
5155
rf_stim_frames, spike_times,
5256
spike_depths, x_lim=[0, 60])
5357
non_zero = np.where(rf_map_avg['on'] != 0)
54-
assert(np.argmin(np.abs(depths - 500)) == non_zero[0][0])
55-
assert(all(non_zero[1] == 10))
56-
assert (all(non_zero[2] == 13))
58+
self.assertEqual(np.argmin(np.abs(depths - 500)), non_zero[0][0])
59+
self.assertTrue(np.all(non_zero[1] == 10))
60+
self.assertTrue(np.all(non_zero[2] == 13))
5761

58-
assert(np.all(rf_map_avg['off'] == 0))
62+
self.assertTrue(np.all(rf_map_avg['off'] == 0))
5963

6064
rf_svd = passive.get_svd_map(rf_map_avg)
6165
# Make sure that the one responsive element is non-zero
62-
assert(rf_svd['on'][non_zero[0][0]][non_zero[1][0], non_zero[2][0]] != 0)
66+
self.assertTrue(rf_svd['on'][non_zero[0][0]][non_zero[1][0], non_zero[2][0]] != 0)
6367
# But that all the rest are zero
6468
rf_svd['on'][non_zero[0][0]][non_zero[1][0], non_zero[2][0]] = 0
65-
assert(np.all(np.isclose(np.vstack(rf_svd['on']), 0)))
66-
assert(np.all(np.vstack(rf_svd['off']) == 0))
69+
self.assertTrue(np.all(np.isclose(np.vstack(rf_svd['on']), 0)))
70+
self.assertTrue(np.all(np.vstack(rf_svd['off']) == 0))
6771

6872
def test_stim_aligned(self):
6973

@@ -78,8 +82,8 @@ def test_stim_aligned(self):
7882
stim_activity = passive.get_stim_aligned_activity(aud_stim, spike_times, spike_depths,
7983
z_score_flag=False, x_lim=[0, 40])
8084

81-
assert(list(stim_activity.keys()) == ['valveOn'])
85+
self.assertCountEqual(stim_activity.keys(), ['valveOn'])
8286
# The first may be a bit different due to overlap with noise floor
83-
assert(all(stim_activity['valveOn'][0][1:] == 5))
87+
self.assertTrue(np.all(stim_activity['valveOn'][0][1:] == 5))
8488
# make sure the rest of the depths are all zero
85-
assert(np.all(stim_activity['valveOn'][1:] == 0))
89+
self.assertTrue(np.all(stim_activity['valveOn'][1:] == 0))

0 commit comments

Comments
 (0)