Skip to content

Commit 68f5d6f

Browse files
tidy
1 parent d724578 commit 68f5d6f

6 files changed

Lines changed: 45 additions & 35 deletions

File tree

include/geode/stochastic/inference/target_statistics.hpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
*/
2323
#pragma once
2424
#include <geode/basic/uuid.hpp>
25+
#include <geode/stochastic/models/model.hpp>
2526

2627
namespace geode
2728
{
@@ -49,27 +50,27 @@ namespace geode
4950
}
5051
}
5152

52-
const Model< ObjectType >& model() const
53+
[[nodiscard]] const Model< ObjectType >& model() const
5354
{
5455
return model_;
5556
}
5657

57-
bool has_target( const uuid& term_uuid ) const
58+
[[nodiscard]] bool has_target( const uuid& term_uuid ) const
5859
{
5960
return active_[model_.term_index( term_uuid )];
6061
}
6162

62-
double target( const uuid& term_uuid ) const
63+
[[nodiscard]] double target( const uuid& term_uuid ) const
6364
{
6465
return values_[model_.term_index( term_uuid )];
6566
}
6667

67-
double tolerance( const uuid& term_uuid ) const
68+
[[nodiscard]] double tolerance( const uuid& term_uuid ) const
6869
{
6970
return tolerances_[model_.term_index( term_uuid )];
7071
}
7172

72-
std::vector< uuid > active_terms() const
73+
[[nodiscard]] std::vector< uuid > active_terms() const
7374
{
7475
std::vector< uuid > active_terms_uuid;
7576

include/geode/stochastic/models/model.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ namespace geode
5454

5555
public:
5656
Model() = delete;
57-
Model( EnergyTermCollection< ObjectType >&& energy_terms )
57+
~Model() = default;
58+
59+
explicit Model( EnergyTermCollection< ObjectType >&& energy_terms )
5860
: terms_collection_( std::move( energy_terms ) ),
5961
energy_{ terms_collection_ }
6062
{

include/geode/stochastic/sampling/mcmc/proposal/object_set_dynamic_config.hpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,14 @@
2222
*/
2323

2424
#pragma once
25+
26+
#include <string>
27+
2528
namespace geode
2629
{
2730
struct ObjectSetDynamicsConfig
2831
{
29-
std::string name;
32+
std::string name{};
3033

3134
double birth_ratio = 1.0;
3235
double death_ratio = 1.0;

include/geode/stochastic/sampling/mcmc/simulation_runner.hpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,17 @@ namespace geode
3333
namespace detail
3434
{
3535
// NOLINTBEGIN(*-magic-numbers)
36-
constexpr index_t default_realizations{ 1000 };
37-
constexpr index_t default_simulation_steps{ 1000 };
38-
constexpr index_t default_burn_in_steps{ 1000 };
36+
constexpr index_t DEFAULT_REALIZATIONS{ 1000 };
37+
constexpr index_t DEFAULT_SIMULATION_STEPS{ 1000 };
38+
constexpr index_t DEFAULT_BURN_IN_STEPS{ 1000 };
3939
// NOLINTEND(*-magic-numbers)
4040
} // namespace detail
4141

4242
struct SimulationConfigurator
4343
{
44-
index_t realizations{ detail::default_realizations };
45-
index_t metropolis_hasting_steps{ detail::default_simulation_steps };
46-
index_t burn_in_steps{ detail::default_burn_in_steps };
44+
index_t realizations{ detail::DEFAULT_REALIZATIONS };
45+
index_t metropolis_hasting_steps{ detail::DEFAULT_SIMULATION_STEPS };
46+
index_t burn_in_steps{ detail::DEFAULT_BURN_IN_STEPS };
4747

4848
std::optional< SimulationPrinterConfigurator > printer{ std::nullopt };
4949

@@ -73,7 +73,7 @@ namespace geode
7373
public:
7474
SimulationRunner() = delete;
7575
explicit SimulationRunner( SimulationContext< ObjectType >&& context )
76-
: context_( std::move( context ) ) {};
76+
: context_( std::move( context ) ){};
7777
virtual ~SimulationRunner() = default;
7878

7979
[[nodiscard]] const ObjectSets< ObjectType >& run(

include/geode/stochastic/spatial/object_sets.hpp

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -65,36 +65,40 @@ namespace geode
6565
ObjectSets( ObjectSets&& ) noexcept = default;
6666
ObjectSets& operator=( ObjectSets&& ) noexcept = default;
6767

68-
const ObjectSet< Type >& get_set( const uuid& set_id ) const;
69-
const Type& get_object( const ObjectId& object_id ) const;
70-
std::vector< ObjectId > get_all_object() const;
71-
std::vector< ObjectId > get_objects_in_set( const uuid& set_id ) const;
72-
73-
index_t nb_sets() const;
74-
index_t nb_objects_in_set( const uuid& set_id ) const;
75-
index_t nb_objects() const;
76-
77-
uuid add_set( std::string_view name );
78-
ObjectId add_object( Type&& object, const uuid& set_id, bool fixed );
79-
void update_free_object( const ObjectId& object_id, Type&& object );
80-
void remove_free_object( const ObjectId& object_id );
81-
82-
std::vector< ObjectId > neighbors( const Type& object,
68+
[[nodiscard]] const ObjectSet< Type >& get_set(
69+
const uuid& set_id ) const;
70+
[[nodiscard]] const Type& get_object( const ObjectId& object_id ) const;
71+
[[nodiscard]] std::vector< ObjectId > get_all_object() const;
72+
[[nodiscard]] std::vector< ObjectId > get_objects_in_set(
73+
const uuid& set_id ) const;
74+
75+
[[nodiscard]] index_t nb_sets() const;
76+
[[nodiscard]] index_t nb_objects_in_set( const uuid& set_id ) const;
77+
[[nodiscard]] index_t nb_objects() const;
78+
79+
[[nodiscard]] uuid add_set( std::string_view name );
80+
[[nodiscard]] ObjectId add_object(
81+
Type&& object, const uuid& set_id, bool fixed );
82+
[[nodiscard]] void update_free_object(
83+
const ObjectId& object_id, Type&& object );
84+
[[nodiscard]] void remove_free_object( const ObjectId& object_id );
85+
86+
[[nodiscard]] std::vector< ObjectId > neighbors( const Type& object,
8387
const std::vector< uuid >& targeted_set_ids,
8488
double searching_distance,
8589
std::optional< ObjectId > exclude_id ) const;
8690

87-
std::string string() const;
91+
[[nodiscard]] std::string string() const;
8892

89-
uuid get_set_uuid( std::string_view set_name ) const;
90-
std::vector< uuid > get_set_uuids(
93+
[[nodiscard]] uuid get_set_uuid( std::string_view set_name ) const;
94+
[[nodiscard]] std::vector< uuid > get_set_uuids(
9195
const std::vector< std::string >& set_names ) const;
92-
std::vector< std::pair< uuid, uuid > > get_set_uuid_pairs(
96+
[[nodiscard]] std::vector< std::pair< uuid, uuid > > get_set_uuid_pairs(
9397
const std::vector< std::pair< std::string, std::string > >&
9498
set_name_pairs ) const;
9599

96100
private:
97-
ObjectSet< Type >& get_set( const uuid& set_id );
101+
[[nodiscard]] ObjectSet< Type >& get_set( const uuid& set_id );
98102

99103
private:
100104
absl::flat_hash_map< std::string, uuid > name_to_uuid_;

tests/stochastic/sampling/mcmc/test-mh-poisson.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,6 @@ namespace
179179
sim_config.metropolis_hasting_steps = 1000;
180180
sim_config.burn_in_steps = 3000;
181181
sim_config.printer = printer_config;
182-
// NOLINTEND(*-magic-numbers)
183182

184183
auto statistic_tracker = runner.run( engine, sim_config );
185184

@@ -191,6 +190,7 @@ namespace
191190
targeted_statistics_descriptors.push_back( stat02 );
192191
geode::TargetStatisticConfig stat03{ "density03", 30.0, 0.15 };
193192
targeted_statistics_descriptors.push_back( stat03 );
193+
// NOLINTEND(*-magic-numbers)
194194

195195
geode::TargetStatistics target_stats{ runner.model(),
196196
targeted_statistics_descriptors };

0 commit comments

Comments
 (0)