Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix multiple different code smells #417

Merged
merged 13 commits into from
Oct 31, 2023
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,13 @@ class LoadGen final : public std::conditional_t<is_gen, GenericGenerator, Generi
using InputType = LoadGenInput<sym>;
using UpdateType = LoadGenUpdate<sym>;
using BaseClass = std::conditional_t<is_gen, GenericGenerator, GenericLoad>;
static constexpr char const* name = sym ? (is_gen ? "sym_gen" : "sym_load") : (is_gen ? "asym_gen" : "asym_load");
static constexpr char const* name = [] {
if constexpr (sym) {
return is_gen ? "sym_gen" : "sym_load";
} else {
return is_gen ? "asym_gen" : "asym_load";
}
}();

LoadGen(LoadGenInput<sym> const& load_gen_input, double u) : BaseClass{load_gen_input, u} {
set_power(load_gen_input.p_specified, load_gen_input.q_specified);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,14 @@ namespace power_grid_model::math_model_impl {

template <scalar_value T, bool sym, bool is_tensor, int n_sub_block> struct block_trait {
static constexpr int n_row = sym ? n_sub_block : n_sub_block * 3;
static constexpr int n_col = is_tensor ? (sym ? n_sub_block : n_sub_block * 3) : 1;
static constexpr int n_col = [] {
if constexpr (is_tensor) {
return sym ? n_sub_block : n_sub_block * 3;
} else {
return 1;
}
}();

using ArrayType = Eigen::Array<T, n_row, n_col, Eigen::ColMajor>;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ struct YBusStructure {
}
// all entries in the same position are looped, append indptr
// need to be offset by fill-in
y_bus_entry_indptr.push_back(static_cast<Idx>(it_element - vec_map_element.cbegin()) - fill_in_counter);
y_bus_entry_indptr.push_back((it_element - vec_map_element.cbegin()) - fill_in_counter);
// iterate linear nnz
++nnz_counter;
++nnz_counter_lu;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class Topology {
// assign node to math group
// append node to dfs list
void discover_vertex(GlobalGraph::vertex_descriptor u, GlobalGraph const& /* unused_value */) {
node_coupling_[u].group = static_cast<Idx>(math_group_);
node_coupling_[u].group = math_group_;
dfs_node_.push_back(static_cast<Idx>(u));
}

Expand Down