Skip to content

Conversation

@Thijss
Copy link
Member

@Thijss Thijss commented May 7, 2025

See title.

@Thijss Thijss marked this pull request as ready for review May 7, 2025 12:46
@sonarqubecloud
Copy link

sonarqubecloud bot commented May 7, 2025

Copy link
Member

@vincentkoppen vincentkoppen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, would be nice to have some tests since it is now a public method.

@Thijss Thijss added the do-not-merge This should not be merged label Jun 5, 2025
Thijss added 4 commits July 17, 2025 12:51
Signed-off-by: Thijs Baaijen <[email protected]>
Signed-off-by: Thijs Baaijen <[email protected]>
Signed-off-by: Thijs Baaijen <[email protected]>

# Conflicts:
#	tests/integration/loadflow/test_power_grid_model.py
@Thijss Thijss removed the do-not-merge This should not be merged label Jul 17, 2025
Thijss added 4 commits July 17, 2025 15:47
Signed-off-by: Thijs Baaijen <[email protected]>
Signed-off-by: Thijs Baaijen <[email protected]>
…blic

# Conflicts:
#	tests/integration/loadflow/conftest.py
#	tests/integration/loadflow/test_power_grid_model.py
Signed-off-by: Thijs Baaijen <[email protected]>
@Thijss Thijss changed the base branch from main to chore/refactor-loadflow-tests July 17, 2025 14:50
Thijss added 3 commits July 17, 2025 16:56
…nto feat/setup-model-public

# Conflicts:
#	src/power_grid_model_ds/_core/load_flow.py
Signed-off-by: Thijs Baaijen <[email protected]>
@Thijss Thijss changed the title Make PowerGridModelInterface._setup_model a public method change: make PowerGridModelInterface._setup_model a public method Jul 18, 2025
@Thijss Thijss changed the title change: make PowerGridModelInterface._setup_model a public method refactor: make PowerGridModelInterface._setup_model a public method Jul 18, 2025
Copy link
Member

@jaapschoutenalliander jaapschoutenalliander left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR is fine, I do wonder what use case you have for making the method public?

Base automatically changed from chore/refactor-loadflow-tests to main July 18, 2025 10:20
# Conflicts:
#	tests/integration/loadflow/test_power_grid_model.py
@sonarqubecloud
Copy link

@Thijss
Copy link
Member Author

Thijss commented Jul 18, 2025

The PR is fine, I do wonder what use case you have for making the method public?

Mostly to keep the code readable.
Below is an approximation of our source code:

def get_high_and_low_power_flow_results(grid) -> dict[str, dict]:
    pgm = _setup_pgm_model(grid)  # uses .setup_model()
    pgm_output = {}
    for peak_load in [PeakLoad.HIGH, PeakLoad.LOW]:
        sources = get_sources(grid, peak_load)
        sym_loads = get_loads_per_component(grid, peak_load)
        pgm_output[peak_load] = _calculate_power_flow(pgm, sym_loads, source)
    )
    return pgm_output

def _calculate_power_flow(pgm: PowerGridModelInterface, sym_loads: np.ndarray, source: SourceArray) -> dict[str, np.ndarray]:
    pgm.update_model(update_data={"sym_load": _get_sym_load_updates(sym_loads)})
    pgm.update_model(update_data={"source": _get_source_updates(source)})
    pgm.calculate_power_flow(calculation_method=CalculationMethod.linear)
    return copy(pgm.output_data)

@Thijss Thijss merged commit 8c4a8a4 into main Jul 18, 2025
22 checks passed
@Thijss Thijss deleted the feat/setup-model-public branch July 18, 2025 10:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants