diff --git a/CHANGELOG.md b/CHANGELOG.md index dc0c43feb..fd497150e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Upcoming +### Fixes +* Fixed issue where the description check failed if the description was a list. [#535](https://github.com/NeurodataWithoutBorders/nwbinspector/pull/535) + + # v0.6.0 ### Deprecation diff --git a/src/nwbinspector/checks/_general.py b/src/nwbinspector/checks/_general.py index f9b0b9563..1eefd1a65 100644 --- a/src/nwbinspector/checks/_general.py +++ b/src/nwbinspector/checks/_general.py @@ -25,9 +25,13 @@ def check_description(neurodata_object: object) -> Optional[InspectorMessage]: """ if not hasattr(neurodata_object, "description"): return None - if neurodata_object.description is None or neurodata_object.description.strip(" ") == "": + + description = neurodata_object.description + if description is not None and type(description) is not str: + return None + if description is None or description.strip(" ") == "": return InspectorMessage(message="Description is missing.") - if neurodata_object.description.lower().strip(".") in COMMON_DESCRIPTION_PLACEHOLDERS: - return InspectorMessage(message=f"Description ('{neurodata_object.description}') is a placeholder.") + if description.lower().strip(".") in COMMON_DESCRIPTION_PLACEHOLDERS: + return InspectorMessage(message=f"Description ('{description}') is a placeholder.") return None diff --git a/tests/unit_tests/test_general.py b/tests/unit_tests/test_general.py index 10ebc6551..d386ad612 100644 --- a/tests/unit_tests/test_general.py +++ b/tests/unit_tests/test_general.py @@ -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 @@ -50,3 +50,25 @@ 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=[0.033, 0.066, 0.099], + features=np.random.rand(3, 5, 4), # time, channel, feature + ) + + assert check_description(neurodata_object=feature_extraction) is None