Skip to content

Commit 745e4a3

Browse files
authored
Merge pull request #578 from AllenInstitute/fix-and-silence-warnings
Fix and silence warnings
2 parents 5c94fc7 + a16a55a commit 745e4a3

14 files changed

+47
-15
lines changed

ipfx/bin/make_stimulus_ontology.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def make_stimulus_ontology(stims):
2323
scode = stim['stimulus_code']
2424

2525
# code tags
26-
m = re.search("(.*)\d{6}$", scode)
26+
m = re.search(r"(.*)\d{6}$", scode)
2727
if m:
2828
code_name, = m.groups()
2929
tags.add((CODE, code_name, scode))

ipfx/dataset/ephys_nwb_data.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ def get_clamp_mode(self,sweep_number):
308308

309309
def get_spike_times(self, sweep_number):
310310
spikes = self.nwb.get_processing_module('spikes')
311-
sweep_spikes = spikes.get_data_interface(f"Sweep_{sweep_number}")
311+
sweep_spikes = spikes.get(f"Sweep_{sweep_number}")
312312
return sweep_spikes.timestamps
313313

314314
@staticmethod

ipfx/nwb_append.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def append_spike_times(input_nwb_path: PathLike,
5959
unit='seconds',
6060
data=wrapped_spike_times,
6161
name=f"Sweep_{sweep_num}")
62-
spike_module.add_data_interface(ts)
62+
spike_module.add(ts)
6363

6464
nwbfile.add_processing_module(spike_module)
6565

ipfx/time_series_utils.py

100644100755
Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,14 @@ def calculate_dvdt(v, t, filter=None):
5050
dv = np.diff(v)
5151

5252
dt = np.diff(t)
53-
dvdt = 1e-3 * dv / dt # in V/s = mV/ms
5453

55-
# some data sources, such as neuron, occasionally report
54+
# some data sources, such as neuron, occasionally report
5655
# duplicate timestamps, so we require that dt is not 0
57-
return dvdt[np.fabs(dt) > sys.float_info.epsilon]
56+
mask = np.fabs(dt) > sys.float_info.epsilon
57+
58+
dvdt = 1e-3 * dv[mask] / dt[mask] # in V/s = mV/ms
59+
60+
return dvdt
5861

5962

6063
def has_fixed_dt(t):

pytest.ini

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,9 @@ markers =
66
requires_inhouse_data: require inhouse data
77

88
filterwarnings =
9+
error
910
ignore:add_child is deprecated. Set the parent attribute instead.:DeprecationWarning
11+
ignore::marshmallow.warnings.RemovedInMarshmallow4Warning
12+
ignore::marshmallow.warnings.ChangedInMarshmallow4Warning
13+
ignore:scipy.misc is deprecated and will be removed in 2.0.0
14+
ignore:.*behaviour will change in pandas 3.0!.*:FutureWarning

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ pillow
1111
pyabf
1212
pynwb==3.1.2
1313
pyYAML
14+
python-dateutil
1415
ruamel.yaml<0.18.0
1516
scipy
1617
simplejson

tests/attach_metadata/test_cli.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
import pytest
1515
from ipfx.utilities import inject_sweep_table
1616

17+
from dateutil.tz import tzlocal
18+
1719
class CliRunner:
1820

1921
def __init__(
@@ -54,7 +56,7 @@ def simple_nwb(base_path):
5456
nwbfile = pynwb.NWBFile(
5557
session_description="test session",
5658
identifier='test session',
57-
session_start_time=datetime.now()
59+
session_start_time=datetime.now(tzlocal())
5860
)
5961

6062
inject_sweep_table(nwbfile)
@@ -149,6 +151,7 @@ def test_cli_nwb2(cli_runner):
149151
[1, 2, 3]
150152
)
151153

154+
@pytest.mark.filterwarnings("ignore:.*Use of icephys_filtering is deprecated and will be removed in PyNWB 4.0. Use the IntracellularElectrode.filtering field instead")
152155
def test_cli_mies(cli_runner):
153156
in_nwb_path = os.path.join(cli_runner.tmpdir, "input.nwb")
154157
out_nwb_path = os.path.join(cli_runner.tmpdir, "meta.nwb")

tests/attach_metadata/test_nwb2_sink.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import pynwb
1616
import h5py
1717

18+
from dateutil.tz import tzlocal
1819
from ipfx.attach_metadata.sink import nwb2_sink
1920
from ipfx.utilities import inject_sweep_table
2021

@@ -24,7 +25,7 @@ def nwbfile():
2425
_nwbfile = pynwb.NWBFile(
2526
session_description="test session",
2627
identifier='test session',
27-
session_start_time=datetime.now()
28+
session_start_time=datetime.now(tzlocal())
2829
)
2930
dev = pynwb.device.Device(name="my_device")
3031
_nwbfile.add_device(dev)
@@ -78,6 +79,8 @@ def test_get_subject(nwbfile, set_none):
7879
assert nwbfile.subject.subject_id == "foo"
7980

8081

82+
@pytest.mark.filterwarnings("ignore:.*Value with data type int64 is being converted to data type uint64.*")
83+
@pytest.mark.filterwarnings("ignore:.*It is recommended that NWB files using the HDF5 backend use the '.nwb' extension.")
8184
def test_serialize(tmpdir_factory, nwbfile):
8285
out_path = os.path.join(
8386
str(tmpdir_factory.mktemp("test_serialize")),
@@ -88,7 +91,6 @@ def test_serialize(tmpdir_factory, nwbfile):
8891
sink._data = io.BytesIO()
8992
sink._h5_file = h5py.File(sink._data, "w")
9093
sink._nwb_io = pynwb.NWBHDF5IO(
91-
path=sink._h5_file.filename,
9294
mode="w",
9395
file=sink._h5_file
9496
)
@@ -101,6 +103,7 @@ def test_serialize(tmpdir_factory, nwbfile):
101103
assert obt.identifier == "test session"
102104

103105

106+
@pytest.mark.filterwarnings("ignore:.*Value with data type int64 is being converted to data type uint64.*")
104107
def test_roundtrip(tmpdir_factory, nwbfile):
105108
tmpdir = str(tmpdir_factory.mktemp("test_serialize"))
106109
first_path = os.path.join(tmpdir, "first.nwb")
@@ -135,6 +138,7 @@ def test_roundtrip(tmpdir_factory, nwbfile):
135138
"Mus musculus"
136139
],
137140
])
141+
@pytest.mark.filterwarnings("ignore:.*Value with data type int64 is being converted to data type uint64.*")
138142
def test_register(
139143
tmpdir_factory, nwbfile, name, value, sweep_id, getter, expected
140144
):

tests/dataset/test_ephys_nwb_data.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from pynwb.icephys import CurrentClampStimulusSeries, CurrentClampSeries
88
import numpy as np
99
from ipfx.utilities import inject_sweep_table
10+
from dateutil.tz import tzlocal
1011

1112
from dictdiffer import diff
1213

@@ -28,8 +29,8 @@ def nwbfile_to_test():
2829
nwbfile = pynwb.NWBFile(
2930
session_description="test nwb data",
3031
identifier='test session',
31-
session_start_time=datetime.datetime.now(),
32-
file_create_date=datetime.datetime.now()
32+
session_start_time=datetime.datetime.now(tzlocal()),
33+
file_create_date=datetime.datetime.now(tzlocal())
3334
)
3435

3536
device = nwbfile.create_device(name='electrode_0')
@@ -102,14 +103,17 @@ def nwb_data(tmp_nwb_path):
102103
return EphysNWBData(nwb_file=tmp_nwb_path, ontology=ontology)
103104

104105

106+
@pytest.mark.filterwarnings("ignore:.*Value with data type int64 is being converted to data type uint64.*")
105107
def test_get_stimulus_unit(nwb_data):
106108
assert nwb_data.get_stimulus_unit(sweep_number=4) == "Amps"
107109

108110

111+
@pytest.mark.filterwarnings("ignore:.*Value with data type int64 is being converted to data type uint64.*")
109112
def test_get_stimulus_code(nwb_data):
110113
assert nwb_data.get_stimulus_code(sweep_number=4) == "STIMULUS_CODE"
111114

112115

116+
@pytest.mark.filterwarnings("ignore:.*Value with data type int64 is being converted to data type uint64.*")
113117
def test_get_sweep_data(nwb_data):
114118

115119
expected = {
@@ -124,6 +128,7 @@ def test_get_sweep_data(nwb_data):
124128
assert list(diff(expected, obtained, tolerance=0.001)) == []
125129

126130

131+
@pytest.mark.filterwarnings("ignore:.*Value with data type int64 is being converted to data type uint64.*")
127132
def test_get_sweep_attrs(nwb_data):
128133

129134
expected = {
@@ -140,12 +145,14 @@ def test_get_sweep_attrs(nwb_data):
140145
print(expected)
141146
assert expected == obtained
142147

148+
@pytest.mark.filterwarnings("ignore:.*Value with data type int64 is being converted to data type uint64.*")
143149
def test_get_clamp_mode(nwb_data):
144150

145151
attrs = nwb_data.get_sweep_attrs(4);
146152

147153
assert attrs['clamp_mode'] == "CurrentClamp"
148154

155+
@pytest.mark.filterwarnings("ignore:.*Value with data type int64 is being converted to data type uint64.*")
149156
def test_get_full_recording_date(nwb_data):
150157
assert nwb_data.get_full_recording_date() == nwb_data.nwb.session_start_time
151158

tests/dataset/test_hbg_nwb_data.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,12 @@ def hbg_nwb_data(tmp_nwb_path):
2727
return HBGNWBData(nwb_file=tmp_nwb_path, ontology=ontology)
2828

2929

30+
@pytest.mark.filterwarnings("ignore:.*Value with data type int64 is being converted to data type uint64.*")
3031
def test_create_hbg(hbg_nwb_data):
3132
assert isinstance(hbg_nwb_data,HBGNWBData)
3233

3334

35+
@pytest.mark.filterwarnings("ignore:.*Value with data type int64 is being converted to data type uint64.*")
3436
def test_get_sweep_metadata(hbg_nwb_data):
3537

3638
expected = {
@@ -48,6 +50,8 @@ def test_get_sweep_metadata(hbg_nwb_data):
4850
obtained = hbg_nwb_data.get_sweep_metadata(sweep_number=4)
4951
assert expected == obtained
5052

53+
54+
@pytest.mark.filterwarnings("ignore:.*Value with data type int64 is being converted to data type uint64.*")
5155
def test_get_stimulus_code_ext(hbg_nwb_data):
5256

5357
expected = 'STIMULUS_CODE'

0 commit comments

Comments
 (0)