Skip to content

Commit

Permalink
fix issue where check fails when description is a list in FeatureExtr…
Browse files Browse the repository at this point in the history
…action
  • Loading branch information
bendichter committed Nov 21, 2024
1 parent 3aa3dab commit ca0a41c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/nwbinspector/checks/_general.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def check_description(neurodata_object: object) -> Optional[InspectorMessage]:
Best Practice: :ref:`best_practice_placeholders`
"""
if not hasattr(neurodata_object, "description"):
if not hasattr(neurodata_object, "description") or type(neurodata_object.description) is not str:
return None
if neurodata_object.description is None or neurodata_object.description.strip(" ") == "":
return InspectorMessage(message="Description is missing.")
Expand Down
27 changes: 26 additions & 1 deletion tests/unit_tests/test_general.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from hdmf.common import DynamicTable
from hdmf.common import DynamicTable, DynamicTableRegion

from nwbinspector import Importance, InspectorMessage
from nwbinspector.checks import check_description, check_name_slashes
Expand Down Expand Up @@ -50,3 +50,28 @@ def test_check_description_missing():
object_name="test",
location="/",
)


def test_check_description_feature_extraction():
import numpy as np

from pynwb.ecephys import FeatureExtraction
from pynwb.testing.mock.ecephys import mock_ElectrodeTable

electrodes = mock_ElectrodeTable()

dynamic_table_region = DynamicTableRegion(
name="electrodes", description="I am wrong", data=[0, 1, 2, 3, 4], table=electrodes
)

feature_extraction = FeatureExtraction(
name="PCA_features",
electrodes=dynamic_table_region,
description=["PC1", "PC2", "PC3", "PC4"],
times=[.033, .066, .099],
features=np.random.rand(3, 5, 4), # time, channel, feature
)

assert check_description(neurodata_object=feature_extraction) is None


0 comments on commit ca0a41c

Please sign in to comment.