Skip to content

Commit

Permalink
Fix warnings from tests (#1778)
Browse files Browse the repository at this point in the history
  • Loading branch information
rly authored Oct 4, 2023
1 parent 4656c08 commit 97ea603
Show file tree
Hide file tree
Showing 17 changed files with 328 additions and 193 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/run_all_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,9 @@ jobs:
fail-fast: false
matrix:
include:
- { name: linux-python3.11-ros3 , python-ver: "3.11", os: ubuntu-latest }
- { name: windows-python3.11-ros3, python-ver: "3.11", os: windows-latest }
- { name: macos-python3.11-ros3 , python-ver: "3.11", os: macos-latest }
- { name: conda-linux-python3.11-ros3 , python-ver: "3.11", os: ubuntu-latest }
- { name: conda-windows-python3.11-ros3, python-ver: "3.11", os: windows-latest }
- { name: conda-macos-python3.11-ros3 , python-ver: "3.11", os: macos-latest }
steps:
- name: Cancel non-latest runs
uses: styfle/[email protected]
Expand Down Expand Up @@ -243,9 +243,9 @@ jobs:
fail-fast: false
matrix:
include:
- { name: linux-gallery-python3.11-ros3 , python-ver: "3.11", os: ubuntu-latest }
- { name: windows-gallery-python3.11-ros3, python-ver: "3.11", os: windows-latest }
- { name: macos-gallery-python3.11-ros3 , python-ver: "3.11", os: macos-latest }
- { name: conda-linux-gallery-python3.11-ros3 , python-ver: "3.11", os: ubuntu-latest }
- { name: conda-windows-gallery-python3.11-ros3, python-ver: "3.11", os: windows-latest }
- { name: conda-macos-gallery-python3.11-ros3 , python-ver: "3.11", os: macos-latest }
steps:
- name: Cancel non-latest runs
uses: styfle/[email protected]
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/run_dandi_read_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@ jobs:
- name: Run DANDI read tests
run: |
pytest -rP tests/read_dandi/
python tests/read_dandi/test_read_dandi.py
4 changes: 2 additions & 2 deletions .github/workflows/run_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ jobs:
fail-fast: false
matrix:
include:
- { name: linux-python3.11-ros3 , python-ver: "3.11", os: ubuntu-latest }
- { name: conda-linux-python3.11-ros3 , python-ver: "3.11", os: ubuntu-latest }
steps:
- name: Cancel non-latest runs
uses: styfle/[email protected]
Expand Down Expand Up @@ -219,7 +219,7 @@ jobs:
fail-fast: false
matrix:
include:
- { name: linux-gallery-python3.11-ros3 , python-ver: "3.11", os: ubuntu-latest }
- { name: conda-linux-gallery-python3.11-ros3 , python-ver: "3.11", os: ubuntu-latest }
steps:
- name: Cancel non-latest runs
uses: styfle/[email protected]
Expand Down
2 changes: 1 addition & 1 deletion docs/notebooks/convert-crcns-ret-1-meisterlab.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1004,7 +1004,7 @@
"source": [
"## Step 5.2: Convert all files\n",
"\n",
"Convert all the files by iteating over the files and calling `convert_single_file` function for each of the file"
"Convert all the files by iterating over the files and calling `convert_single_file` function for each of the file"
]
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1001,7 +1001,7 @@
"source": [
"## Step 5.3: Convert all files\n",
"\n",
"Convert all the files by iteating over the files and calling `convert_single_file` function for each of the file"
"Convert all the files by iterating over the files and calling `convert_single_file` function for each of the file"
]
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -974,7 +974,7 @@
"source": [
"## Step 5.3: Convert all files\n",
"\n",
"Convert all the files by iteating over the files and calling `convert_single_file` function for each of the file"
"Convert all the files by iterating over the files and calling `convert_single_file` function for each of the file"
]
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Convert all the files by iteating over the files and calling `convert_single_file` function for each of the file"
"Convert all the files by iterating over the files and calling `convert_single_file` function for each of the file"
]
},
{
Expand Down
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ per-file-ignores =
tests/integration/__init__.py:F401
src/pynwb/testing/__init__.py:F401
src/pynwb/validate.py:T201
tests/read_dandi/test_read_dandi.py:T201
setup.py:T201
test.py:T201
scripts/*:T201
Expand Down
30 changes: 26 additions & 4 deletions src/pynwb/testing/mock/ophys.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from hdmf.common.table import DynamicTableRegion

from ... import NWBFile
from ... import NWBFile, ProcessingModule
from ...device import Device
from ...ophys import (
RoiResponseSeries,
Expand Down Expand Up @@ -272,6 +272,8 @@ def mock_RoiResponseSeries(
else:
n_rois = 5

plane_seg = plane_segmentation or mock_PlaneSegmentation(n_rois=n_rois, nwbfile=nwbfile)

roi_response_series = RoiResponseSeries(
name=name if name is not None else name_generator("RoiResponseSeries"),
data=data if data is not None else np.ones((30, n_rois)),
Expand All @@ -280,7 +282,7 @@ def mock_RoiResponseSeries(
or DynamicTableRegion(
name="rois",
description="rois",
table=plane_segmentation or mock_PlaneSegmentation(n_rois=n_rois, nwbfile=nwbfile),
table=plane_seg,
data=list(range(n_rois)),
),
resolution=resolution,
Expand All @@ -298,6 +300,9 @@ def mock_RoiResponseSeries(
if "ophys" not in nwbfile.processing:
nwbfile.create_processing_module("ophys", "ophys")

if plane_seg.name not in nwbfile.processing["ophys"].data_interfaces:
nwbfile.processing["ophys"].add(plane_seg)

nwbfile.processing["ophys"].add(roi_response_series)

return roi_response_series
Expand All @@ -309,16 +314,24 @@ def mock_DfOverF(
nwbfile: Optional[NWBFile] = None
) -> DfOverF:
df_over_f = DfOverF(
roi_response_series=roi_response_series or [mock_RoiResponseSeries(nwbfile=nwbfile)],
name=name if name is not None else name_generator("DfOverF"),
)
plane_seg = mock_PlaneSegmentation(nwbfile=nwbfile)

if nwbfile is not None:
if "ophys" not in nwbfile.processing:
nwbfile.create_processing_module("ophys", "ophys")

nwbfile.processing["ophys"].add(df_over_f)

else:
pm = ProcessingModule(name="ophys", description="ophys")
pm.add(plane_seg)
pm.add(df_over_f)

df_over_f.add_roi_response_series(
roi_response_series or mock_RoiResponseSeries(nwbfile=nwbfile, plane_segmentation=plane_seg)
)
return df_over_f


Expand All @@ -328,13 +341,22 @@ def mock_Fluorescence(
nwbfile: Optional[NWBFile] = None,
) -> Fluorescence:
fluorescence = Fluorescence(
roi_response_series=roi_response_series or [mock_RoiResponseSeries(nwbfile=nwbfile)],
name=name if name is not None else name_generator("Fluorescence"),
)
plane_seg = mock_PlaneSegmentation(nwbfile=nwbfile)

if nwbfile is not None:
if "ophys" not in nwbfile.processing:
nwbfile.create_processing_module("ophys", "ophys")

nwbfile.processing["ophys"].add(fluorescence)
else:
pm = ProcessingModule(name="ophys", description="ophys")
pm.add(plane_seg)
pm.add(fluorescence)

fluorescence.add_roi_response_series(
roi_response_series or mock_RoiResponseSeries(nwbfile=nwbfile, plane_segmentation=plane_seg)
)

return fluorescence
5 changes: 2 additions & 3 deletions test.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def validate_nwbs():

def get_namespaces(nwbfile):
comp = run(["python", "-m", "pynwb.validate",
"--list-namespaces", "--cached-namespace", nwb],
"--list-namespaces", nwbfile],
stdout=PIPE, stderr=STDOUT, universal_newlines=True, timeout=30)

if comp.returncode != 0:
Expand All @@ -179,14 +179,13 @@ def get_namespaces(nwbfile):

cmds = []
cmds += [["python", "-m", "pynwb.validate", nwb]]
cmds += [["python", "-m", "pynwb.validate", "--cached-namespace", nwb]]
cmds += [["python", "-m", "pynwb.validate", "--no-cached-namespace", nwb]]

for ns in namespaces:
# for some reason, this logging command is necessary to correctly printing the namespace in the
# next logging command
logging.info("Namespace found: %s" % ns)
cmds += [["python", "-m", "pynwb.validate", "--cached-namespace", "--ns", ns, nwb]]
cmds += [["python", "-m", "pynwb.validate", "--ns", ns, nwb]]

for cmd in cmds:
logging.info("Validating with \"%s\"." % (" ".join(cmd[:-1])))
Expand Down
Loading

0 comments on commit 97ea603

Please sign in to comment.