1818
1919from power_grid_model_io .converters import PandaPowerConverter
2020from power_grid_model_io .converters .pandapower_converter import (
21+ PP_COMPATIBILITY_VERSION_3_2_0 ,
22+ PP_CONVERSION_VERSION ,
2123 PandaPowerData ,
2224 get_loss_params_3ph ,
23- pp_curr_version ,
24- pp_ref_version ,
2525)
2626
27- from ...data .pandapower .pp_validation import pp_net , pp_net_3ph , pp_net_3ph_minimal_trafo
27+ from ...data .pandapower .pp_validation import (
28+ pp_net ,
29+ pp_net_3ph ,
30+ pp_net_3ph_minimal_trafo ,
31+ )
2832from ..utils import component_attributes_df , load_json_single_dataset
2933
3034pp = pytest .importorskip ("pandapower" , reason = "pandapower is not installed" )
3337PGM_PP_TEST_DATA = Path (__file__ ).parents [2 ] / "data" / "pandapower"
3438PGM_OUTPUT_FILE = PGM_PP_TEST_DATA / "pgm_output_data.json"
3539PGM_ASYM_OUTPUT_FILE = PGM_PP_TEST_DATA / "pgm_asym_output_data.json"
36- if pp_curr_version <= pp_ref_version :
40+ if PP_CONVERSION_VERSION < PP_COMPATIBILITY_VERSION_3_2_0 :
3741 PP_V2_NET_OUTPUT_FILE = PGM_PP_TEST_DATA / "v3.1.2" / "pp_v2_net_output.json"
3842 PP_V2_NET_3PH_OUTPUT_FILE = PGM_PP_TEST_DATA / "v3.1.2" / "pp_v2_net_3ph_output.json"
3943 PP_V2_NET_3PH_OUTPUT_FILE_CURRENT_LOADING = (
@@ -168,24 +172,33 @@ def check_result(net):
168172 i_c_lv = net .res_trafo_3ph .loc [:, "i_c_lv_ka" ] * 1000
169173
170174 np .testing .assert_allclose (
171- np .maximum (i_a_hv / i_max_hv , i_a_lv / i_max_lv ) * 100 , net .res_trafo_3ph .loading_a_percent
175+ np .maximum (i_a_hv / i_max_hv , i_a_lv / i_max_lv ) * 100 ,
176+ net .res_trafo_3ph .loading_a_percent ,
172177 )
173178 np .testing .assert_allclose (
174- np .maximum (i_b_hv / i_max_hv , i_b_lv / i_max_lv ) * 100 , net .res_trafo_3ph .loading_b_percent
179+ np .maximum (i_b_hv / i_max_hv , i_b_lv / i_max_lv ) * 100 ,
180+ net .res_trafo_3ph .loading_b_percent ,
175181 )
176182 np .testing .assert_allclose (
177- np .maximum (i_c_hv / i_max_hv , i_c_lv / i_max_lv ) * 100 , net .res_trafo_3ph .loading_c_percent
183+ np .maximum (i_c_hv / i_max_hv , i_c_lv / i_max_lv ) * 100 ,
184+ net .res_trafo_3ph .loading_c_percent ,
178185 )
179186 np .testing .assert_allclose (
180187 np .maximum (
181- np .maximum (net .res_trafo_3ph .loading_a_percent , net .res_trafo_3ph .loading_b_percent ),
188+ np .maximum (
189+ net .res_trafo_3ph .loading_a_percent ,
190+ net .res_trafo_3ph .loading_b_percent ,
191+ ),
182192 net .res_trafo_3ph .loading_c_percent ,
183193 ),
184194 net .res_trafo_3ph .loading_percent ,
185195 )
186196 np .testing .assert_allclose (
187197 np .maximum (
188- np .maximum (net .res_line_3ph .loading_a_percent , net .res_line_3ph .loading_b_percent ),
198+ np .maximum (
199+ net .res_line_3ph .loading_a_percent ,
200+ net .res_line_3ph .loading_b_percent ,
201+ ),
189202 net .res_line_3ph .loading_c_percent ,
190203 ),
191204 net .res_line_3ph .loading_percent ,
@@ -196,31 +209,49 @@ def compare_result(actual, expected, *, rtol):
196209 np .testing .assert_allclose (actual .trafo .vn_lv_kv , expected .trafo .vn_lv_kv , rtol = rtol )
197210 np .testing .assert_allclose (actual .trafo .sn_mva , expected .trafo .sn_mva , rtol = rtol )
198211 np .testing .assert_allclose (
199- actual .res_trafo_3ph .loc [:, "i_a_hv_ka" ], expected .res_trafo_3ph .loc [:, "i_a_hv_ka" ], rtol = rtol
212+ actual .res_trafo_3ph .loc [:, "i_a_hv_ka" ],
213+ expected .res_trafo_3ph .loc [:, "i_a_hv_ka" ],
214+ rtol = rtol ,
200215 )
201216 np .testing .assert_allclose (
202- actual .res_trafo_3ph .loc [:, "i_b_hv_ka" ], expected .res_trafo_3ph .loc [:, "i_b_hv_ka" ], rtol = rtol
217+ actual .res_trafo_3ph .loc [:, "i_b_hv_ka" ],
218+ expected .res_trafo_3ph .loc [:, "i_b_hv_ka" ],
219+ rtol = rtol ,
203220 )
204221 np .testing .assert_allclose (
205- actual .res_trafo_3ph .loc [:, "i_c_hv_ka" ], expected .res_trafo_3ph .loc [:, "i_c_hv_ka" ], rtol = rtol
222+ actual .res_trafo_3ph .loc [:, "i_c_hv_ka" ],
223+ expected .res_trafo_3ph .loc [:, "i_c_hv_ka" ],
224+ rtol = rtol ,
206225 )
207226 np .testing .assert_allclose (
208- actual .res_trafo_3ph .loc [:, "i_a_lv_ka" ], expected .res_trafo_3ph .loc [:, "i_a_lv_ka" ], rtol = rtol
227+ actual .res_trafo_3ph .loc [:, "i_a_lv_ka" ],
228+ expected .res_trafo_3ph .loc [:, "i_a_lv_ka" ],
229+ rtol = rtol ,
209230 )
210231 np .testing .assert_allclose (
211- actual .res_trafo_3ph .loc [:, "i_b_lv_ka" ], expected .res_trafo_3ph .loc [:, "i_b_lv_ka" ], rtol = rtol
232+ actual .res_trafo_3ph .loc [:, "i_b_lv_ka" ],
233+ expected .res_trafo_3ph .loc [:, "i_b_lv_ka" ],
234+ rtol = rtol ,
212235 )
213236 np .testing .assert_allclose (
214- actual .res_trafo_3ph .loc [:, "i_c_lv_ka" ], expected .res_trafo_3ph .loc [:, "i_c_lv_ka" ], rtol = rtol
237+ actual .res_trafo_3ph .loc [:, "i_c_lv_ka" ],
238+ expected .res_trafo_3ph .loc [:, "i_c_lv_ka" ],
239+ rtol = rtol ,
215240 )
216241 np .testing .assert_allclose (
217- actual .res_trafo_3ph .loading_a_percent , expected .res_trafo_3ph .loading_a_percent , rtol = rtol
242+ actual .res_trafo_3ph .loading_a_percent ,
243+ expected .res_trafo_3ph .loading_a_percent ,
244+ rtol = rtol ,
218245 )
219246 np .testing .assert_allclose (
220- actual .res_trafo_3ph .loading_b_percent , expected .res_trafo_3ph .loading_b_percent , rtol = rtol
247+ actual .res_trafo_3ph .loading_b_percent ,
248+ expected .res_trafo_3ph .loading_b_percent ,
249+ rtol = rtol ,
221250 )
222251 np .testing .assert_allclose (
223- actual .res_trafo_3ph .loading_c_percent , expected .res_trafo_3ph .loading_c_percent , rtol = rtol
252+ actual .res_trafo_3ph .loading_c_percent ,
253+ expected .res_trafo_3ph .loading_c_percent ,
254+ rtol = rtol ,
224255 )
225256
226257 pgm_net = pp_net_3ph_minimal_trafo ()
@@ -283,7 +314,11 @@ def test_attributes(output_data: Tuple[PandaPowerData, PandaPowerData], componen
283314
284315
285316@pytest .mark .parametrize (("component" , "attribute" ), component_attributes_df (load_and_convert_pgm_data_3ph ()))
286- def test_attributes_3ph (output_data_3ph : Tuple [PandaPowerData , PandaPowerData ], component : str , attribute : str ):
317+ def test_attributes_3ph (
318+ output_data_3ph : Tuple [PandaPowerData , PandaPowerData ],
319+ component : str ,
320+ attribute : str ,
321+ ):
287322 """
288323 For each attribute, check if the actual values are consistent with the expected values for asym
289324 """
0 commit comments