Skip to content

Commit 2544c32

Browse files
committed
add more braces
1 parent b444f33 commit 2544c32

File tree

5 files changed

+40
-23
lines changed

5 files changed

+40
-23
lines changed

multi_physics/QED/QED_tests/test_picsar_quantum_sync_tables.cpp

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -279,22 +279,24 @@ void check_photon_emission_table()
279279
for (const auto rr : rrs){
280280
auto res = table.interp(xx, rr);
281281
auto rxx = xx;
282-
if(rxx < chi_min) rxx = chi_min;
283-
if(rxx > chi_max) rxx = chi_max;
282+
if(rxx < chi_min) { rxx = chi_min; }
283+
if(rxx > chi_max) { rxx = chi_max; }
284284
auto expected = inverse_functor(std::array<RealType,2>{rxx, rr})*xx;
285-
if(expected < small<RealType>())
285+
if(expected < small<RealType>()){
286286
BOOST_CHECK_SMALL((res-expected)/expected, tolerance<RealType>());
287-
else
287+
}
288+
else{
288289
BOOST_CHECK_SMALL((res-expected), tolerance<RealType>());
289-
290+
}
290291
}
291292
}
292293

293294
const auto table_view = table.get_view();
294295

295296
for(auto xx : xxs){
296-
for (auto r : rrs)
297+
for (auto r : rrs){
297298
BOOST_CHECK_EQUAL(table_view.interp(xx,r ), table.interp(xx, r));
299+
}
298300
}
299301
}
300302

@@ -408,22 +410,25 @@ void check_tailopt_photon_emission_table()
408410
for (const auto rr : rrs){
409411
auto res = table.interp(xx, rr);
410412
auto rxx = xx;
411-
if(rxx < chi_min) rxx = chi_min;
412-
if(rxx > chi_max) rxx = chi_max;
413+
if(rxx < chi_min) { rxx = chi_min; }
414+
if(rxx > chi_max) { rxx = chi_max; }
413415
auto expected = inverse_functor(std::array<RealType,2>{rxx, rr})*xx;
414-
if(expected < small<RealType>())
416+
if(expected < small<RealType>()){
415417
BOOST_CHECK_SMALL((res-expected)/expected, tolerance<RealType>());
416-
else
418+
}
419+
else {
417420
BOOST_CHECK_SMALL((res-expected), tolerance<RealType>());
421+
}
418422

419423
}
420424
}
421425

422426
const auto table_view = table.get_view();
423427

424428
for(auto xx : xxs){
425-
for (auto r : rrs)
429+
for (auto r : rrs){
426430
BOOST_CHECK_EQUAL(table_view.interp(xx,r ), table.interp(xx, r));
431+
}
427432
}
428433

429434
}

multi_physics/QED/include/picsar_qed/containers/picsar_tables.hpp

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -347,9 +347,10 @@ namespace details{
347347
PXRMP_FORCE_INLINE
348348
void set_all_vals(const std::vector<RealType>& new_values)
349349
{
350-
if (new_values.size() != m_values.size())
350+
if (new_values.size() != m_values.size()){
351351
throw std::runtime_error("Mismatch new_values length \
352352
and m_values length");
353+
}
353354
std::copy(new_values.begin(), new_values.end(), m_values.begin());
354355
//VectorType may need a call to a user-defined method for CPU-GPU synchronization
355356
details::aux_sync_vec(m_values);
@@ -790,8 +791,9 @@ namespace details{
790791

791792
auto idx_left = static_cast<int>(
792793
m_floor((m_how_many_y-1)*(where_y-m_y_min)/m_y_size));
793-
if (idx_left == (m_how_many_y-1))
794+
if (idx_left == (m_how_many_y-1)){
794795
idx_left = m_how_many_y-2;
796+
}
795797
const auto idx_right = idx_left + 1;
796798

797799
const auto left_val = m_values[idx(i, idx_left)];
@@ -841,9 +843,10 @@ namespace details{
841843
PXRMP_FORCE_INLINE
842844
void set_all_vals(const std::vector<RealType>& new_values)
843845
{
844-
if (new_values.size() != m_values.size())
846+
if (new_values.size() != m_values.size()){
845847
throw std::runtime_error("Mismatch new_values length \
846848
and m_values length");
849+
}
847850
std::copy(new_values.begin(), new_values.end(), m_values.begin());
848851
//VectorType may need a call to a user-defined method for CPU-GPU synchronization
849852
details::aux_sync_vec(m_values);
@@ -994,10 +997,12 @@ namespace details{
994997
serialization::get_out<decltype(m_how_many_x)>(it_raw_data);
995998
m_how_many_y =
996999
serialization::get_out<decltype(m_how_many_y)>(it_raw_data);
997-
if(m_how_many_x <= 0)
1000+
if(m_how_many_x <= 0){
9981001
throw std::runtime_error("raw_data contains invalid data.");
999-
if(m_how_many_y <= 0)
1002+
}
1003+
if(m_how_many_y <= 0){
10001004
throw std::runtime_error("raw_data contains invalid data.");
1005+
}
10011006

10021007
//static_cast<int> here has the sole purpose of avoiding to trigger
10031008
//a CodeQL check in CI (Multiplication result converted to larger type)
@@ -1305,8 +1310,9 @@ namespace details{
13051310
using namespace picsar::multi_physics::math;
13061311

13071312
auto idx_left = m_iy_map_functor(where_y);
1308-
if (idx_left == (m_how_many_y-1))
1313+
if (idx_left == (m_how_many_y-1)){
13091314
idx_left = m_how_many_y-2;
1315+
}
13101316
const auto idx_right = idx_left + 1;
13111317

13121318
const auto left_val = m_values[idx(i, idx_left)];
@@ -1356,9 +1362,10 @@ namespace details{
13561362
PXRMP_FORCE_INLINE
13571363
void set_all_vals(const std::vector<RealType>& new_values)
13581364
{
1359-
if (new_values.size() != m_values.size())
1365+
if (new_values.size() != m_values.size()){
13601366
throw std::runtime_error("Mismatch new_values length \
13611367
and m_values length");
1368+
}
13621369
std::copy(new_values.begin(), new_values.end(), m_values.begin());
13631370
//VectorType may need a call to a user-defined method for CPU-GPU synchronization
13641371
details::aux_sync_vec(m_values);

multi_physics/QED/include/picsar_qed/physics/breit_wheeler/breit_wheeler_engine_tables_generator.hpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,9 @@ namespace breit_wheeler{
108108
}
109109

110110
for (auto& val : all_vals){
111-
if(std::isnan(val))
111+
if(std::isnan(val)){
112112
throw std::runtime_error("Error: nan detected in generated table!");
113+
}
113114
}
114115

115116
set_all_vals(all_vals);
@@ -222,8 +223,9 @@ namespace breit_wheeler{
222223
}
223224

224225
for (auto& val : all_vals){
225-
if(std::isnan(val))
226+
if(std::isnan(val)){
226227
throw std::runtime_error("Error: nan detected in generated table!");
228+
}
227229
}
228230

229231
set_all_vals(all_vals);

multi_physics/QED/include/picsar_qed/physics/quantum_sync/quantum_sync_engine_tables.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,8 +341,9 @@ namespace quantum_sync{
341341
const auto vals_length = vals.size();
342342
auto log_vals = std::vector<RealType>(vals_length);
343343

344-
if(static_cast<int>(vals_length) != m_table.get_how_many_x())
344+
if(static_cast<int>(vals_length) != m_table.get_how_many_x()){
345345
return false;
346+
}
346347

347348
std::transform(vals.begin(), vals.end(), log_vals.begin(),
348349
[](auto x){return math::m_log(x);});

multi_physics/QED/include/picsar_qed/physics/quantum_sync/quantum_sync_engine_tables_generator_detail.hpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,9 @@ namespace detail{
8282
}
8383

8484
for (const auto& val : all_vals){
85-
if(std::isnan(val))
85+
if(std::isnan(val)){
8686
throw std::runtime_error("Error: nan detected in generated table!");
87+
}
8788
}
8889

8990
auto t_end = std::chrono::system_clock::now();
@@ -173,8 +174,9 @@ namespace detail{
173174
}
174175

175176
for (const auto& val : all_vals){
176-
if(std::isnan(val))
177+
if(std::isnan(val)){
177178
throw std::runtime_error("Error: nan detected in generated table!");
179+
}
178180
}
179181

180182
auto t_end = std::chrono::system_clock::now();

0 commit comments

Comments
 (0)