From 680ea8c9a7ac0b6d2a7fab2d19a65694bbb78881 Mon Sep 17 00:00:00 2001 From: Steph Prince <40640337+stephprince@users.noreply.github.com> Date: Thu, 23 May 2024 11:09:46 -0700 Subject: [PATCH] fix formatting --- src/BaseIO.cpp | 7 +++++-- src/Channel.hpp | 3 ++- src/Utils.hpp | 16 +++++++++------- src/hdf5/HDF5IO.cpp | 2 +- src/nwb/NWBFile.cpp | 9 +++++---- src/nwb/NWBFile.hpp | 10 ++++------ src/nwb/NWBRecording.cpp | 22 ++++++++++------------ src/nwb/file/ElectrodeTable.cpp | 2 +- src/nwb/hdmf/table/DynamicTable.cpp | 2 +- src/nwb/hdmf/table/DynamicTableRegion.hpp | 3 +-- tests/testHDF5IO.cpp | 8 ++++---- tests/testNWBFile.cpp | 6 ++++-- tests/testNWBRecording.cpp | 18 +++++++++--------- tests/testUtils.hpp | 9 ++++----- 14 files changed, 60 insertions(+), 57 deletions(-) diff --git a/src/BaseIO.cpp b/src/BaseIO.cpp index d4971736..62067e02 100644 --- a/src/BaseIO.cpp +++ b/src/BaseIO.cpp @@ -32,7 +32,7 @@ const BaseDataType BaseDataType::DSTR = BaseDataType(T_STR, DEFAULT_STR_SIZE); // BaseIO BaseIO::BaseIO() - : readyToOpen(true) + : readyToOpen(true) , opened(false) { } @@ -78,7 +78,10 @@ Status BaseIO::createDataAttributes(const std::string& path, Status BaseIO::createTimestampsAttributes(const std::string& path) { int interval = 1; - createAttribute(BaseDataType::I32, static_cast(&interval), path + "/timestamps", "interval"); + createAttribute(BaseDataType::I32, + static_cast(&interval), + path + "/timestamps", + "interval"); createAttribute("seconds", path + "/timestamps", "unit"); return Status::Success; diff --git a/src/Channel.hpp b/src/Channel.hpp index 93c70875..7eeb7ef8 100644 --- a/src/Channel.hpp +++ b/src/Channel.hpp @@ -19,7 +19,8 @@ class Channel int globalIndex, float conversion = 1e6f, // uV to V float samplingRate = 30000.f, - float bitVolts = 0.000002f, // least significant bit needed to convert 16-bit int to volts + float bitVolts = 0.000002f, // least significant bit needed to + // convert 16-bit int to volts std::vector position = {0.f, 0.f, 0.f}) : name(name) , groupName(groupName) diff --git a/src/Utils.hpp b/src/Utils.hpp index 74dc2a8e..69dcafe3 100644 --- a/src/Utils.hpp +++ b/src/Utils.hpp @@ -7,9 +7,9 @@ #include #include #include -#include "boost/date_time/c_local_time_adjustor.hpp" #include "BaseIO.hpp" +#include "boost/date_time/c_local_time_adjustor.hpp" #include "hdf5/HDF5IO.hpp" namespace AQNWB @@ -58,11 +58,13 @@ inline std::string getCurrentTime() * @brief Factory method to create an IO object. * @return A pointer to a BaseIO object */ -inline std::unique_ptr createIO(const std::string& type, const std::string& filename) { - if (type == "HDF5") { - return std::make_unique(filename); - } else { - throw std::invalid_argument("Invalid IO type"); - } +inline std::unique_ptr createIO(const std::string& type, + const std::string& filename) +{ + if (type == "HDF5") { + return std::make_unique(filename); + } else { + throw std::invalid_argument("Invalid IO type"); + } } } // namespace AQNWB diff --git a/src/hdf5/HDF5IO.cpp b/src/hdf5/HDF5IO.cpp index 41841b63..0af0cade 100644 --- a/src/hdf5/HDF5IO.cpp +++ b/src/hdf5/HDF5IO.cpp @@ -685,4 +685,4 @@ Status HDF5RecordingData::writeDataRow(const SizeType& xDataSize, } return Status::Success; -}; \ No newline at end of file +} diff --git a/src/nwb/NWBFile.cpp b/src/nwb/NWBFile.cpp index 5ea0f851..d1afffaa 100644 --- a/src/nwb/NWBFile.cpp +++ b/src/nwb/NWBFile.cpp @@ -178,7 +178,8 @@ Status NWBFile::startRecording(std::vector recordingArrays) timeseriesData.push_back(std::move(electricalSeries)); - // Add electrode information to electrode table (does not write to datasets yet) + // Add electrode information to electrode table (does not write to datasets + // yet) elecTable.addElectrodes(channelGroup); } @@ -191,9 +192,9 @@ Status NWBFile::startRecording(std::vector recordingArrays) void NWBFile::stopRecording() {} Status NWBFile::writeTimeseriesTimestamps(int datasetInd, - int numSamples, - BaseDataType type, - const void* data) + int numSamples, + BaseDataType type, + const void* data) { if (!timeseriesData[datasetInd]) return Status::Failure; diff --git a/src/nwb/NWBFile.hpp b/src/nwb/NWBFile.hpp index 4dbcfe2a..d25d907a 100644 --- a/src/nwb/NWBFile.hpp +++ b/src/nwb/NWBFile.hpp @@ -55,9 +55,7 @@ class NWBFile * @brief Starts a recording. * @return Status The status of the recording operation. */ - Status startRecording( - std::vector - recordingArrays); + Status startRecording(std::vector recordingArrays); /** * @brief Closes the relevant datasets. @@ -72,9 +70,9 @@ class NWBFile * @param data The data to write. */ Status writeTimeseriesTimestamps(int datasetInd, - int numSamples, - BaseDataType type, - const void* data); + int numSamples, + BaseDataType type, + const void* data); /** * @brief Write a row of timeseries data to the NWB file. diff --git a/src/nwb/NWBRecording.cpp b/src/nwb/NWBRecording.cpp index 42c35288..ea0045ae 100644 --- a/src/nwb/NWBRecording.cpp +++ b/src/nwb/NWBRecording.cpp @@ -32,14 +32,12 @@ Status NWBRecording::openFiles(const std::string& rootFolder, rootFolder + baseName + std::to_string(experimentNumber) + ".nwb"; // initialize nwbfile object and create base structure - nwbfile = std::make_unique( - generateUuid(), - createIO(IOType, filename)); + nwbfile = std::make_unique(generateUuid(), + createIO(IOType, filename)); nwbfile->initialize(); // start the new recording - return nwbfile->startRecording( - recordingArrays); + return nwbfile->startRecording(recordingArrays); } void NWBRecording::closeFiles() @@ -62,12 +60,12 @@ void NWBRecording::writeTimeseriesData(int timeseriesInd, [multFactor](float value) { return value * multFactor; }); // convert float to int16 - std::transform(scaledBuffer.get(), - scaledBuffer.get() + numSamples, - intBuffer.get(), - [](float value) { - return static_cast(std::clamp(value, -32768.0f, 32767.0f)); - }); + std::transform( + scaledBuffer.get(), + scaledBuffer.get() + numSamples, + intBuffer.get(), + [](float value) + { return static_cast(std::clamp(value, -32768.0f, 32767.0f)); }); // write intBuffer data to dataset nwbfile->writeTimeseriesData(timeseriesInd, @@ -79,4 +77,4 @@ void NWBRecording::writeTimeseriesData(int timeseriesInd, nwbfile->writeTimeseriesTimestamps( timeseriesInd, numSamples, BaseDataType::F64, timestampBuffer); } -} \ No newline at end of file +} diff --git a/src/nwb/file/ElectrodeTable.cpp b/src/nwb/file/ElectrodeTable.cpp index 63ef720d..e5de893e 100644 --- a/src/nwb/file/ElectrodeTable.cpp +++ b/src/nwb/file/ElectrodeTable.cpp @@ -30,7 +30,7 @@ void ElectrodeTable::addElectrodes(std::vector channels) groupNames.push_back(ch.groupName); electrodeNumbers.push_back(ch.globalIndex); locationNames.push_back("unknown"); - } + } } void ElectrodeTable::finalize() diff --git a/src/nwb/hdmf/table/DynamicTable.cpp b/src/nwb/hdmf/table/DynamicTable.cpp index dd0b80d5..47f3cd64 100644 --- a/src/nwb/hdmf/table/DynamicTable.cpp +++ b/src/nwb/hdmf/table/DynamicTable.cpp @@ -79,4 +79,4 @@ std::string DynamicTable::getDescription() const const std::vector& DynamicTable::getColNames() { return colNames; -} \ No newline at end of file +} diff --git a/src/nwb/hdmf/table/DynamicTableRegion.hpp b/src/nwb/hdmf/table/DynamicTableRegion.hpp index 5dcc4fac..4f8b8db6 100644 --- a/src/nwb/hdmf/table/DynamicTableRegion.hpp +++ b/src/nwb/hdmf/table/DynamicTableRegion.hpp @@ -10,8 +10,7 @@ namespace AQNWB::NWB /** * @brief An n-dimensional dataset representing a column of a DynamicTable. */ -class DynamicTableRegion - : public VectorData +class DynamicTableRegion : public VectorData { public: /** diff --git a/tests/testHDF5IO.cpp b/tests/testHDF5IO.cpp index 45fd7c82..f7e1b020 100644 --- a/tests/testHDF5IO.cpp +++ b/tests/testHDF5IO.cpp @@ -27,12 +27,12 @@ TEST_CASE("writeGroup", "[hdf5io]") hdf5io.close(); } - SECTION("try initializing group that already exists") + SECTION("try initializing group that already exists") { // TODO } - SECTION("try initializing group without parent group") + SECTION("try initializing group without parent group") { // TODO } @@ -40,12 +40,12 @@ TEST_CASE("writeGroup", "[hdf5io]") TEST_CASE("writeDataset", "[hdf5io]") { - SECTION("create dataset and write data row") + SECTION("create dataset and write data row") { // TODO } - SECTION("create dataset and write data block") + SECTION("create dataset and write data block") { // TODO } diff --git a/tests/testNWBFile.cpp b/tests/testNWBFile.cpp index ffa1573c..cda9b82a 100644 --- a/tests/testNWBFile.cpp +++ b/tests/testNWBFile.cpp @@ -36,9 +36,11 @@ TEST_CASE("startRecording", "[nwb]") std::vector mockData = {1.0, 2.0, 3.0, 4.0, 5.0}; std::vector mockTimestamps = {0.1, 0.2, 0.3, 0.4, 0.5}; nwbfile.writeTimeseriesData(0, 0, 5, BaseDataType::F32, mockData.data()); - nwbfile.writeTimeseriesTimestamps(0, 5, BaseDataType::F32, mockTimestamps.data()); + nwbfile.writeTimeseriesTimestamps( + 0, 5, BaseDataType::F32, mockTimestamps.data()); nwbfile.writeTimeseriesData(1, 0, 5, BaseDataType::F32, mockData.data()); - nwbfile.writeTimeseriesTimestamps(1, 5, BaseDataType::F32, mockTimestamps.data()); + nwbfile.writeTimeseriesTimestamps( + 1, 5, BaseDataType::F32, mockTimestamps.data()); nwbfile.finalize(); diff --git a/tests/testNWBRecording.cpp b/tests/testNWBRecording.cpp index d7145e9d..53ec8cbf 100644 --- a/tests/testNWBRecording.cpp +++ b/tests/testNWBRecording.cpp @@ -48,7 +48,8 @@ TEST_CASE("writeContinuousData", "[recording]") for (const auto& channel : channelGroup) { // copy data into buffer std::copy(mockData[channel.globalIndex].begin() + samplesRecorded, - mockData[channel.globalIndex].begin() + samplesRecorded + numSamples / 10, + mockData[channel.globalIndex].begin() + samplesRecorded + + numSamples / 10, dataBuffer.begin()); std::copy(mockTimestamps.begin() + samplesRecorded, mockTimestamps.begin() + samplesRecorded + numSamples / 10, @@ -60,7 +61,6 @@ TEST_CASE("writeContinuousData", "[recording]") dataBuffer.data(), timestampsBuffer.data(), dataBuffer.size()); - } } // check if recording is done @@ -71,18 +71,18 @@ TEST_CASE("writeContinuousData", "[recording]") } } - SECTION("check contents of data and timestamps", "[recording]") + SECTION("check contents of data and timestamps", "[recording]") { - // TODO + // TODO } - SECTION("test if more samples than buffer size", "[recording]") + SECTION("test if more samples than buffer size", "[recording]") { - // TODO + // TODO } - SECTION("add a new recording number to the same file", "[recording]") + SECTION("add a new recording number to the same file", "[recording]") { - // TODO + // TODO } -} \ No newline at end of file +} diff --git a/tests/testUtils.hpp b/tests/testUtils.hpp index 0b472684..e724d0ea 100644 --- a/tests/testUtils.hpp +++ b/tests/testUtils.hpp @@ -36,9 +36,8 @@ inline std::vector getMockChannelArrays() Channel ch1 = Channel("ch1", "array1", 1, 1); Channel ch2 = Channel("ch2", "array2", 0, 2); Channel ch3 = Channel("ch3", "array2", 1, 3); - std::vector arrays = { - Types::ChannelGroup {ch0, ch1}, - Types::ChannelGroup {ch2, ch3}}; + std::vector arrays = {Types::ChannelGroup {ch0, ch1}, + Types::ChannelGroup {ch2, ch3}}; return arrays; } @@ -50,7 +49,7 @@ inline std::vector> getMockData(int numChannels = 4, std::random_device rd; std::mt19937 rng(rd()); // random number generator - std::uniform_real_distribution<> dis(-1.0, 1.0); //range of floats + std::uniform_real_distribution<> dis(-1.0, 1.0); // range of floats for (auto& channelData : mockData) { for (auto& data : channelData) { @@ -73,4 +72,4 @@ inline std::vector getMockTimestamps(int numSamples = 1000, } return mockTimestamps; -} \ No newline at end of file +}