Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

#pragma once

#include "../common/common.hpp"
#include "../common/three_phase_tensor.hpp"
#include "power_grid_model/common/common.hpp"

namespace power_grid_model {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#include <cassert>
#include <complex>
#include <format>
#include <string>
#include <type_traits>

Expand Down Expand Up @@ -154,7 +155,7 @@ class LoadGen final : public std::conditional_t<is_generator_v<appliance_type_>,
case const_i:
return params() * cabs(u);
default:
throw MissingCaseForEnumError(std::string{name} + " power scaling factor", this->type());
throw MissingCaseForEnumError{std::format("{} power scaling factor", name), this->type()};
}
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
#include "../auxiliary/input.hpp"
#include "../auxiliary/output.hpp"
#include "../auxiliary/update.hpp"
#include "power_grid_model/common/common.hpp"
#include "power_grid_model/common/enum.hpp"
#include "../common/common.hpp"
#include "../common/enum.hpp"

#include <cassert>
#include <concepts>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ inline void allocate_q_iterative_distribution(int num_regulating_gens, RealValue
if (std::abs(total_q<sym>(q_remaining - q_unallocated)) < numerical_tolerance) {
// throw just in case, as this should only happen when all limits are hit,
// and this case should have been handled in allocate_q_bus_limit_violated()
throw CalculationError("Unallocated Q remains after distribution on");
throw CalculationError{"Unallocated Q remains after distribution on"};
}

q_remaining = q_unallocated;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
#pragma once

#include "measured_values.hpp"
#include "power_grid_model/calculation_parameters.hpp"
#include "power_grid_model/common/common.hpp"
#include "power_grid_model/common/enum.hpp"
#include "power_grid_model/common/typing.hpp"
#include "y_bus.hpp"

#include "../calculation_parameters.hpp"
#include "../common/common.hpp"
#include "../common/enum.hpp"
#include "../common/exception.hpp"
#include "../common/typing.hpp"

#include <algorithm>
#include <cassert>
Expand Down
5 changes: 1 addition & 4 deletions power_grid_model_c/power_grid_model_c/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@ add_library(
"src/math_solver.cpp"
)

file(
GLOB_RECURSE pgm_c_private_headers
"${CMAKE_CURRENT_SOURCE_DIR}/src/*.hpp"
)
file(GLOB_RECURSE pgm_c_private_headers "${CMAKE_CURRENT_SOURCE_DIR}/src/*.hpp")

file(
GLOB_RECURSE pgm_c_public_headers
Expand Down
2 changes: 1 addition & 1 deletion power_grid_model_c/power_grid_model_c/src/math_solver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
#define PGM_DLL_EXPORTS

#include "math_solver.hpp"
#include <power_grid_model/math_solver/math_solver_dispatch.hpp>

#include <power_grid_model/math_solver/math_solver.hpp>
#include <power_grid_model/math_solver/math_solver_dispatch.hpp>

namespace power_grid_model_c {
using namespace power_grid_model;
Expand Down
2 changes: 2 additions & 0 deletions power_grid_model_c/power_grid_model_c/src/serialization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// SPDX-License-Identifier: MPL-2.0

#define PGM_DLL_EXPORTS

#include "forward_declarations.hpp"
#include "get_meta_data.hpp"
#include "handle.hpp"
Expand All @@ -16,6 +17,7 @@
#include <power_grid_model/auxiliary/serialization/serializer.hpp>
#include <power_grid_model/common/enum.hpp>

#include <cassert>
#include <cstddef>
#include <span>
#include <vector>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include <vector>

namespace power_grid_model_cpp {

namespace {
using EnumMap = CLI::TransformPairs<Idx>;

struct CLIPostCallback {
Expand Down Expand Up @@ -126,6 +126,7 @@ struct CLIPostCallback {
}
}
};
} // namespace

CLIResult parse_cli_options(int argc, char** argv, CLIOptions& options) {
auto version_str = std::format("Power Grid Model CLI\n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include <vector>

namespace power_grid_model_cpp {

namespace {
struct BatchDatasets {
explicit BatchDatasets(CLIOptions const& cli_options) {
if (!cli_options.is_batch) {
Expand Down Expand Up @@ -46,6 +46,7 @@ struct BatchDatasets {
std::vector<OwningDataset> datasets;
std::vector<DatasetConst> dataset_consts;
};
} // namespace

void pgm_calculation(CLIOptions const& cli_options) {
OwningDataset const input_dataset = load_dataset(cli_options.input_file, cli_options.input_serialization_format);
Expand Down
2 changes: 1 addition & 1 deletion src/power_grid_model/_core/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import numpy as np

_DEPRECATED_ERROR_MSG = "This error type is deprecated and may be reduced in a future release."
_DEPRECATED_ERROR_MSG = "This error type is deprecated and may be removed in a future release."


class PowerGridError(RuntimeError):
Expand Down
1 change: 1 addition & 0 deletions tests/benchmark_cpp/benchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include "fictional_grid_generator.hpp"

#include <power_grid_model_cpp/basics.hpp>
#include <power_grid_model_cpp/dataset.hpp>
#include <power_grid_model_cpp/logger.hpp>
#include <power_grid_model_cpp/meta_data.hpp>
Expand Down
4 changes: 2 additions & 2 deletions tests/cpp_cli_tests/test_cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include <power_grid_model_cpp/serialization.hpp>

#include <doctest/doctest.h>
#include <nlohmann/json.hpp>
#include <nlohmann/json.hpp> // NOLINT(misc-include-cleaner) // false positive

#include <array>
#include <complex>
Expand Down Expand Up @@ -226,7 +226,7 @@ void save_data(std::string_view json_data, fs::path const& path, PGM_Serializati
if (format == PGM_json) {
ofs << json_data;
} else {
nlohmann::json const j = nlohmann::json::parse(json_data);
nlohmann::json const j = nlohmann::json::parse(json_data); // NOLINT(misc-include-cleaner) // false positive
std::string msgpack_buffer;
nlohmann::json::to_msgpack(j, msgpack_buffer);
ofs << msgpack_buffer;
Expand Down
17 changes: 9 additions & 8 deletions tests/cpp_unit_tests/math_solver/test_math_solver_se.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,17 @@ struct WeightedPowerReference {
// Independent WLS reference solutions: symmetric, then asymmetric.
inline constexpr std::array<WeightedPowerReference, 2> weighted_power_references{{
{
{{{-0.012931579763747281, 0, 0}, {-0.072074026454564483, 0, 0}, {-0.64803267961269317, 0, 0}}},
{{{1.0886744473242378, 0, 0}, {0.97834875041371472, 0, 0}, {0.90774626327045671, 0, 0}}},
.expected_angle =
{{{-0.012931579763747281, 0, 0}, {-0.072074026454564483, 0, 0}, {-0.64803267961269317, 0, 0}}},
.expected_magnitude = {{{1.0886744473242378, 0, 0}, {0.97834875041371472, 0, 0}, {0.90774626327045671, 0, 0}}},
},
{
{{{0.0028860613646341125, -2.1128248852594584, 2.0624094609995924},
{-0.069761570200159786, -2.1636716162922429, 2.021621193449247},
{-0.64917820246136004, -2.7459231572286105, 1.4553706326473219}}},
{{{1.1042154942185964, 1.0464291971463717, 1.0992389433007472},
{0.97649213512856181, 0.95624900830031723, 0.98309380273782954},
{0.90829642922764842, 0.89652332245654576, 0.90063061273657197}}},
.expected_angle = {{{0.0028860613646341125, -2.1128248852594584, 2.0624094609995924},
{-0.069761570200159786, -2.1636716162922429, 2.021621193449247},
{-0.64917820246136004, -2.7459231572286105, 1.4553706326473219}}},
.expected_magnitude = {{{1.1042154942185964, 1.0464291971463717, 1.0992389433007472},
{0.97649213512856181, 0.95624900830031723, 0.98309380273782954},
{0.90829642922764842, 0.89652332245654576, 0.90063061273657197}}},
},
}};
} // namespace power_grid_model::math_solver::test_data
Expand Down
6 changes: 3 additions & 3 deletions tests/native_api_tests/test_api_dataset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,8 @@ TEST_CASE("OwningDataset - filter irrelevant components") {

namespace {
constexpr auto indptr_bounds_error_message =
"The last element of indptr must be equal to the total number of elements!\n";
"For a non-uniform buffer, indptr should begin with 0 and end with total_elements!\n";
constexpr auto indptr_monotonic_error_message = "For a non-uniform buffer, indptr should be non-decreasing!\n";
} // namespace

TEST_CASE_TEMPLATE("Native readable dataset - indptr sanitization", DatasetType, DatasetMutable, DatasetConst) {
Expand Down Expand Up @@ -196,8 +197,7 @@ TEST_CASE_TEMPLATE("Native readable dataset - indptr sanitization", DatasetType,
SUBCASE("add_buffer with non-monotonic indptr") {
std::vector<Idx> const indptr{0, 2, 1, 3};
CHECK_THROWS_AS_MESSAGE(dataset.add_buffer("node", -1, indptr.back(), indptr.data(), nullptr),
PowerGridRegularError,
doctest::Contains("For a non-uniform buffer, indptr should be non-decreasing!\n"));
PowerGridRegularError, doctest::Contains(indptr_monotonic_error_message));
}
}

Expand Down
Loading