Skip to content

Create tests folder and add test_cases.py to check all cases in pypow…#90

Open
dchassin wants to merge 38 commits intorwl:masterfrom
dchassin:add-tests
Open

Create tests folder and add test_cases.py to check all cases in pypow…#90
dchassin wants to merge 38 commits intorwl:masterfrom
dchassin:add-tests

Conversation

@dchassin
Copy link
Collaborator

@dchassin dchassin commented Jun 12, 2025

This PR adds a tests folder, which includes a script to run all the cases found in the pypower folder. The tests are part of a github workflow that will be automatically run by github actions anytime there is a push or pull request on master. The tests are run on all the supported runners. See GitHub Actions Runners for a list of currently support runners.

In principle all these cases should pass both runpf() and runopf() calls. If the case name contains the string target it is considered a continuation powerflow and solved using runcpf().

The test script outputs the case data in case*.json and results in case*_pf.out or case*_opf.out to aid with diagnostics. The tests folder is saved as an artifact when a test fails. Downloading this artifacts can aid in diagnosing the cause of the failure.

IMPORTANT NOTE: due to a number of version issues, this PR deprecates support for Python versions older than 3.10, which as of this date are at or very near official end-of-life support.

Case fixes:

  • case4gs: 'gencost'
  • case9target: runcpf failed
  • case30pwl: can't multiply sequence by non-int of type 'float'
  • case9Q: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
  • case30Q: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

New case(s):

  • DC line test

@dchassin dchassin requested a review from rwl June 12, 2025 16:22
@dchassin
Copy link
Collaborator Author

dchassin commented Jun 12, 2025

The current test result is as follows:

Testing all pypower v5.1.19 cases in ../pypower...
Solving case30.py problems... PF... OPF... ok.
Solving case14.py problems... PF... OPF... ok.
Solving case9.py problems... PF... OPF... ok.
Solving case4gs.py problems... PF... ok.
Solving case24_ieee_rts.py problems... PF... OPF... ok.
Solving case39.py problems... PF... OPF... ok.
Solving case9target.py problems... CPF... ok.
Solving case30pwl.py problems... PF... OPF... ok.
Solving case300.py problems... PF... OPF... ok.
Solving case9Q.py problems... PF... OPF... ok.
Solving case6ww.py problems... PF... OPF... ok.
Solving case57.py problems... PF... OPF... ok.
Solving case118.py problems... PF... OPF... ok.
Solving case30Q.py problems... PF... OPF... ok.
Testing completed: tested=14, failed=0

@dchassin dchassin marked this pull request as draft June 13, 2025 04:43
@dchassin
Copy link
Collaborator Author

dchassin commented Jun 13, 2025

This PR now includes needed updates to module versions and changes to tox version info.

@dchassin dchassin marked this pull request as ready for review June 13, 2025 18:05
@rwl
Copy link
Owner

rwl commented Jun 13, 2025

Having fun David? It is great to see PYPOWER getting some much needed attention. Sorry I can't work on it with you.

In the past Travis-CI was used for CI/CD, but it is no longer free for open source projects. It would be great if the config could be replaced with a GitHub Actions workflow.

@dchassin
Copy link
Collaborator Author

dchassin commented Jun 13, 2025

Having fun David? It is great to see PYPOWER getting some much needed attention. Sorry I can't work on it with you.

No worries. If you have any thoughts or suggestions on things I should look into, please let me know.

In the past Travis-CI was used for CI/CD, but it is no longer free for open source projects. It would be great if the config could be replaced with a GitHub Actions workflow.

Indeed, I saw that and it is something I've added in this PR. However, I have not connected the tests as a dependency for publishing yet. I'm not sure how to do that across workflows. I think they have to be integrated into a single workflow.

@dchassin
Copy link
Collaborator Author

@rwl, I don't see any examples or test cases for DC lines. Do you know how these are modeled? Do you have anything you can point me to that I can use to add a DC line test case?

@rwl
Copy link
Owner

rwl commented Jul 30, 2025

Tests for dcline are here: https://github.com/rwl/PYPOWER/blob/master/pypower/t/t_dcline.py

@rwl
Copy link
Owner

rwl commented Jul 30, 2025

The MATPOWER User's Manual describes the DC line model:

https://github.com/MATPOWER/matpower/blob/master/docs/src/MATPOWER-manual/MATPOWER-manual.tex#L3670-L3712

@dchassin
Copy link
Collaborator Author

Tests for dcline are here: https://github.com/rwl/PYPOWER/blob/master/pypower/t/t_dcline.py

I assume that means t_case9_dcline.py is the reference model to use for integration tests with GridLAB-D.

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.

2 participants