From 5a411c480c3ecfc956d433e63662823d4b085129 Mon Sep 17 00:00:00 2001 From: Oliver Ruebel Date: Sun, 22 Sep 2024 12:32:07 -0700 Subject: [PATCH] Add TimeSeries.descriptionLazy field to test that reading string attributes works --- src/nwb/base/TimeSeries.hpp | 6 ++++++ tests/examples/test_ecephys_data_read.cpp | 9 +++++++++ 2 files changed, 15 insertions(+) diff --git a/src/nwb/base/TimeSeries.hpp b/src/nwb/base/TimeSeries.hpp index 750ff1b..0266c91 100644 --- a/src/nwb/base/TimeSeries.hpp +++ b/src/nwb/base/TimeSeries.hpp @@ -100,5 +100,11 @@ class TimeSeries : public Container float, "data/resolution", Smallest meaningful difference between values in data.) + + DEFINE_FIELD(descriptionLazy, + AttributeField, + std::string, + "description", + Description of the series) }; } // namespace AQNWB::NWB diff --git a/tests/examples/test_ecephys_data_read.cpp b/tests/examples/test_ecephys_data_read.cpp index e87f903..9f013a2 100644 --- a/tests/examples/test_ecephys_data_read.cpp +++ b/tests/examples/test_ecephys_data_read.cpp @@ -196,6 +196,15 @@ TEST_CASE("ElectricalSeriesReadExample", "[ecephys]") auto readBoostMulitArray = readDataValues.as_multi_array<2>(); // [example_read_only_snippet] + // Test that reading a string attribute works + auto esDescr = electricalSeries->descriptionLazy(); + auto esDescrData = esDescr->values(); + REQUIRE(esDescrData.data.size() == 1); + REQUIRE(esDescrData.shape.size() == 0); + REQUIRE(esDescrData.data[0] + == std::string("Stores continuously sampled voltage data from an " + "extracellular ephys recording")); + // TODO Slicing doesn't seem to work quite yet. The full data is loaded // instead. Let's read the first 10 timesteps for the first two channels /*DataBlock dataSlice = readDataWrapper->values(