Skip to content

Commit 2509e67

Browse files
Merge pull request #264 from NeurodataWithoutBorders/fix_pynwb_version_icephys
Fix attribute retrieval from version-dependent icephys
2 parents 40a9885 + 7045196 commit 2509e67

File tree

3 files changed

+48
-1
lines changed

3 files changed

+48
-1
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Past PyNWB Version
2+
on:
3+
schedule:
4+
- cron: "0 0 * * *" # daily
5+
pull_request:
6+
7+
jobs:
8+
build-and-test:
9+
name: Testing against past PyNWB versions
10+
runs-on: ubuntu-latest
11+
strategy:
12+
fail-fast: false
13+
matrix:
14+
pynwb-version: ["2.1.0", "2.0.0"]
15+
steps:
16+
- uses: s-weigand/setup-conda@v1
17+
with:
18+
update-conda: true
19+
python-version: 3.9
20+
conda-channels: conda-forge
21+
- uses: actions/checkout@v2
22+
- run: git fetch --prune --unshallow --tags
23+
- name: Install pytest
24+
run: |
25+
pip install pytest
26+
pip install pytest-cov
27+
- name: Install package
28+
run: |
29+
pip install -e .
30+
pip install pynwb==${{ matrix.pynwb-version }}
31+
- name: Run pytest with coverage
32+
run: pytest -rsx

nwbinspector/checks/icephys.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@
66
@register_check(importance=Importance.BEST_PRACTICE_VIOLATION, neurodata_type=IntracellularElectrode)
77
def check_intracellular_electrode_cell_id_exists(intracellular_electrode: IntracellularElectrode):
88
"""Check if the IntracellularElectrode contains a cell_id."""
9-
if intracellular_electrode.cell_id is None:
9+
if hasattr(intracellular_electrode, "cell_id") and intracellular_electrode.cell_id is None:
1010
return InspectorMessage(message="Please include a unique cell_id associated with this IntracellularElectrode.")

tests/unit_tests/test_icephys.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,23 @@
1+
import pytest
2+
from packaging.version import Version
13
from pynwb.icephys import IntracellularElectrode
24
from pynwb.device import Device
35

46
from nwbinspector import InspectorMessage, Importance, check_intracellular_electrode_cell_id_exists
7+
from nwbinspector.utils import get_package_version
58

9+
PYNWB_VERSION_LOWER_2_1_0 = get_package_version(name="pynwb") < Version("2.1.0")
10+
PYNWB_VERSION_LOWER_SKIP_REASON = "This test requires PyNWB>=2.1.0"
611

12+
13+
@pytest.mark.skipif(PYNWB_VERSION_LOWER_2_1_0, reason=PYNWB_VERSION_LOWER_SKIP_REASON)
714
def test_pass_check_intracellular_electrode_cell_id_exists():
815
device = Device(name="device")
916
ielec = IntracellularElectrode(name="ielec", cell_id="123", device=device, description="an intracellular electrode")
1017
assert check_intracellular_electrode_cell_id_exists(ielec) is None
1118

1219

20+
@pytest.mark.skipif(PYNWB_VERSION_LOWER_2_1_0, reason=PYNWB_VERSION_LOWER_SKIP_REASON)
1321
def test_fail_check_intracellular_electrode_cell_id_exists():
1422
device = Device(name="device")
1523
ielec = IntracellularElectrode(name="ielec", device=device, description="an intracellular electrode")
@@ -21,3 +29,10 @@ def test_fail_check_intracellular_electrode_cell_id_exists():
2129
object_name="ielec",
2230
location="/",
2331
)
32+
33+
34+
@pytest.mark.skipif(not PYNWB_VERSION_LOWER_2_1_0, reason="This test requires PyNWB<2.1.0")
35+
def test_skip_check_for_lower_versions():
36+
device = Device(name="device")
37+
ielec = IntracellularElectrode(name="ielec", device=device, description="an intracellular electrode")
38+
assert check_intracellular_electrode_cell_id_exists(ielec) is None

0 commit comments

Comments
 (0)