-
Notifications
You must be signed in to change notification settings - Fork 563
pp.create.create_transformers value initialization not working #2894
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
Open
belobradi
wants to merge
6
commits into
e2nIEE:develop
Choose a base branch
from
belobradi:transformer-nan-values
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+128
−75
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
efcb911
pp.create.create_transformers value initialization not working (#2886)
belobradi f404f42
pp.create.create_transformers value initialization not working (#2886)
belobradi a3e013d
pp.create.create_transformers value initialization not working (#2886)
belobradi 4be1f30
Merge branch 'develop' into transformer-nan-values
KS-HTK f9aa6ed
Merge branch 'develop' into transformer-nan-values
vogt31337 8a0669a
Merge branch 'develop' into transformer-nan-values
KS-HTK File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -983,37 +983,34 @@ def test_create_transformers(): | |
| name=["trafo1", "trafo2"], | ||
| test_kwargs="TestKW" | ||
| ) | ||
| res_df = pd.DataFrame({ | ||
| 'name': ['trafo1', 'trafo2'], | ||
| 'std_type': ['0.4 MVA 10/0.4 kV', '0.4 MVA 10/0.4 kV'], | ||
| 'hv_bus': pd.Series([0, 0], dtype=np.uint32), | ||
| 'lv_bus': pd.Series([1, 2], dtype=np.uint32), | ||
| 'sn_mva': [0.4, 0.4], | ||
| 'vn_hv_kv': [10.0, 10.0], | ||
| 'vn_lv_kv': [0.4, 0.4], | ||
| 'vk_percent': [4.0, 4.0], | ||
| 'vkr_percent': [1.325, 1.325], | ||
| 'pfe_kw': [0.95, 0.95], | ||
| 'i0_percent': [0.2375, 0.2375], | ||
| 'shift_degree': [0.0, 0.0], | ||
| 'tap_side': ['', ''], | ||
| 'tap_neutral': [nan, nan], | ||
| 'tap_min': [nan, nan], | ||
| 'tap_max': [nan, nan], | ||
| 'tap_step_percent': [nan, nan], | ||
| 'tap_step_degree': [nan, nan], | ||
| 'tap_pos': [nan, nan], | ||
| 'tap_changer_type': ['', ''], | ||
| 'id_characteristic_table': pd.Series([pd.NA, pd.NA], dtype=pd.Int64Dtype), | ||
| 'tap_dependency_table': [False, False], | ||
| 'parallel': pd.Series([1, 1], dtype=np.uint32), | ||
| 'df': [1.0, 1.0], | ||
| 'in_service': [True, True], | ||
| 'oltc': [False, False], | ||
| 'test_kwargs': ['TestKW', 'TestKW'], | ||
| 'vector_group': ['Dyn5', 'Dyn5'], | ||
| }) | ||
| assert dataframes_equal(net.trafo, res_df) | ||
|
|
||
| assert net.trafo["name"].tolist() == ["trafo1", "trafo2"] | ||
| assert net.trafo["std_type"].tolist() == ["0.4 MVA 10/0.4 kV", "0.4 MVA 10/0.4 kV"] | ||
| assert net.trafo["hv_bus"].tolist() == [0, 0] | ||
| assert net.trafo["lv_bus"].tolist() == [1, 2] | ||
| assert np.allclose(net.trafo["sn_mva"].tolist(), [0.4, 0.4]) | ||
| assert np.allclose(net.trafo["vn_hv_kv"].tolist(), [10.0, 10.0]) | ||
| assert np.allclose(net.trafo["vn_lv_kv"].tolist(), [0.4, 0.4]) | ||
| assert np.allclose(net.trafo["vk_percent"].tolist(), [4.0, 4.0]) | ||
| assert np.allclose(net.trafo["vkr_percent"].tolist(), [1.325, 1.325]) | ||
| assert np.allclose(net.trafo["pfe_kw"].tolist(), [0.95, 0.95]) | ||
| assert np.allclose(net.trafo["i0_percent"].tolist(), [0.2375, 0.2375]) | ||
| assert np.allclose(net.trafo["shift_degree"].tolist(), [150.0, 150.0]) | ||
| assert net.trafo["tap_side"].tolist() == ["hv", "hv"] | ||
| assert net.trafo["tap_neutral"].tolist(), [0, 0] | ||
| assert net.trafo["tap_min"].tolist(), [-2, -2] | ||
| assert net.trafo["tap_max"].tolist(), [2, 2] | ||
| assert np.allclose(net.trafo["tap_step_percent"].tolist(), [2.5, 2.5]) | ||
| assert net.trafo["tap_step_degree"].tolist(), [0, 0] | ||
| assert net.trafo["tap_pos"].tolist(), [0, 0] | ||
| assert net.trafo["tap_changer_type"].tolist() == ["Ratio", "Ratio"] | ||
| assert net.trafo["id_characteristic_table"].isna().all() | ||
| assert net.trafo["parallel"].tolist() == [1, 1] | ||
| assert np.allclose(net.trafo["df"].tolist(), [1.0, 1.0]) | ||
| assert net.trafo["in_service"].tolist() == [True, True] | ||
| assert net.trafo["oltc"].tolist() == [False, False] | ||
| assert net.trafo["test_kwargs"].tolist() == ["TestKW", "TestKW"] | ||
| assert net.trafo["vector_group"].tolist() == ["Dyn5", "Dyn5"] | ||
|
|
||
| def test_create_transformers_for_single(): | ||
| net = create_empty_network() | ||
|
|
@@ -1028,37 +1025,94 @@ def test_create_transformers_for_single(): | |
| test_kwargs="TestKW", | ||
| sn_mva=.4 | ||
| ) | ||
| res_df = pd.DataFrame({ | ||
| 'name': ['trafo1'], | ||
| 'std_type': ['0.4 MVA 10/0.4 kV'], | ||
| 'hv_bus': pd.Series([0], dtype=np.uint32), | ||
| 'lv_bus': pd.Series([1], dtype=np.uint32), | ||
| 'sn_mva': [0.4], | ||
| 'vn_hv_kv': [10.0], | ||
| 'vn_lv_kv': [0.4], | ||
| 'vk_percent': [4.0], | ||
| 'vkr_percent': [1.325], | ||
| 'pfe_kw': [0.95], | ||
| 'i0_percent': [0.2375], | ||
| 'shift_degree': [0.0], | ||
| 'tap_side': [''], | ||
| 'tap_neutral': [nan], | ||
| 'tap_min': [nan], | ||
| 'tap_max': [nan], | ||
| 'tap_step_percent': [nan], | ||
| 'tap_step_degree': [nan], | ||
| 'tap_pos': [nan], | ||
| 'tap_changer_type': [''], | ||
| 'id_characteristic_table': pd.Series([pd.NA], dtype=pd.Int64Dtype), | ||
| 'tap_dependency_table': [False], | ||
| 'parallel': pd.Series([1], dtype=np.uint32), | ||
| 'df': [1.0], | ||
| 'in_service': [True], | ||
| 'oltc': [False], | ||
| 'test_kwargs': ['TestKW'], | ||
| 'vector_group': ['Dyn5'], | ||
| }) | ||
| assert dataframes_equal(net.trafo, res_df) | ||
| assert net.trafo["name"].tolist() == ["trafo1"] | ||
| assert net.trafo["std_type"].tolist() == ["0.4 MVA 10/0.4 kV"] | ||
| assert net.trafo["hv_bus"].tolist() == [0] | ||
| assert net.trafo["lv_bus"].tolist() == [1] | ||
| assert np.allclose(net.trafo["sn_mva"].tolist(), [0.4]) | ||
| assert np.allclose(net.trafo["vn_hv_kv"].tolist(), [10.0]) | ||
| assert np.allclose(net.trafo["vn_lv_kv"].tolist(), [0.4]) | ||
| assert np.allclose(net.trafo["vk_percent"].tolist(), [4.0]) | ||
| assert np.allclose(net.trafo["vkr_percent"].tolist(), [1.325]) | ||
| assert np.allclose(net.trafo["pfe_kw"].tolist(), [0.95]) | ||
| assert np.allclose(net.trafo["i0_percent"].tolist(), [0.2375]) | ||
| assert np.allclose(net.trafo["shift_degree"].tolist(), [150.0]) | ||
| assert net.trafo["tap_side"].tolist() == ["hv"] | ||
| assert net.trafo["tap_neutral"].tolist(), [0] | ||
| assert net.trafo["tap_min"].tolist(), [-2] | ||
| assert net.trafo["tap_max"].tolist(), [2] | ||
| assert np.allclose(net.trafo["tap_step_percent"].tolist(), [2.5]) | ||
| assert net.trafo["tap_step_degree"].tolist(), [0] | ||
| assert net.trafo["tap_pos"].tolist(), [0] | ||
| assert net.trafo["tap_changer_type"].tolist() == ["Ratio"] | ||
| assert net.trafo["id_characteristic_table"].isna().all() | ||
| assert net.trafo["parallel"].tolist() == [1] | ||
| assert np.allclose(net.trafo["df"].tolist(), [1.0]) | ||
| assert net.trafo["in_service"].tolist() == [True] | ||
| assert net.trafo["oltc"].tolist() == [False] | ||
| assert net.trafo["test_kwargs"].tolist() == ["TestKW"] | ||
| assert net.trafo["vector_group"].tolist() == ["Dyn5"] | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change seems to be unrelated to the PR. I would also not approve of it as this seems overly complex, if the original assert fails you can get slightly better output if you have CLI logging enabled while testing. Same for the test above. |
||
|
|
||
| def test_create_transformers_for_single_override_std_type(): | ||
| net = create_empty_network() | ||
| b1 = create_bus(net, 22) | ||
| b2 = create_bus(net, .5) | ||
| create_transformers( | ||
| net, | ||
| hv_buses=[b1], | ||
| lv_buses=[b2], | ||
| std_type="0.4 MVA 10/0.4 kV", | ||
| name="trafo1", | ||
| sn_mva = 0.5, | ||
| vn_hv_kv = 22, | ||
| vn_lv_kv = 0.5, | ||
| vk_percent = 5, | ||
| vkr_percent = 1.532, | ||
| pfe_kw = 0.65, | ||
| i0_percent = 0.1264, | ||
| shift_degree = 90, | ||
| vector_group = "Dd5", | ||
| tap_side = "lv", | ||
| tap_neutral = 1, | ||
| tap_min = -4, | ||
| tap_max = 4, | ||
| tap_step_degree = 3, | ||
| tap_step_percent = 1.5, | ||
| tap_changer_type = "Symmetrical", | ||
| trafo_characteristic_table = True, | ||
| parallel = 2, | ||
| df = 2, | ||
| in_service = False, | ||
| oltc = True, | ||
| test_kwargs = "TestKW" | ||
| ) | ||
| assert net.trafo["name"].tolist() == ["trafo1"] | ||
| assert net.trafo["std_type"].tolist() == ["0.4 MVA 10/0.4 kV"] | ||
| assert net.trafo["hv_bus"].tolist() == [0] | ||
| assert net.trafo["lv_bus"].tolist() == [1] | ||
| assert np.allclose(net.trafo["sn_mva"].tolist(), [0.5]) | ||
| assert np.allclose(net.trafo["vn_hv_kv"].tolist(), [22.0]) | ||
| assert np.allclose(net.trafo["vn_lv_kv"].tolist(), [0.5]) | ||
| assert np.allclose(net.trafo["vk_percent"].tolist(), [5.0]) | ||
| assert np.allclose(net.trafo["vkr_percent"].tolist(), [1.532]) | ||
| assert np.allclose(net.trafo["pfe_kw"].tolist(), [0.65]) | ||
| assert np.allclose(net.trafo["i0_percent"].tolist(), [0.1264]) | ||
| assert np.allclose(net.trafo["shift_degree"].tolist(), [90.0]) | ||
| assert net.trafo["tap_side"].tolist() == ["lv"] | ||
| assert net.trafo["tap_neutral"].tolist(), [1] | ||
| assert net.trafo["tap_min"].tolist(), [-4] | ||
| assert net.trafo["tap_max"].tolist(), [4] | ||
| assert np.allclose(net.trafo["tap_step_percent"].tolist(), [1.5]) | ||
| assert net.trafo["tap_step_degree"].tolist(), [3] | ||
| assert net.trafo["tap_pos"].tolist(), [1] | ||
| assert net.trafo["tap_changer_type"].tolist() == ["Symmetrical"] | ||
| assert net.trafo["id_characteristic_table"].isna().all() | ||
| assert net.trafo["parallel"].tolist() == [2] | ||
| assert np.allclose(net.trafo["df"].tolist(), [2.0]) | ||
| assert net.trafo["in_service"].tolist() == [False] | ||
| assert net.trafo["oltc"].tolist() == [True] | ||
| assert net.trafo["test_kwargs"].tolist() == ["TestKW"] | ||
| assert net.trafo["vector_group"].tolist() == ["Dd5"] | ||
|
|
||
|
|
||
| def test_create_transformers3w(): | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While I think this change is a good Idea there seems to be one issue.
If the standard type includes one of the explicitly passed parameters this will fail.
Standard types in pandapower have a set of minimal required values that need to be set, but can take any additional values.
So I could create a standard_type that includes e.g a derating factor
df, with you're code change this would lead todfbeing passed twice as a keyword and lead to aTypeError: pandapower.create.trafo_create.create_transformers_from_parameters() got multiple values for keyword argument 'df'Reproducible example: