Skip to content

Commit 9eb4f47

Browse files
committed
utils_aux.cc tidy
1 parent 705cd8e commit 9eb4f47

File tree

7 files changed

+90
-224
lines changed

7 files changed

+90
-224
lines changed

bdm.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ interval = 7200
44

55
[[visualize_agent]]
66
name = "TumorCell"
7-
additional_data_members = ["diameter_","volume_", "type_"]
7+
additional_data_members = [
8+
{name = "diameter_", function = "diameter_"},
9+
{name = "volume_", function = "volume_"},
10+
{name = "cell_type", function = "GetTypeAsInt"}
11+
]
812

913
[[visualize_diffusion]]
1014
name = "oxygen"

clang_output.txt

Lines changed: 0 additions & 177 deletions
Original file line numberDiff line numberDiff line change
@@ -1,177 +0,0 @@
1-
102264 warnings generated.
2-
src/utils_aux.cc: clang-tidy-18 -p=build -line-filter=[{\"name\":\"src/cart_cell.cc\",\"lines\":[[1,321]]},{\"name\":\"src/cart_cell.h\",\"lines\":[[1,250]]},{\"name\":\"src/cart_tumor.cc\",\"lines\":[[1,133]]},{\"name\":\"src/cart_tumor.h\",\"lines\":[[1,36]]},{\"name\":\"src/diffusion_thomas_algorithm.cc\",\"lines\":[[1,319]]},{\"name\":\"src/diffusion_thomas_algorithm.h\",\"lines\":[[1,194]]},{\"name\":\"src/forces_tumor_cart.cc\",\"lines\":[[1,163]]},{\"name\":\"src/forces_tumor_cart.h\",\"lines\":[[1,60]]},{\"name\":\"src/hyperparams.h\",\"lines\":[[1,216]]},{\"name\":\"src/tumor_cell.cc\",\"lines\":[[1,673]]},{\"name\":\"src/tumor_cell.h\",\"lines\":[[1,301]]},{\"name\":\"src/utils_aux.cc\",\"lines\":[[1,176]]},{\"name\":\"src/utils_aux.h\",\"lines\":[[1,96]]}] --enable-check-profile -store-check-profile=clang-tidy-review-profile --config-file=.clang-tidy --export-fixes=/tmp/tmpb2o1s_sd/tmp_xr510k8.yaml src/utils_aux.cc
3-
Suppressed 102378 warnings (102216 in non-user code, 162 NOLINT).
4-
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
5-
/github/workspace/src/utils_aux.cc:23:1: warning: #includes are not sorted properly [llvm-include-order]
6-
23 | #include <cmath>
7-
| ^ ~~~~~~~
8-
| "hyperparams.h"
9-
24 | #include <fstream>
10-
| ~~~~~~~~~
11-
| "tumor_cell.h"
12-
25 | #include <tuple>
13-
| ~~~~~~~
14-
| <cmath>
15-
26 | #include <vector>
16-
| ~~~~~~~~
17-
| <fstream>
18-
27 | #include "hyperparams.h"
19-
| ~~~~~~~~~~~~~~~
20-
| <tuple>
21-
28 | #include "tumor_cell.h"
22-
| ~~~~~~~~~~~~~~
23-
| <vector>
24-
/github/workspace/src/utils_aux.cc:34:1: warning: no header providing "bdm::real_t" is directly included [misc-include-cleaner]
25-
27 | #include "hyperparams.h"
26-
28 | #include "tumor_cell.h"
27-
29 |
28-
30 | namespace bdm {
29-
31 |
30-
32 | // Samples a Gaussian value with given mean and standard deviation but all
31-
33 | // negative values are mapped to zero
32-
34 | real_t SamplePositiveGaussian(float mean, float sigma) {
33-
| ^
34-
/github/workspace/src/utils_aux.cc:43:13: warning: no header providing "bdm::Real3" is directly included [misc-include-cleaner]
35-
27 | std::vector<Real3> CreateSphereOfTumorCells(real_t sphere_radius) {
36-
| ^
37-
/github/workspace/src/utils_aux.cc:45:3: warning: variable 'cell_radius' of type 'real_t' (aka 'double') can be declared 'const' [misc-const-correctness]
38-
45 | real_t cell_radius =
39-
| ^
40-
| const
41-
/github/workspace/src/utils_aux.cc:46:46: warning: 6 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
42-
46 | std::cbrt(kDefaultVolumeNewTumorCell * 6 / Math::kPi) / 2;
43-
| ^
44-
/github/workspace/src/utils_aux.cc:46:50: warning: no header providing "bdm::Math" is directly included [misc-include-cleaner]
45-
27 | std::cbrt(kDefaultVolumeNewTumorCell * 6 / Math::kPi) / 2;
46-
| ^
47-
/github/workspace/src/utils_aux.cc:51:3: warning: variable 'spacing_x' of type 'real_t' (aka 'double') can be declared 'const' [misc-const-correctness]
48-
51 | real_t spacing_x = cell_radius * std::sqrt(3.0);
49-
| ^
50-
| const
51-
/github/workspace/src/utils_aux.cc:51:46: warning: 3.0 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
52-
51 | real_t spacing_x = cell_radius * std::sqrt(3.0);
53-
| ^
54-
/github/workspace/src/utils_aux.cc:52:3: warning: variable 'spacing_y' of type 'real_t' (aka 'double') can be declared 'const' [misc-const-correctness]
55-
52 | real_t spacing_y = cell_radius * 2.0;
56-
| ^
57-
| const
58-
/github/workspace/src/utils_aux.cc:52:36: warning: 2.0 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
59-
52 | real_t spacing_y = cell_radius * 2.0;
60-
| ^
61-
/github/workspace/src/utils_aux.cc:53:3: warning: variable 'spacing_z' of type 'real_t' (aka 'double') can be declared 'const' [misc-const-correctness]
62-
53 | real_t spacing_z = cell_radius * std::sqrt(3.0);
63-
| ^
64-
| const
65-
/github/workspace/src/utils_aux.cc:53:46: warning: 3.0 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
66-
53 | real_t spacing_z = cell_radius * std::sqrt(3.0);
67-
| ^
68-
/github/workspace/src/utils_aux.cc:56:3: warning: Variable 'z' with floating point type 'real_t' should not be used as a loop counter [clang-analyzer-security.FloatLoopCounter]
69-
56 | for (real_t z = -sphere_radius; z < sphere_radius; z += spacing_z, ++zc) {
70-
| ^ ~ ~
71-
/github/workspace/src/utils_aux.cc:56:3: note: Variable 'z' with floating point type 'real_t' should not be used as a loop counter
72-
56 | for (real_t z = -sphere_radius; z < sphere_radius; z += spacing_z, ++zc) {
73-
| ^ ~ ~
74-
/github/workspace/src/utils_aux.cc:58:5: warning: Variable 'x' with floating point type 'real_t' should not be used as a loop counter [clang-analyzer-security.FloatLoopCounter]
75-
58 | for (real_t x = -sphere_radius; x < sphere_radius; x += spacing_x, ++xc) {
76-
| ^ ~ ~
77-
/github/workspace/src/utils_aux.cc:58:5: note: Variable 'x' with floating point type 'real_t' should not be used as a loop counter
78-
58 | for (real_t x = -sphere_radius; x < sphere_radius; x += spacing_x, ++xc) {
79-
| ^ ~ ~
80-
/github/workspace/src/utils_aux.cc:60:7: warning: Variable 'y' with floating point type 'real_t' should not be used as a loop counter [clang-analyzer-security.FloatLoopCounter]
81-
60 | for (real_t y = -sphere_radius; y < sphere_radius; y += spacing_y, ++yc) {
82-
| ^ ~ ~
83-
/github/workspace/src/utils_aux.cc:60:7: note: Variable 'y' with floating point type 'real_t' should not be used as a loop counter
84-
60 | for (real_t y = -sphere_radius; y < sphere_radius; y += spacing_y, ++yc) {
85-
| ^ ~ ~
86-
/github/workspace/src/utils_aux.cc:62:9: warning: variable 'px' of type 'real_t' (aka 'double') can be declared 'const' [misc-const-correctness]
87-
62 | real_t px = x + (zc % 2) * 0.5 * cell_radius;
88-
| ^
89-
| const
90-
/github/workspace/src/utils_aux.cc:62:36: warning: 0.5 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
91-
62 | real_t px = x + (zc % 2) * 0.5 * cell_radius;
92-
| ^
93-
/github/workspace/src/utils_aux.cc:63:9: warning: variable 'py' of type 'real_t' (aka 'double') can be declared 'const' [misc-const-correctness]
94-
63 | real_t py = y + (xc % 2) * cell_radius;
95-
| ^
96-
| const
97-
/github/workspace/src/utils_aux.cc:64:9: warning: variable 'pz' of type 'real_t' (aka 'double') can be declared 'const' [misc-const-correctness]
98-
64 | real_t pz = z;
99-
| ^
100-
| const
101-
/github/workspace/src/utils_aux.cc:66:9: warning: variable 'dist' of type 'real_t' (aka 'double') can be declared 'const' [misc-const-correctness]
102-
66 | real_t dist = std::sqrt(px * px + py * py + pz * pz);
103-
| ^
104-
| const
105-
/github/workspace/src/utils_aux.cc:80:12: warning: no header providing "size_t" is directly included [misc-include-cleaner]
106-
24 | std::tuple<size_t, size_t, size_t, size_t, size_t, size_t, real_t>
107-
| ^
108-
/github/workspace/src/utils_aux.cc:92:30: warning: no header providing "bdm::Agent" is directly included [misc-include-cleaner]
109-
27 | rm->ForEachAgent([&](const Agent* agent) {
110-
| ^
111-
/github/workspace/src/utils_aux.cc:93:9: warning: 'auto *tumor_cell' can be declared as 'const auto *tumor_cell' [readability-qualified-auto]
112-
93 | if (auto* tumor_cell = dynamic_cast<const TumorCell*>(agent)) {
113-
| ^
114-
| const
115-
/github/workspace/src/utils_aux.cc:96:7: warning: variable 'dist_sq' of type 'real_t' (aka 'double') can be declared 'const' [misc-const-correctness]
116-
96 | real_t dist_sq = pos[0] * pos[0] + pos[1] * pos[1] + pos[2] * pos[2];
117-
| ^
118-
| const
119-
/github/workspace/src/utils_aux.cc:115:14: warning: 5 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
120-
115 | case 5:
121-
| ^
122-
/github/workspace/src/utils_aux.cc:135:54: warning: no header providing "std::ios" is directly included [misc-include-cleaner]
123-
25 | std::ofstream file("output/final_data.csv", std::ios::app);
124-
| ^
125-
/github/workspace/src/utils_aux.cc:148:7: warning: variable 'total_minutes' of type 'double' can be declared 'const' [misc-const-correctness]
126-
148 | double total_minutes =
127-
| ^
128-
| const
129-
/github/workspace/src/utils_aux.cc:150:7: warning: variable 'total_hours' of type 'double' can be declared 'const' [misc-const-correctness]
130-
150 | double total_hours = total_minutes / 60.0;
131-
| ^
132-
| const
133-
/github/workspace/src/utils_aux.cc:150:44: warning: 60.0 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
134-
150 | double total_hours = total_minutes / 60.0;
135-
| ^
136-
/github/workspace/src/utils_aux.cc:151:7: warning: variable 'total_days' of type 'double' can be declared 'const' [misc-const-correctness]
137-
151 | double total_days = total_hours / 24.0;
138-
| ^
139-
| const
140-
/github/workspace/src/utils_aux.cc:151:41: warning: 24.0 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
141-
151 | double total_days = total_hours / 24.0;
142-
| ^
143-
/github/workspace/src/utils_aux.cc:154:14: warning: variable 'total_num_tumor_cells' is not initialized [cppcoreguidelines-init-variables]
144-
154 | size_t total_num_tumor_cells;
145-
| ^
146-
| = 0
147-
/github/workspace/src/utils_aux.cc:155:7: warning: multiple declarations in a single statement reduces readability [readability-isolate-declaration]
148-
155 | size_t num_tumor_cells_type1, num_tumor_cells_type2,
149-
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
150-
156 | num_tumor_cells_type3, num_tumor_cells_type4,
151-
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
152-
157 | num_tumor_cells_type5_dead;
153-
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~
154-
/github/workspace/src/utils_aux.cc:155:14: warning: variable 'num_tumor_cells_type1' is not initialized [cppcoreguidelines-init-variables]
155-
155 | size_t num_tumor_cells_type1, num_tumor_cells_type2,
156-
| ^
157-
note: this fix will not be applied because it overlaps with another fix
158-
/github/workspace/src/utils_aux.cc:155:37: warning: variable 'num_tumor_cells_type2' is not initialized [cppcoreguidelines-init-variables]
159-
155 | size_t num_tumor_cells_type1, num_tumor_cells_type2,
160-
| ^
161-
note: this fix will not be applied because it overlaps with another fix
162-
/github/workspace/src/utils_aux.cc:156:11: warning: variable 'num_tumor_cells_type3' is not initialized [cppcoreguidelines-init-variables]
163-
156 | num_tumor_cells_type3, num_tumor_cells_type4,
164-
| ^
165-
note: this fix will not be applied because it overlaps with another fix
166-
/github/workspace/src/utils_aux.cc:156:34: warning: variable 'num_tumor_cells_type4' is not initialized [cppcoreguidelines-init-variables]
167-
156 | num_tumor_cells_type3, num_tumor_cells_type4,
168-
| ^
169-
note: this fix will not be applied because it overlaps with another fix
170-
/github/workspace/src/utils_aux.cc:157:11: warning: variable 'num_tumor_cells_type5_dead' is not initialized [cppcoreguidelines-init-variables]
171-
157 | num_tumor_cells_type5_dead;
172-
| ^
173-
note: this fix will not be applied because it overlaps with another fix
174-
/github/workspace/src/utils_aux.cc:158:14: warning: variable 'tumor_radius' is not initialized [cppcoreguidelines-init-variables]
175-
23 | real_t tumor_radius;
176-
| ^
177-
| = NAN

src/diffusion_thomas_algorithm.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ DiffusionThomasAlgorithm::DiffusionThomasAlgorithm(
4646
jump_k_(static_cast<int>(resolution_ * resolution_)),
4747
constant1_(dc * dt / (d_space_ * d_space_)),
4848
constant1a_(-constant1_),
49-
constant2_(mu * dt / kDirectionsDivisor),
49+
constant2_(mu * dt / 3.0),// NOLINT(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers)
5050
constant3_(1.0 + 2 * constant1_ + constant2_),
5151
constant3a_(1.0 + constant1_ + constant2_),
5252
thomas_c_x_(resolution_, constant1a_),

src/hyperparams.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ constexpr real_t kVolumeRelaxarionRateFluidNecroticLysed = 0.050 / 60.0;
9494
constexpr real_t kThresholdCancerCellType1 = 1.5;
9595
constexpr real_t kThresholdCancerCellType2 = 1.0;
9696
constexpr real_t kThresholdCancerCellType3 = 0.5;
97+
constexpr real_t kThresholdCancerCellType4 = 0.0;
9798

9899
///
99100
/// General Hyperparameters
@@ -191,8 +192,6 @@ constexpr real_t kAdhesionCartCart = 0.0;
191192
constexpr real_t kAdhesionCartTumor = 0.0;
192193
/// Adhesion coeficient between tumor cells and CAR-T cells
193194
constexpr real_t kAdhesionTumorCart = 0.0;
194-
/// Divisor for dividing directions
195-
constexpr real_t kDirectionsDivisor = 3.0;
196195

197196
/// Do not change
198197
// coefficientes for the two step Adams-Bashforth approximation of the time

src/tumor_cell.cc

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ TumorCell::TumorCell(const Real3& position)
5151
target_nucleus_solid_(0.0),
5252
target_fraction_fluid_(0.0),
5353
target_relation_cytoplasm_nucleus_(0.0),
54-
type_(0),
54+
type_(TumorCellType::kType0),
5555
older_velocity_{0, 0, 0},
5656
oxygen_consumption_rate_(0.0),
5757
immunostimulatory_factor_secretion_rate_(0.0),
@@ -174,13 +174,15 @@ void TumorCell::SetOncoproteineLevel(real_t level) {
174174
oncoproteine_level_ = level; // oncoproteine_level_
175175
// cell type
176176
if (level >= kThresholdCancerCellType1) { // between 1.5 and 2.0
177-
type_ = 1;
177+
type_ = TumorCellType::kType1;
178178
} else if (level >= kThresholdCancerCellType2 && level < kThresholdCancerCellType1) {
179-
type_ = 2;
179+
type_ = TumorCellType::kType2;
180180
} else if (level >= kThresholdCancerCellType3 && level < kThresholdCancerCellType2) {
181-
type_ = 3;
182-
} else { // between 0.0 and 0.5
183-
type_ = 4;
181+
type_ = TumorCellType::kType3;
182+
} else if (level >= kThresholdCancerCellType4 && level < kThresholdCancerCellType3) {
183+
type_ = TumorCellType::kType4;
184+
} else { // undefined type
185+
type_ = TumorCellType::kType0;
184186
}
185187
}
186188

@@ -694,7 +696,7 @@ bool StateControlGrowProliferate::ShouldEnterNecrosis(real_t oxygen_level,
694696
cell->SetTargetFractionFluid(1.0); // Set target fraction of fluid to 1.0
695697
cell->SetTargetRelationCytoplasmNucleus(0.0);
696698
// Set type to 5 to indicate dead cell
697-
cell->SetType(5); // NOLINT(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers)
699+
cell->SetType(TumorCellType::kType5);
698700
}
699701
return enter_necrosis; // Return whether the cell entered necrosis
700702
}

src/tumor_cell.h

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424

2525
#include "core/util/root.h"
2626
#include "core/agent/agent.h"
27-
#include "core/agent/agent.h" // Ensure bdm::Agent is directly included
2827
#include "core/agent/cell.h"
2928
#include "core/behavior/behavior.h"
3029
#include "core/diffusion/diffusion_grid.h"
@@ -58,6 +57,26 @@ enum class TumorCellState : int {
5857
///< controlled form of cell death.
5958
};
6059

60+
/// Enumeration representing the different types of tumor cells
61+
///
62+
/// This enum class defines the various types of tumor cells depending on their
63+
/// agressiveness from 1 (most agressive) until 4 (least agressive) based on the
64+
/// expressed oncoprotein level. Type 5 cells are dead cells
65+
enum class TumorCellType : int {
66+
kType0 =
67+
0, ///< Unclassified tumor cells
68+
kType1 =
69+
1, ///< Most aggressive tumor cells
70+
kType2 =
71+
2, ///< Moderately aggressive tumor cells
72+
kType3 =
73+
3, ///< Less aggressive tumor cells
74+
kType4 =
75+
4, ///< Least aggressive tumor cells
76+
kType5 =
77+
5 ///< Dead tumor cells
78+
};
79+
6180
/// Tumor cell class implementation
6281
///
6382
/// This class represents a cancer cell that forms a heterogeneous tumor in the
@@ -88,7 +107,7 @@ class TumorCell : public Cell {
88107
target_nucleus_solid_(0.0),
89108
target_fraction_fluid_(0.0),
90109
target_relation_cytoplasm_nucleus_(0.0),
91-
type_(0),
110+
type_(TumorCellType::kType0),
92111
oxygen_consumption_rate_(0.0),
93112
immunostimulatory_factor_secretion_rate_(0.0),
94113
constant1_oxygen_(0.0),
@@ -159,8 +178,8 @@ class TumorCell : public Cell {
159178
void SetAttachedToCart(bool attached) { attached_to_cart_ = attached; }
160179
bool IsAttachedToCart() const { return attached_to_cart_; }
161180

162-
void SetType(int type) { type_ = type; }
163-
int GetType() const { return type_; }
181+
void SetType(TumorCellType type) { type_ = type; }
182+
TumorCellType GetType() const { return type_; }
164183

165184
Real3 GetOlderVelocity() const { return older_velocity_; }
166185
void SetOlderVelocity(const Real3& velocity) { older_velocity_ = velocity; }
@@ -179,6 +198,8 @@ class TumorCell : public Cell {
179198

180199
real_t GetTargetTotalVolume() const;
181200

201+
int GetTypeAsInt() const { return static_cast<int>(type_); }
202+
182203
/// Returns the diffusion grid for oxygen
183204
DiffusionGrid* GetOxygenDiffusionGrid() const { return oxygen_dgrid_; }
184205
/// Returns the diffusion grid for immunostimulatory factors
@@ -293,7 +314,7 @@ class TumorCell : public Cell {
293314
/// Types 1-4: 1 is the most mutated and proliferative type, 4 is the least
294315
/// aggressive. Type 5 means the cell is dead.
295316
// NOLINTNEXTLINE(readability-identifier-naming)
296-
int type_ = 0;
317+
TumorCellType type_ = TumorCellType::kType0;
297318

298319
/// Velocity of the cell in the previous time step
299320
// NOLINTNEXTLINE(readability-identifier-naming)

0 commit comments

Comments
 (0)