Skip to content

Keep only important integration tests: step 5 #848

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

Merged
merged 41 commits into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
39f5ef3
migrate indexer main model test to test api model
mgovers Nov 28, 2024
5e28a87
migrate duplicated id + non existing id checks to test api model
mgovers Nov 28, 2024
71f67df
migrate test id for wrong type
mgovers Nov 28, 2024
e940d99
migrate update with unknown id
mgovers Nov 28, 2024
eab6a6f
remove some restore logic testing
mgovers Nov 29, 2024
6762c75
attempt with heap corruption
mgovers Dec 2, 2024
88114ed
fix heap corruption
mgovers Dec 2, 2024
d237fee
add enum for calculation symmetry
mgovers Dec 2, 2024
15e4a89
minor
mgovers Dec 2, 2024
cc254ef
move misc api model test to regular api model test
mgovers Dec 2, 2024
74e7e75
remove duplicate test
mgovers Dec 2, 2024
b879932
migrate updates with alternating compute mode test
mgovers Dec 2, 2024
69590af
remove redundant code
mgovers Dec 2, 2024
c3fd36d
remove more redundant tests from test api model misc
mgovers Dec 2, 2024
c57e4f6
fully migrate incomplete input test
mgovers Dec 2, 2024
18514d7
minor cleanup
mgovers Dec 2, 2024
e88c4b5
migrate final test
mgovers Dec 2, 2024
84b60ba
finally remove last main model integration tests
mgovers Dec 2, 2024
749e64d
remove deprecated functionality; make more main model private
mgovers Dec 2, 2024
f4c3920
merge api model misc into api model update tests
mgovers Dec 2, 2024
7e1cb78
remove todo
mgovers Dec 2, 2024
1578616
Merge remote-tracking branch 'origin/main' into feature/only-importan…
mgovers Dec 2, 2024
c897c03
fix clang tidy
mgovers Dec 3, 2024
2d2d9b8
more clang-tidy
mgovers Dec 3, 2024
7162012
remove unused variable
mgovers Dec 3, 2024
058a897
fix clang-tidy
mgovers Dec 3, 2024
95c0b48
fix clang-tidy
mgovers Dec 3, 2024
4b8951e
make even more explicit
mgovers Dec 3, 2024
29e8b68
merge get indexer C API tests
mgovers Dec 3, 2024
bacf4f0
use C++17 features in C++ wrapper
mgovers Dec 3, 2024
6309aa5
calng-tidy
mgovers Dec 3, 2024
7e56733
tests per attribute
mgovers Dec 3, 2024
c69b8d8
debug macos release
mgovers Dec 3, 2024
566ff3f
debug macos
mgovers Dec 3, 2024
efcca25
Merge remote-tracking branch 'origin/main' into feature/only-importan…
mgovers Dec 3, 2024
8f5862f
sonar-cloud + clang-tidy
mgovers Dec 3, 2024
81936f6
resolve comments + fix ci
mgovers Dec 3, 2024
ca918e2
Merge branch 'main' into feature/only-important-integration-tests-5
mgovers Dec 4, 2024
e6a4ea8
fix full clang-tidy build
mgovers Dec 4, 2024
08a0b6b
use bool is_batch instead of Idx in cpp wrapper
mgovers Dec 4, 2024
5cb7a28
more full clang-tidy
mgovers Dec 4, 2024
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
2 changes: 1 addition & 1 deletion docs/advanced_documentation/c-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ and may vary between power grid model versions, compilers, operating systems and
<line_0><line_1><line_2> <-- 3 lines.
| | | | | | | <-- alignment: a line may start every 4 bytes.
iiiift iiiift iiiift <-- data: 6 bytes per line: 4 bytes for the ID, 1 for the from_status and 1 for the to_status.
| ..| ..| ..| <-- padding: (6 mod 4 = 2) bytes after every line.
| ..| ..| ..| <-- padding: (4 - (6 mod 4) = 2) bytes after every line.
| | | | <-- aligned size: (6 + 2 = 8) bytes every line.
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ enum class ControlSide : IntS { from = 0, to = 1, side_1 = 0, side_2 = 1, side_3

enum class CalculationType : IntS { power_flow = 0, state_estimation = 1, short_circuit = 2 };

enum class CalculationSymmetry : IntS { symmetric = 0, asymmetric = 1 };
enum class CalculationSymmetry : IntS { symmetric = 1, asymmetric = 2 };

enum class CalculationMethod : IntS {
default_method = -128,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,6 @@ class MainModel {
}

void set_construction_complete() { impl().set_construction_complete(); }
void restore_components(ConstDataset const& update_data) {
impl().restore_components(impl().get_all_sequence_idx_map(update_data));
}

template <class CompType> void add_component(std::vector<typename CompType::InputType> const& components) {
add_component<CompType>(std::span<typename CompType::InputType const>{components});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,35 +306,6 @@ class MainModelImpl<ExtraRetrievableTypes<ExtraRetrievableType...>, ComponentLis
update_components<CacheType>(update_data, 0, sequence_idx_map);
}

template <typename CompType> void restore_component(SequenceIdxView const& sequence_idx) {
constexpr auto component_index = main_core::utils::index_of_component<CompType, ComponentType...>;

auto& cached_inverse_update = std::get<component_index>(cached_inverse_update_);
auto const& component_sequence = std::get<component_index>(sequence_idx);

if (!cached_inverse_update.empty()) {
update_component<CompType, permanent_update_t>(cached_inverse_update, component_sequence);
cached_inverse_update.clear();
}
}

// restore the initial values of all components
void restore_components(SequenceIdxView const& sequence_idx) {
(restore_component<ComponentType>(sequence_idx), ...);

update_state(cached_state_changes_);
cached_state_changes_ = {};
}
void restore_components(std::array<std::reference_wrapper<std::vector<Idx2D> const>,
main_core::utils::n_types<ComponentType...>> const& sequence_idx) {
restore_components(std::array{std::span<Idx2D const>{
std::get<main_core::utils::index_of_component<ComponentType, ComponentType...>>(sequence_idx).get()}...});
}
void restore_components(main_core::utils::SequenceIdx<ComponentType...> const& sequence_idx) {
restore_components(std::array{std::span<Idx2D const>{
std::get<main_core::utils::index_of_component<ComponentType, ComponentType...>>(sequence_idx)}...});
}

// set complete construction
// initialize internal arrays
void set_construction_complete() {
Expand Down Expand Up @@ -402,6 +373,35 @@ class MainModelImpl<ExtraRetrievableTypes<ExtraRetrievableType...>, ComponentLis
is_asym_parameter_up_to_date_ = is_asym_parameter_up_to_date_ && !changes.topo && !changes.param;
}

template <typename CompType> void restore_component(SequenceIdxView const& sequence_idx) {
constexpr auto component_index = main_core::utils::index_of_component<CompType, ComponentType...>;

auto& cached_inverse_update = std::get<component_index>(cached_inverse_update_);
auto const& component_sequence = std::get<component_index>(sequence_idx);

if (!cached_inverse_update.empty()) {
update_component<CompType, permanent_update_t>(cached_inverse_update, component_sequence);
cached_inverse_update.clear();
}
}

// restore the initial values of all components
void restore_components(SequenceIdxView const& sequence_idx) {
(restore_component<ComponentType>(sequence_idx), ...);

update_state(cached_state_changes_);
cached_state_changes_ = {};
}
void restore_components(std::array<std::reference_wrapper<std::vector<Idx2D> const>,
main_core::utils::n_types<ComponentType...>> const& sequence_idx) {
restore_components(std::array{std::span<Idx2D const>{
std::get<main_core::utils::index_of_component<ComponentType, ComponentType...>>(sequence_idx).get()}...});
}
void restore_components(main_core::utils::SequenceIdx<ComponentType...> const& sequence_idx) {
restore_components(std::array{std::span<Idx2D const>{
std::get<main_core::utils::index_of_component<ComponentType, ComponentType...>>(sequence_idx)}...});
}

template <solver_output_type SolverOutputType, typename MathSolverType, typename YBus, typename InputType,
typename PrepareInputFn, typename SolveFn>
requires std::invocable<std::remove_cvref_t<PrepareInputFn>, Idx /*n_math_solvers*/> &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,14 @@ enum PGM_CalculationMethod {
PGM_iec60909 = 5 /**< fault analysis for short circuits using the iec60909 standard */
};

/**
* @brief Enumeration for calculation and/or component symmetry
*/
enum PGM_SymmetryType {
PGM_asymmetric = 0, /** < asymmetric calculation and/or component */
PGM_symmetric = 1 /** < symmetric calculation and/or component */
};

/**
* @brief Enumeration of error codes.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ PGM_API void PGM_set_calculation_method(PGM_Handle* handle, PGM_Options* opt, PG
*
* @param handle
* @param opt The pointer to the option instance.
* @param sym 1 for symmetric calculation; 0 for asymmetric calculation.
* @param sym See #PGM_CalculationSymmetry . 1 for symmetric calculation; 0 for asymmetric calculation.
*/
PGM_API void PGM_set_symmetric(PGM_Handle* handle, PGM_Options* opt, PGM_Idx sym);

Expand Down
8 changes: 6 additions & 2 deletions power_grid_model_c/power_grid_model_c/src/model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,14 @@ constexpr auto get_calculation_type(PGM_Options const& opt) {
}

constexpr auto get_calculation_symmetry(PGM_Options const& opt) {
if (opt.symmetric == 0) {
switch (opt.symmetric) {
case PGM_asymmetric:
return CalculationSymmetry::asymmetric;
case PGM_symmetric:
return CalculationSymmetry::symmetric;
default:
throw MissingCaseForEnumError{"get_calculation_symmetry", opt.tap_changing_strategy};
}
return CalculationSymmetry::symmetric;
}

constexpr auto get_calculation_method(PGM_Options const& opt) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class Buffer {
RawDataConstPtr get() const { return buffer_.get(); }
RawDataPtr get() { return buffer_.get(); }

MetaComponent const* component() const { return component_; }
Idx size() const { return size_; }

void set_nan() { set_nan(0, size_); }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,13 @@ class DatasetWritable {

class DatasetMutable {
public:
DatasetMutable(std::string const& dataset, Idx is_batch, Idx batch_size)
: dataset_{handle_.call_with(PGM_create_dataset_mutable, dataset.c_str(), is_batch, batch_size)},
DatasetMutable(std::string const& dataset, std::convertible_to<Idx> auto is_batch, Idx batch_size)
requires(!std::same_as<decltype(is_batch), bool>)
: handle_{},
dataset_{handle_.call_with(PGM_create_dataset_mutable, dataset.c_str(), is_batch, batch_size)},
info_{handle_.call_with(PGM_dataset_mutable_get_info, get())} {}
explicit DatasetMutable(std::string const& dataset, std::same_as<bool> auto is_batch, Idx batch_size)
: DatasetMutable{dataset, is_batch ? Idx{1} : Idx{0}, batch_size} {}

RawMutableDataset const* get() const { return dataset_.get(); }
RawMutableDataset* get() { return dataset_.get(); }
Expand Down Expand Up @@ -126,9 +130,13 @@ class DatasetMutable {

class DatasetConst {
public:
DatasetConst(std::string const& dataset, Idx is_batch, Idx batch_size)
: dataset_{handle_.call_with(PGM_create_dataset_const, dataset.c_str(), is_batch, batch_size)},
DatasetConst(std::string const& dataset, std::convertible_to<Idx> auto is_batch, Idx batch_size)
requires(!std::same_as<decltype(is_batch), bool>)
: handle_{},
dataset_{handle_.call_with(PGM_create_dataset_const, dataset.c_str(), is_batch, batch_size)},
info_{handle_.call_with(PGM_dataset_const_get_info, get())} {}
explicit DatasetConst(std::string const& dataset, std::same_as<bool> auto is_batch, Idx batch_size)
: DatasetConst{dataset, is_batch ? Idx{1} : Idx{0}, batch_size} {}
DatasetConst(DatasetWritable const& writable_dataset)
: dataset_{handle_.call_with(PGM_create_dataset_const_from_writable, writable_dataset.get())},
info_{handle_.call_with(PGM_dataset_const_get_info, get())} {}
Expand Down
1 change: 0 additions & 1 deletion tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,5 @@ include("${doctest_DIR}/doctest.cmake")

add_subdirectory("native_api_tests")
add_subdirectory("cpp_unit_tests")
add_subdirectory("cpp_integration_tests")
add_subdirectory("cpp_validation_tests")
add_subdirectory("benchmark_cpp")
19 changes: 0 additions & 19 deletions tests/cpp_integration_tests/CMakeLists.txt

This file was deleted.

9 changes: 0 additions & 9 deletions tests/cpp_integration_tests/test_entry_point.cpp

This file was deleted.

Loading
Loading