Skip to content

Commit

Permalink
fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
stephprince committed Jul 25, 2024
1 parent 5fddba2 commit e174f26
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 23 deletions.
3 changes: 2 additions & 1 deletion src/hdf5/HDF5IO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,7 @@ Status HDF5RecordingData::writeDataBlock(
return Status::Success;
}

const H5::DataSet* HDF5RecordingData::getDataSet(){
const H5::DataSet* HDF5RecordingData::getDataSet()
{
return dSet.get();
};
13 changes: 7 additions & 6 deletions tests/testBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,20 @@ TEST_CASE("TimeSeries", "[base]")
// Read data back from file
double* tsBuffer = new double[numSamples];
BaseRecordingData* tsDset = io->getDataSet(dataPath + "/timestamps");
readH5DataBlock(static_cast<HDF5::HDF5RecordingData*>(tsDset)->getDataSet(),
timestampsType,
tsBuffer);
readH5DataBlock(static_cast<HDF5::HDF5RecordingData*>(tsDset)->getDataSet(),
timestampsType,
tsBuffer);
std::vector<double> tsRead(tsBuffer, tsBuffer + numSamples);
delete[] tsBuffer;
REQUIRE(tsRead == timestamps);

// Read data back from file
float* dataBuffer = new float[numSamples];
BaseRecordingData* dataDset = io->getDataSet(dataPath + "/data");
readH5DataBlock(static_cast<HDF5::HDF5RecordingData*>(dataDset)->getDataSet(),
dataType,
dataBuffer);
readH5DataBlock(
static_cast<HDF5::HDF5RecordingData*>(dataDset)->getDataSet(),
dataType,
dataBuffer);
std::vector<float> dataRead(dataBuffer, dataBuffer + numSamples);
delete[] dataBuffer;
REQUIRE_THAT(dataRead, Catch::Matchers::Approx(data).margin(1));
Expand Down
7 changes: 4 additions & 3 deletions tests/testFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,10 @@ TEST_CASE("ElectrodeTable", "[ecephys]")
SizeType numChannels = 3;
BaseRecordingData* id_data = io->getDataSet(path + "id");
int* buffer = new int[numChannels];
readH5DataBlock(static_cast<HDF5::HDF5RecordingData*>(id_data)->getDataSet(),
BaseDataType::I32,
buffer);
readH5DataBlock(
static_cast<HDF5::HDF5RecordingData*>(id_data)->getDataSet(),
BaseDataType::I32,
buffer);
std::vector<SizeType> read_channels(buffer, buffer + numChannels);
delete[] buffer;
REQUIRE(channelIDs == read_channels);
Expand Down
31 changes: 20 additions & 11 deletions tests/testHDF5IO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,10 @@ TEST_CASE("writeDataset", "[hdf5io]")

BaseRecordingData* dataRead = hdf5io->getDataSet(dataPath);
int* buffer = new int[numSamples];
readH5DataBlock(static_cast<HDF5::HDF5RecordingData*>(dataRead)->getDataSet(),
BaseDataType::I32,
buffer);
readH5DataBlock(
static_cast<HDF5::HDF5RecordingData*>(dataRead)->getDataSet(),
BaseDataType::I32,
buffer);
std::vector<int> dataOut(buffer, buffer + numSamples);
delete[] buffer;

Expand Down Expand Up @@ -100,9 +101,10 @@ TEST_CASE("writeDataset", "[hdf5io]")
// Read back the 1D data block from 3D dataset
BaseRecordingData* dataRead1D = hdf5io->getDataSet(dataPath);
int* buffer1D = new int[numCols];
readH5DataBlock(static_cast<HDF5::HDF5RecordingData*>(dataRead1D)->getDataSet(),
BaseDataType::I32,
buffer1D);
readH5DataBlock(
static_cast<HDF5::HDF5RecordingData*>(dataRead1D)->getDataSet(),
BaseDataType::I32,
buffer1D);
std::vector<int> dataOut1D(buffer1D, buffer1D + numCols);
delete[] buffer1D;

Expand Down Expand Up @@ -139,8 +141,10 @@ TEST_CASE("writeDataset", "[hdf5io]")
// Read back the 2D data block
BaseRecordingData* dataRead = hdf5io->getDataSet(dataPath);
int* buffer = new int[numRows * numCols];
readH5DataBlock(static_cast<HDF5::HDF5RecordingData*>(dataRead)->getDataSet(),
BaseDataType::I32, buffer);
readH5DataBlock(
static_cast<HDF5::HDF5RecordingData*>(dataRead)->getDataSet(),
BaseDataType::I32,
buffer);
std::vector<int> dataOut(buffer, buffer + numRows * numCols);
delete[] buffer;

Expand Down Expand Up @@ -175,8 +179,10 @@ TEST_CASE("writeDataset", "[hdf5io]")
BaseRecordingData* dataRead1D = hdf5io->getDataSet(dataPath);
int* buffer1D =
new int[width]; // Assuming 'width' is the size of the 1D data block
readH5DataBlock(static_cast<HDF5::HDF5RecordingData*>(dataRead1D)->getDataSet(),
BaseDataType::I32, buffer1D);
readH5DataBlock(
static_cast<HDF5::HDF5RecordingData*>(dataRead1D)->getDataSet(),
BaseDataType::I32,
buffer1D);
std::vector<int> dataOut1D(buffer1D, buffer1D + width);
delete[] buffer1D;

Expand Down Expand Up @@ -211,7 +217,10 @@ TEST_CASE("writeDataset", "[hdf5io]")
int* buffer2D =
new int[height * width]; // Assuming 'numRows' and 'numCols' define the
// 2D data block size
readH5DataBlock(static_cast<HDF5::HDF5RecordingData*>(dataRead2D)->getDataSet(), BaseDataType::I32, buffer2D);
readH5DataBlock(
static_cast<HDF5::HDF5RecordingData*>(dataRead2D)->getDataSet(),
BaseDataType::I32,
buffer2D);
std::vector<int> dataOut2D(buffer2D, buffer2D + height * width);
delete[] buffer2D;

Expand Down
5 changes: 3 additions & 2 deletions tests/testUtils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,9 @@ inline std::vector<double> getMockTimestamps(SizeType numSamples = 1000,
return mockTimestamps;
}

inline void readH5DataBlock(const H5::DataSet* dSet, const BaseDataType& type, void*
buffer)
inline void readH5DataBlock(const H5::DataSet* dSet,
const BaseDataType& type,
void* buffer)
{
H5::DataSpace fSpace = dSet->getSpace();
H5::DataType nativeType = HDF5::HDF5IO::getNativeType(type);
Expand Down

0 comments on commit e174f26

Please sign in to comment.