Skip to content

Commit ebb8056

Browse files
committed
Fix deprecation warnings in tests
1 parent 35070e0 commit ebb8056

File tree

4 files changed

+10
-7
lines changed

4 files changed

+10
-7
lines changed

phylib/io/model.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1048,6 +1048,8 @@ def get_depths(self):
10481048
features = self.sparse_features.data[ispi, :, 0]
10491049
features = np.maximum(features, 0) ** 2 # takes only positive values into account
10501050
ichannels = self.sparse_features.cols[self.spike_clusters[ispi]].astype(np.uint32)
1051+
# features = np.square(self.sparse_features.data[ispi, :, 0])
1052+
# ichannels = self.sparse_features.cols[self.spike_templates[ispi]].astype(np.int64)
10511053
ypos = self.channel_positions[ichannels, 1]
10521054
with np.errstate(divide='ignore'):
10531055
spikes_depths[ispi] = (np.sum(np.transpose(ypos * features) /
@@ -1088,7 +1090,7 @@ def get_amplitudes_true(self, sample2unit=1.):
10881090
templates_amps_au = np.max(templates_ch_amps, axis=1)
10891091
spike_amps = templates_amps_au[self.spike_templates] * self.amplitudes
10901092

1091-
with np.errstate(divide='ignore'):
1093+
with np.errstate(divide='ignore', invalid='ignore'):
10921094
# take the average spike amplitude per template
10931095
templates_amps_v = (np.bincount(self.spike_templates, weights=spike_amps) /
10941096
np.bincount(self.spike_templates))

phylib/io/tests/test_datasets.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,15 @@ def _add_mock_response(url, body, file_type='binary'):
4646

4747
@yield_fixture
4848
def mock_url():
49-
_add_mock_response(_URL, _DATA.tostring())
49+
_add_mock_response(_URL, _DATA.tobytes())
5050
_add_mock_response(_URL + '.md5', _CHECKSUM + ' ' + Path(_URL).name)
5151
yield _URL
5252
responses.reset()
5353

5454

5555
@yield_fixture(params=product((True, False), repeat=4))
5656
def mock_urls(request):
57-
data = _DATA.tostring()
57+
data = _DATA.tobytes()
5858
checksum = _CHECKSUM
5959
url_data = _URL
6060
url_checksum = _URL + '.md5'
@@ -128,7 +128,7 @@ def test_download_already_exists_valid(tempdir, mock_url):
128128
path = Path(tempdir) / 'test'
129129
# Create valid file.
130130
with open(path, 'ab') as f:
131-
f.write(_DATA.tostring())
131+
f.write(_DATA.tobytes())
132132
_check(_dl(path))
133133
assert 'skip' in buf.getvalue()
134134

@@ -144,7 +144,7 @@ def test_download_file(tempdir, mock_urls):
144144
(not(checksum_here) and checksum_valid)))
145145

146146
download_succeeds = (assert_succeeds or (data_here and
147-
(not(data_valid) and not(checksum_here))))
147+
(not(data_valid) and not(checksum_here))))
148148

149149
if download_succeeds:
150150
data = _dl(path)

phylib/io/tests/test_merge.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def test_merged_single(merged, merged_original_amps=None):
101101
assert np.all(merged_original_amps[spike_probes == 0] <= 15)
102102
assert np.all(merged_original_amps[spike_probes == 1] >= 20)
103103

104-
np.all(merged.sparse_templates.data[:64, :, 0:32] == single.sparse_templates.data)
104+
# np.all(merged.sparse_templates.data[:64, :, 0:32] == single.sparse_templates.data)
105105

106106
# Convert into ALF and load.
107107
alf = EphysAlfCreator(merged).convert(tempdir / 'alf')

phylib/io/traces.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,7 @@ def _get_ephys_constructor(obj, **kwargs):
459459
return None, None, {}
460460
assert path.exists()
461461
ext = path.suffix
462+
assert ext, "No extension found in file `%s`" % path
462463
# Mtscomp file
463464
if ext == '.cbin':
464465
reader = mtscomp.Reader(n_threads=mp.cpu_count() // 2)
@@ -471,7 +472,7 @@ def _get_ephys_constructor(obj, **kwargs):
471472
return (NpyEphysReader, obj, kwargs)
472473
# TODO: other standard binary formats
473474
else: # pragma: no cover
474-
raise IOError("Unknown file extension: %s.", ext)
475+
raise IOError("Unknown file extension: `%s`." % ext)
475476
elif isinstance(obj, (tuple, list)):
476477
if obj:
477478
# Concatenate the main argument to the constructor.

0 commit comments

Comments
 (0)