Skip to content

Commit 7cbb86f

Browse files
author
Zaina Shaikh
committed
Fix Clang-Tidy issues
1 parent 14ee180 commit 7cbb86f

File tree

6 files changed

+36
-30
lines changed

6 files changed

+36
-30
lines changed

Simulator/Recorders/Hdf5Recorder.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,12 @@ void Hdf5Recorder::compileHistories()
189189
} else if (variableInfo.hdf5Datatype_ == PredType::NATIVE_INT) {
190190
vector<int> dataBuffer(variableInfo.variableLocation_.getNumElements());
191191
for (size_t i = 0; i < variableInfo.variableLocation_.getNumElements(); ++i) {
192-
if constexpr (std::is_same_v<vertexType, std::decay_t<decltype(get<vertexType>(variableInfo.variableLocation_.getElement(i)))>>) {
193-
dataBuffer[i] = static_cast<int>(get<vertexType>(variableInfo.variableLocation_.getElement(i)));
192+
if constexpr (std::is_same_v<
193+
vertexType,
194+
std::decay_t<decltype(get<vertexType>(
195+
variableInfo.variableLocation_.getElement(i)))>>) {
196+
dataBuffer[i] = static_cast<int>(
197+
get<vertexType>(variableInfo.variableLocation_.getElement(i)));
194198
} else {
195199
dataBuffer[i] = get<int>(variableInfo.variableLocation_.getElement(i));
196200
}

Simulator/Recorders/Hdf5Recorder.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
#include "H5Cpp.h"
55
#include "Model.h"
66
#include "Recorder.h"
7-
87
#include <fstream>
98
#include <vector>
109

@@ -117,8 +116,7 @@ class Hdf5Recorder : public Recorder {
117116
hdf5Datatype_ = PredType::NATIVE_DOUBLE;
118117
} else if (dataType_ == typeid(vertexType).name()) {
119118
hdf5Datatype_ = PredType::NATIVE_INT;
120-
}
121-
else {
119+
} else {
122120
throw runtime_error("Unsupported data type");
123121
}
124122
}
@@ -140,8 +138,9 @@ class Hdf5Recorder : public Recorder {
140138
} else if (hdf5Datatype_ == PredType::NATIVE_INT) {
141139
vector<int> dataBuffer(variableLocation_.getNumElements());
142140
for (int i = 0; i < variableLocation_.getNumElements(); ++i) {
143-
if constexpr (std::is_same_v<vertexType, std::decay_t<decltype(get<vertexType>(variableLocation_.getElement(i)))>>) {
144-
dataBuffer[i] = static_cast<int>(get<vertexType>(variableLocation_.getElement(i)));;
141+
if constexpr (std::is_same_v<vertexType, std::decay_t<decltype(get<vertexType>
142+
(variableLocation_.getElement(i)))>>) {
143+
dataBuffer[i] = static_cast<int>(get<vertexType>(variableLocation_.getElement(i)));
145144
} else {
146145
dataBuffer[i] = get<int>(variableLocation_.getElement(i));
147146
}

Simulator/Utils/Global.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// Globally available functions and default parameter values.
99

1010
#pragma once
11-
#include "MTRand.h"
11+
#include "MTRand.h"
1212

1313
// Debug output is included in both debug/release builds now.
1414
// The Default for debug is "LOW" and "OFF" for Release.

Simulator/Utils/VertexType.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ enum class vertexType {
3939
inline std::ostream &operator<<(std::ostream &os, vertexType vT)
4040
{
4141
os << static_cast<int>(vT);
42-
return os;
42+
return os;
4343
}
4444

45-
#endif // VERTEX_TYPE_H
45+
#endif // VERTEX_TYPE_H

Testing/UnitTesting/Hdf5RecorderTests.cpp

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -106,15 +106,15 @@ TEST(Hdf5RecorderTest, RegisterVertexTypeTest)
106106
// Create a vector of NeuronType enums
107107
RecordableVector<vertexType> neuronTypes;
108108
neuronTypes.resize(2);
109-
neuronTypes[0] = vertexType::EXC;
110-
neuronTypes[1] = vertexType::INH;
109+
neuronTypes[0] = vertexType::EXC;
110+
neuronTypes[1] = vertexType::INH;
111111

112112
// register the vector of NeuronTypes
113113
recorder.registerVariable("neuron_types", neuronTypes, Recorder::UpdatedType::DYNAMIC);
114114

115115
// Verify that the registered variables are stored correctly
116116
const auto &variableTable = recorder.getVariableTable();
117-
ASSERT_EQ(1, variableTable.size()); // Only one variable, "neuron_types"
117+
ASSERT_EQ(1, variableTable.size()); // Only one variable, "neuron_types"
118118

119119
// Verify that the registered variable name matches
120120
ASSERT_EQ("neuron_types", variableTable[0].variableName_);
@@ -182,9 +182,9 @@ TEST(Hdf5RecorderTest, SaveSimDataVertexTypeTest)
182182
// Create and configure RecordableVector<vertexType> for testing
183183
RecordableVector<vertexType> neuronTypes;
184184
neuronTypes.resize(3);
185-
neuronTypes[0] = vertexType::EXC;
186-
neuronTypes[1] = vertexType::INH;
187-
neuronTypes[2] = vertexType::EXC;
185+
neuronTypes[0] = vertexType::EXC;
186+
neuronTypes[1] = vertexType::INH;
187+
neuronTypes[2] = vertexType::EXC;
188188

189189
// Register the variable with Hdf5Recorder
190190
recorder.registerVariable("neuron_types", neuronTypes, Recorder::UpdatedType::CONSTANT);
@@ -205,10 +205,9 @@ TEST(Hdf5RecorderTest, SaveSimDataVertexTypeTest)
205205
dataset.read(dataBuffer.data(), PredType::NATIVE_INT);
206206

207207
// Verify the data matches the expected NeuronType values (converted to int)
208-
vector<int> expectedData = {static_cast<int>(vertexType::EXC),
209-
static_cast<int>(vertexType::INH),
208+
vector<int> expectedData = {static_cast<int>(vertexType::EXC), static_cast<int>(vertexType::INH),
210209
static_cast<int>(vertexType::EXC)};
211-
210+
212211
ASSERT_EQ(expectedData.size(), dataBuffer.size());
213212
for (size_t i = 0; i < expectedData.size(); ++i) {
214213
EXPECT_EQ(expectedData[i], dataBuffer[i]);
@@ -288,7 +287,7 @@ TEST(Hdf5RecorderTest, CompileHistoriesVertexTypeTest)
288287

289288
// Call compileHistories() multiple times to simulate multiple epochs
290289
for (int epoch = 0; epoch < 3; ++epoch) {
291-
// Clear and insert new NeuronType values
290+
// Clear and insert new NeuronType values
292291
eventBufferNeuron.clear();
293292
eventBufferNeuron.insertEvent(static_cast<int>(vertexType::EXC));
294293
eventBufferNeuron.insertEvent(static_cast<int>(vertexType::INH));

Testing/UnitTesting/XmlRecorderTests.cpp

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ TEST(XmlRecorderTest, RegisterVectorVertexTypeTest)
105105
// Create an instance of XmlRecorder
106106
XmlRecorder recorder;
107107

108-
// Create a RecordableVector<vertexType>
108+
// Create a RecordableVector<vertexType>
109109
RecordableVector<vertexType> vertTypes;
110110
vertTypes.resize(2);
111111
vertTypes[0] = vertexType::EXC;
@@ -170,7 +170,8 @@ TEST(XmlRecorderTest, CompileHistoriesTest)
170170

171171
// Call the compileHistories method
172172
recorderTest_->compileHistories();
173-
vector<std::variant<uint64_t, bool, int, BGFLOAT, vertexType>> history = recorderTest_->getHistory(0);
173+
vector<std::variant<uint64_t, bool, int, BGFLOAT, vertexType>> history
174+
= recorderTest_->getHistory(0);
174175

175176
// Verify the events compiled hisotry
176177
uint64_t data = 1;
@@ -198,7 +199,9 @@ TEST(XmlRecorderTest, ToXML)
198199
// Verify the expected XML output
199200
stringstream os;
200201
os << "<Matrix ";
201-
os << "name=\"" << "TestVar" << "\" ";
202+
os << "name=\""
203+
<< "TestVar"
204+
<< "\" ";
202205
os << "type=\"complete\" rows=\"" << 1 << "\" columns=\"" << variableHistory.size()
203206
<< "\" multiplier=\"1.0\">" << endl;
204207
os << " ";
@@ -261,19 +264,19 @@ TEST(XmlRecorderTest, SaveSimDataVertexTypeTest)
261264
{
262265
std::string outputFile = "../Testing/UnitTesting/TestOutput/test_vertex_type.xml";
263266
unique_ptr<XmlRecorder> recorderTest_(new XmlRecorder(outputFile));
264-
265-
// Create a recordable vector
267+
268+
// Create a recordable vector
266269
RecordableVector<vertexType> vertTypes;
267270
vertTypes.resize(2);
268-
vertTypes[0] = vertexType::EXC;
269-
vertTypes[1] = vertexType::INH;
271+
vertTypes[0] = vertexType::EXC;
272+
vertTypes[1] = vertexType::INH;
270273

271274
// Register the RecordableVector of VertexTypes
272275
recorderTest_->registerVariable("VertexTypes", vertTypes, Recorder::UpdatedType::DYNAMIC);
273276

274277
// initialize the XmlRecorder object
275278
recorderTest_->init();
276-
279+
277280
// Call the compileHistories method
278281
recorderTest_->compileHistories();
279282
// Call the saveSimData() function
@@ -284,15 +287,16 @@ TEST(XmlRecorderTest, SaveSimDataVertexTypeTest)
284287
std::stringstream outputBuffer;
285288
outputBuffer << inputFile.rdbuf();
286289
inputFile.close();
287-
290+
288291
// checks for saving simulation data
289292
vector<std::variant<uint64_t, bool, int, BGFLOAT, vertexType>> mock_history
290293
= {vertexType::EXC, vertexType::INH};
291294

292295
std::string expect_header = "<?xml version=\"1.0\" standalone=\"no\"?>\n";
293296
std::string expect_end = "\n";
294297
std::string expectXML
295-
= expect_header + recorderTest_->getToXML("VertexTypes", mock_history, typeid(vertexType).name())
298+
= expect_header
299+
+ recorderTest_->getToXML("VertexTypes", mock_history, typeid(vertexType).name())
296300
+ expect_end;
297301
// Vertify the output string
298302
ASSERT_EQ(outputBuffer.str(), expectXML);

0 commit comments

Comments
 (0)