Skip to content

Commit 18c8e8f

Browse files
Merge branch 'main' into feature/step-up-transformer-tap-changer-support
Signed-off-by: Jerry Guo <6221579+Jerry-Jinfeng-Guo@users.noreply.github.com>
2 parents f9c990c + 208a620 commit 18c8e8f

39 files changed

+234
-196
lines changed

.github/conda_pgm_env.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ dependencies:
1515
- nlohmann_json
1616
- msgpack-cxx
1717
- numpy
18+
- cmake
19+
- ninja
1820
# test deps
1921
- pytest
2022
- pytest-cov

.github/workflows/clang-tidy.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ concurrency:
4444

4545
jobs:
4646
clang-tidy:
47-
runs-on: ubuntu-22.04
47+
runs-on: ubuntu-24.04
4848
strategy:
4949
matrix:
5050
build-option: [ debug, release ]
@@ -60,10 +60,10 @@ jobs:
6060
- name: Install packages
6161
run: |
6262
sudo apt-get update
63-
sudo apt-get install -y ninja-build clang-15 clang-tidy-15
64-
sudo ln -s /usr/bin/clang-15 /usr/local/bin/clang
65-
sudo ln -s /usr/bin/clang++-15 /usr/local/bin/clang++
66-
sudo ln -s /usr/bin/clang-tidy-15 /usr/local/bin/clang-tidy
63+
sudo apt-get install -y ninja-build clang-18 clang-tidy-18
64+
sudo ln -s /usr/bin/clang-18 /usr/local/bin/clang
65+
sudo ln -s /usr/bin/clang++-18 /usr/local/bin/clang++
66+
sudo ln -s /usr/bin/clang-tidy-18 /usr/local/bin/clang-tidy
6767
6868
- name: Enable brew
6969
run: |

.github/workflows/main.yml

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -235,10 +235,18 @@ jobs:
235235
strategy:
236236
matrix:
237237
os: ["ubuntu", "windows"] # We do not test conda for MacOS
238-
238+
include:
239+
- os: ubuntu
240+
shell: bash -el {0}
241+
- os: windows
242+
shell: powershell
243+
244+
env:
245+
POWER_GRID_MODEL_NO_BINARY_BUILD: 1
246+
239247
defaults:
240248
run:
241-
shell: bash -el {0}
249+
shell: ${{ matrix.shell }}
242250
steps:
243251
- uses: actions/checkout@v4
244252

@@ -253,8 +261,26 @@ jobs:
253261
run: |
254262
conda info
255263
conda list
256-
257-
- name: Build
264+
265+
- name: Build and install cmake target for Windows
266+
if: matrix.os == 'windows'
267+
run: |
268+
$vsPath = &(Join-Path ${env:ProgramFiles(x86)} '\Microsoft Visual Studio\Installer\vswhere.exe') -property installationpath
269+
Import-Module (Join-Path $vsPath 'Common7\Tools\Microsoft.VisualStudio.DevShell.dll')
270+
Enter-VsDevShell -VsInstallPath $vsPath -SkipAutomaticLocation -DevCmdArguments '-arch=x64 -host_arch=x64'
271+
272+
cmake -GNinja -DCMAKE_BUILD_TYPE=Release -B build/ -S .
273+
cmake --build build/ --verbose -j1
274+
cmake --install build/ --prefix ${env:CONDA_PREFIX}/Library
275+
276+
- name: Build and install cmake target for Linux
277+
if: matrix.os == 'ubuntu'
278+
run: |
279+
cmake -GNinja -DCMAKE_BUILD_TYPE=Release -B build/ -S . -DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX -DCMAKE_PREFIX_PATH=$CONDA_PREFIX
280+
cmake --build build/ --verbose -j1
281+
cmake --install build/
282+
283+
- name: Build python
258284
run: python -m pip install . -vv --no-build-isolation --no-deps
259285

260286
- name: Test

docs/advanced_documentation/build-guide.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ export CXX=clang++-18 # or g++-13
210210
export CC=clang-18 # gcc-13
211211
export CMAKE_PREFIX_PATH=/home/linuxbrew/.linuxbrew
212212
export LLVM_COV=llvm-cov-18
213-
export CLANG_TIDY=clang-tidy-15 # only if you want to use one of the clang-tidy presets
213+
export CLANG_TIDY=clang-tidy-18 # only if you want to use one of the clang-tidy presets
214214
```
215215
216216
### Ubuntu Software Packages

power_grid_model_c/power_grid_model/include/power_grid_model/auxiliary/serialization/deserializer.hpp

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ using nlohmann::json;
4444
// visitor for json conversion
4545
struct JsonMapArrayData {
4646
size_t size{};
47-
msgpack::sbuffer buffer{};
47+
msgpack::sbuffer buffer;
4848
};
4949

5050
struct JsonSAXVisitor {
@@ -130,8 +130,8 @@ struct JsonSAXVisitor {
130130
throw SerializationError{ss.str()};
131131
}
132132

133-
std::stack<JsonMapArrayData> data_buffers{};
134-
msgpack::sbuffer root_buffer{};
133+
std::stack<JsonMapArrayData> data_buffers;
134+
msgpack::sbuffer root_buffer;
135135
};
136136

137137
// visitors for parsing
@@ -192,8 +192,15 @@ struct MapArrayVisitor : DefaultErrorVisitor<MapArrayVisitor<map_array>> {
192192
std::same_as<map_array, visit_map_t> || std::same_as<map_array, visit_map_array_t>;
193193
static constexpr bool enable_array =
194194
std::same_as<map_array, visit_array_t> || std::same_as<map_array, visit_map_array_t>;
195-
static constexpr std::string_view static_err_msg =
196-
enable_map ? (enable_array ? "Map or an array expected." : "Map expected.") : "Array expected.";
195+
static constexpr std::string_view static_err_msg = [] {
196+
if constexpr (enable_map && enable_array) {
197+
return "Map or an array expected.";
198+
} else if constexpr (enable_map) {
199+
return "Map expected.";
200+
} else {
201+
return "Array expected.";
202+
}
203+
}();
197204

198205
Idx size{};
199206
bool is_map{};
@@ -228,7 +235,7 @@ struct MapArrayVisitor : DefaultErrorVisitor<MapArrayVisitor<map_array>> {
228235
struct StringVisitor : DefaultErrorVisitor<StringVisitor> {
229236
static constexpr std::string_view static_err_msg = "String expected.";
230237

231-
std::string_view str{};
238+
std::string_view str;
232239
bool visit_str(const char* v, uint32_t size) {
233240
str = {v, size};
234241
return true;

power_grid_model_c/power_grid_model/include/power_grid_model/auxiliary/serialization/serializer.hpp

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,10 @@ struct MapArray {
7676
struct JsonConverter : msgpack::null_visitor {
7777
static constexpr char sep_char = ' ';
7878

79-
Idx indent;
80-
Idx max_indent_level;
81-
std::stringstream ss{};
82-
std::stack<MapArray> map_array{};
79+
Idx indent{};
80+
Idx max_indent_level{};
81+
std::stringstream ss{}; // NOLINT(readability-redundant-member-init)
82+
std::stack<MapArray> map_array{}; // NOLINT(readability-redundant-member-init)
8383

8484
void print_indent() {
8585
if (indent < 0) {
@@ -293,7 +293,7 @@ class Serializer {
293293
std::vector<ComponentBuffer> component_buffers_; // list of components, then all scenario flatten
294294

295295
// msgpack pakcer
296-
msgpack::sbuffer msgpack_buffer_{};
296+
msgpack::sbuffer msgpack_buffer_;
297297
msgpack::packer<msgpack::sbuffer> packer_;
298298
bool use_compact_list_{};
299299
std::map<MetaComponent const*, std::vector<MetaAttribute const*>> attributes_;
@@ -506,12 +506,10 @@ class Serializer {
506506
}
507507

508508
void pack_element_in_list(columnar_t /*tag*/, BufferView const& element_buffer, MetaComponent const& /*component*/,
509-
std::span<MetaAttribute const* const> attributes) {
509+
[[maybe_unused]] std::span<MetaAttribute const* const> attributes) {
510510
assert(is_columnar(element_buffer));
511511
assert(element_buffer.reordered_attribute_buffers.size() == attributes.size());
512512

513-
(void)attributes; // suppress unused variable in release mode
514-
515513
pack_array(element_buffer.reordered_attribute_buffers.size());
516514
for (auto const& attribute_buffer : element_buffer.reordered_attribute_buffers) {
517515
if (check_nan(attribute_buffer, element_buffer.idx)) {
@@ -606,7 +604,7 @@ class Serializer {
606604
});
607605
}
608606
void pack_attribute(AttributeBuffer<void const> const& attribute_buffer, Idx idx) {
609-
return ctype_func_selector(attribute_buffer.meta_attribute->ctype, [&]<class T> {
607+
ctype_func_selector(attribute_buffer.meta_attribute->ctype, [this, &attribute_buffer, idx]<class T> {
610608
packer_.pack(*(reinterpret_cast<T const*>(attribute_buffer.data) + idx));
611609
});
612610
}

power_grid_model_c/power_grid_model/include/power_grid_model/calculation_parameters.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ template <symmetry_tag sym_type> struct BranchShortCircuitSolverOutput {
5454

5555
// fault math calculation parameters and math output
5656
struct FaultCalcParam {
57-
DoubleComplex y_fault{};
57+
DoubleComplex y_fault;
5858
FaultType fault_type{};
5959
FaultPhase fault_phase{};
6060
};
@@ -126,7 +126,7 @@ static_assert(sensor_calc_param_type<PowerSensorCalcParam<asymmetric_t>>);
126126
struct TransformerTapRegulatorCalcParam {
127127
double u_set{};
128128
double u_band{};
129-
DoubleComplex z_compensation{};
129+
DoubleComplex z_compensation;
130130
IntS status{};
131131
};
132132

@@ -193,7 +193,7 @@ struct SourceCalcParam {
193193
DoubleComplex y1;
194194
DoubleComplex y0;
195195

196-
template <symmetry_tag sym> inline ComplexTensor<sym> y_ref() const {
196+
template <symmetry_tag sym> ComplexTensor<sym> y_ref() const {
197197
if constexpr (is_symmetric_v<sym>) {
198198
return y1;
199199
} else {

power_grid_model_c/power_grid_model/include/power_grid_model/common/common.hpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,20 @@ using IntSVector = std::vector<IntS>;
9191
template <class T, class... Ts>
9292
concept is_in_list_c = (std::same_as<std::remove_const_t<T>, Ts> || ...);
9393

94+
namespace capturing {
95+
// perfect forward into void
96+
template <class... T>
97+
constexpr void into_the_void(T&&... /*ignored*/) { // NOLINT(cppcoreguidelines-missing-std-forward)
98+
// do nothing; the constexpr allows all compilers to optimize this away
99+
}
100+
} // namespace capturing
101+
94102
// functor to include all
95103
struct IncludeAll {
96-
template <class... T> constexpr bool operator()(T&&... /*ignored*/) const { return true; }
104+
template <class... T> consteval bool operator()(T&&... args) const {
105+
capturing::into_the_void(std::forward<T>(args)...);
106+
return true;
107+
}
97108
};
98109
constexpr IncludeAll include_all{};
99110

power_grid_model_c/power_grid_model/include/power_grid_model/common/grouped_index_vector.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ class DenseGroupedIdxVector {
161161

162162
IdxVector const* dense_vector_{};
163163
Idx group_{};
164-
std::pair<group_iterator, group_iterator> group_range_{};
164+
std::pair<group_iterator, group_iterator> group_range_;
165165

166166
friend class boost::iterator_core_access;
167167

power_grid_model_c/power_grid_model/include/power_grid_model/common/iterator_like_concepts.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ concept iterator_like = requires(T const t) {
1616

1717
template <typename T, typename ElementType>
1818
concept forward_iterator_like = std::regular<T> && iterator_like<T, ElementType> && requires(T t) {
19-
{ t++ } -> std::same_as<T>;
20-
{ ++t } -> std::same_as<T&>;
19+
{ t++ } -> std::same_as<T>; // NOLINT(bugprone-inc-dec-in-conditions)
20+
{ ++t } -> std::same_as<T&>; // NOLINT(bugprone-inc-dec-in-conditions)
2121
};
2222

2323
template <typename T, typename ElementType>
2424
concept bidirectional_iterator_like = forward_iterator_like<T, ElementType> && requires(T t) {
25-
{ t-- } -> std::same_as<T>;
26-
{ --t } -> std::same_as<T&>;
25+
{ t-- } -> std::same_as<T>; // NOLINT(bugprone-inc-dec-in-conditions)
26+
{ --t } -> std::same_as<T&>; // NOLINT(bugprone-inc-dec-in-conditions)
2727
};
2828

2929
template <typename T, typename ElementType>

0 commit comments

Comments
 (0)