Skip to content

Commit

Permalink
Merge branch 'dev' into add_dandi_inspector
Browse files Browse the repository at this point in the history
  • Loading branch information
CodyCBakerPhD committed Sep 1, 2024
2 parents 3660ed6 + 91799e8 commit 3c6fa21
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 13 deletions.
4 changes: 1 addition & 3 deletions src/nwbinspector/_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
import jsonschema
import yaml

from nwbinspector.utils._utils import (
PathType,
)
from nwbinspector.utils import PathType

from . import available_checks
from ._registration import Importance
Expand Down
6 changes: 4 additions & 2 deletions src/nwbinspector/_formatting.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,17 @@ def __init__(
self.message_counter = 0
self.formatted_messages = []

def _count_messages_by_importance(self, messages: List[InspectorMessage]) -> Dict[str, int]:
@staticmethod
def _count_messages_by_importance(messages: List[InspectorMessage]) -> Dict[str, int]:
message_count_by_importance = {importance_level.name: 0 for importance_level in Importance}
for message in messages:
message_count_by_importance[message.importance.name] += 1
for key in [keys for keys, count in message_count_by_importance.items() if count == 0]:
message_count_by_importance.pop(key)
return message_count_by_importance

def _get_name(self, obj) -> str:
@staticmethod
def _get_name(obj) -> str:
if isinstance(obj, Enum):
return obj.name
if isinstance(obj, str):
Expand Down
8 changes: 4 additions & 4 deletions src/nwbinspector/_nwb_inspection.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from collections import defaultdict
from concurrent.futures import ProcessPoolExecutor, as_completed
from pathlib import Path
from typing import Iterable, List, Optional, Union
from typing import Iterable, List, Optional, Type, Union
from warnings import filterwarnings, warn

import pynwb
Expand Down Expand Up @@ -34,7 +34,7 @@ def inspect_all(
n_jobs: int = 1,
skip_validate: bool = False,
progress_bar: bool = True,
progress_bar_class: tqdm = tqdm,
progress_bar_class: Type[tqdm] = tqdm,
progress_bar_options: Optional[dict] = None,
stream: bool = False, # TODO: remove after 3/1/2025
version_id: Optional[str] = None, # TODO: remove after 3/1/2025
Expand Down Expand Up @@ -427,7 +427,7 @@ def inspect_nwbfile_object(
def run_checks(
nwbfile: pynwb.NWBFile,
checks: list,
progress_bar_class: Optional[tqdm] = None,
progress_bar_class: Optional[Type[tqdm]] = None,
progress_bar_options: Optional[dict] = None,
) -> Iterable[InspectorMessage]:
"""
Expand All @@ -441,7 +441,7 @@ def run_checks(
The list of check functions that will be run on the in-memory pynwb.NWBFile object.
progress_bar_class : type of tqdm.tqdm, optional
The specific child class of tqdm.tqdm to use to make progress bars.
Defaults to not displaying progress per set of checks over an invidiual file.
Defaults to not displaying progress per set of checks over an individual file.
progress_bar_options : dict, optional
Dictionary of keyword arguments to pass directly to the `progress_bar_class`.
Expand Down
3 changes: 2 additions & 1 deletion tests/streaming_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ def setUpClass(cls):
def tearDownClass(cls):
rmtree(cls.tempdir)

def assertFileExists(self, path: FilePathType):
@staticmethod
def assertFileExists(path: FilePathType):
path = Path(path)
assert path.exists()

Expand Down
3 changes: 2 additions & 1 deletion tests/test_inspector.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ def add_simple_table(nwbfile: NWBFile):
class TestInspector(TestCase):
"""A common helper class for testing the NWBInspector."""

def assertFileExists(self, path: FilePathType):
@staticmethod
def assertFileExists(path: FilePathType):
path = Path(path)
assert path.exists()

Expand Down
3 changes: 1 addition & 2 deletions tests/unit_tests/test_nwb_containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
from pynwb import NWBContainer, NWBFile
from pynwb.image import ImageSeries

from nwbinspector import Importance, InspectorMessage
from nwbinspector._registration import Severity
from nwbinspector import Importance, InspectorMessage, Severity
from nwbinspector.checks import (
check_empty_string_for_optional_attribute,
check_large_dataset_compression,
Expand Down

0 comments on commit 3c6fa21

Please sign in to comment.