power-grid-model-io 1.2.62__py3-none-any.whl → 1.2.64__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of power-grid-model-io might be problematic. Click here for more details.

@@ -699,7 +699,9 @@ class PandaPowerConverter(BaseConverter[PandaPowerData]):
699
699
  mag0_percent = self._get_pp_attr("trafo", "mag0_percent", expected_type="f8", default=np.nan)
700
700
  mag0_rx = self._get_pp_attr("trafo", "mag0_rx", expected_type="f8", default=np.nan)
701
701
  # Calculate rx ratio of magnetising branch
702
- mag_g = pfe / (sn_mva * 1000)
702
+ valid = np.logical_and(np.not_equal(sn_mva, 0.0), np.isfinite(sn_mva))
703
+ mag_g = np.divide(pfe, sn_mva * 1000, where=valid)
704
+ mag_g[np.logical_not(valid)] = np.nan
703
705
  rx_mag = mag_g / np.sqrt(i_no_load * i_no_load * 1e-4 - mag_g * mag_g)
704
706
  # positive and zero sequence magnetising impedance must be equal.
705
707
  # mag0_percent = z0mag / z0.
@@ -727,8 +729,8 @@ class PandaPowerConverter(BaseConverter[PandaPowerData]):
727
729
  # Default vector group for odd clocks = DYn and for even clocks = YNyn
728
730
  no_vector_groups = np.isnan(winding_types["winding_from"]) | np.isnan(winding_types["winding_to"])
729
731
  no_vector_groups_dyn = no_vector_groups & (clocks % 2)
730
- winding_types[no_vector_groups] = WindingType.wye_n
731
- winding_types["winding_from"][no_vector_groups_dyn] = WindingType.delta
732
+ winding_types.loc[no_vector_groups] = WindingType.wye_n
733
+ winding_types.loc[no_vector_groups_dyn, "winding_from"] = WindingType.delta
732
734
 
733
735
  # Create PGM array
734
736
  pgm_transformers = initialize_array(data_type="input", component_type="transformer", shape=len(pp_trafo))
@@ -838,8 +840,8 @@ class PandaPowerConverter(BaseConverter[PandaPowerData]):
838
840
  no_vector_groups_ynd2 = no_vector_groups & (clocks_12 % 2)
839
841
  no_vector_groups_ynd3 = no_vector_groups & (clocks_13 % 2)
840
842
  winding_types[no_vector_groups] = WindingType.wye_n
841
- winding_types["winding_2"][no_vector_groups_ynd2] = WindingType.delta
842
- winding_types["winding_3"][no_vector_groups_ynd3] = WindingType.delta
843
+ winding_types.loc[no_vector_groups_ynd2, "winding_2"] = WindingType.delta
844
+ winding_types.loc[no_vector_groups_ynd3, "winding_3"] = WindingType.delta
843
845
 
844
846
  pgm_3wtransformers = initialize_array(
845
847
  data_type="input", component_type="three_winding_transformer", shape=len(pp_trafo3w)
@@ -1012,9 +1014,11 @@ class PandaPowerConverter(BaseConverter[PandaPowerData]):
1012
1014
  * 1e6
1013
1015
  )
1014
1016
  p_spec = pgm_sym_loads_from_motor["p_specified"]
1015
- pgm_sym_loads_from_motor["q_specified"] = np.sqrt(
1016
- np.power(p_spec / self._get_pp_attr("motor", "cos_phi", expected_type="f8"), 2) - p_spec**2
1017
- )
1017
+ cos_phi = self._get_pp_attr("motor", "cos_phi", expected_type="f8")
1018
+ valid = np.logical_and(np.not_equal(cos_phi, 0.0), np.isfinite(cos_phi))
1019
+ q_spec = np.sqrt(np.power(np.divide(p_spec, cos_phi, where=valid), 2, where=valid) - p_spec**2, where=valid)
1020
+ q_spec[np.logical_not(valid)] = np.nan
1021
+ pgm_sym_loads_from_motor["q_specified"] = q_spec
1018
1022
 
1019
1023
  # If input data of loads has already been filled then extend it with data of motors. If it is empty and there
1020
1024
  # is no data about loads,then assign motor data to it
@@ -1613,7 +1617,7 @@ class PandaPowerConverter(BaseConverter[PandaPowerData]):
1613
1617
  links = self.pgm_output_data["link"]
1614
1618
  # For links, i_from = i_to = i_ka / 1e3
1615
1619
  link_ids = self._get_pp_ids("switch", links["id"], "b2b_switches")
1616
- pp_switches_output["i_ka"][link_ids] = links["i_from"] * 1e-3
1620
+ pp_switches_output.loc[link_ids, "i_ka"] = links["i_from"] * 1e-3
1617
1621
 
1618
1622
  assert "res_switch" not in self.pp_output_data
1619
1623
  self.pp_output_data["res_switch"] = pp_switches_output
@@ -2247,7 +2251,7 @@ class PandaPowerConverter(BaseConverter[PandaPowerData]):
2247
2251
  Returns:
2248
2252
  the "closed" value of a Switch
2249
2253
  """
2250
- switch_state = (
2254
+ switch_states = (
2251
2255
  component[["index", bus]]
2252
2256
  .merge(
2253
2257
  switches,
@@ -2255,10 +2259,11 @@ class PandaPowerConverter(BaseConverter[PandaPowerData]):
2255
2259
  left_on=["index", bus],
2256
2260
  right_on=["element", "bus"],
2257
2261
  )
2258
- .fillna(True)
2259
- .set_index(component.index)
2262
+ .set_index(component.index)["closed"]
2260
2263
  )
2261
- return pd.Series(switch_state["closed"])
2264
+
2265
+ # no need to fill na because bool(NaN) == True
2266
+ return pd.Series(switch_states.astype(bool, copy=False))
2262
2267
 
2263
2268
  def get_switch_states(self, pp_table: str) -> pd.DataFrame:
2264
2269
  """
@@ -2414,7 +2419,7 @@ class PandaPowerConverter(BaseConverter[PandaPowerData]):
2414
2419
  if any(nan_values):
2415
2420
  attr_data = attr_data.fillna(value=default, inplace=False)
2416
2421
 
2417
- return attr_data.to_numpy(dtype=exp_dtype)
2422
+ return attr_data.to_numpy(dtype=exp_dtype, copy=True)
2418
2423
 
2419
2424
  def get_id(self, pp_table: str, pp_idx: int, name: Optional[str] = None) -> int:
2420
2425
  """
@@ -140,7 +140,7 @@ class ExcelFileStore(BaseDataStore[TabularData]):
140
140
 
141
141
  to_rename = self._check_duplicate_values(sheet_name=sheet_name, data=data)
142
142
  if to_rename:
143
- columns = data.columns.values
143
+ columns = data.columns.values.copy()
144
144
  for col_idx, new_name in to_rename.items():
145
145
  self._log.warning(
146
146
  "Column is renamed",
@@ -80,12 +80,12 @@ class TabularData:
80
80
  # If the index 'column' is requested, but no column called 'index' exist,
81
81
  # return the index of the dataframe as if it were an actual column.
82
82
  if column_name == "index" and "index" not in table_data and hasattr(table_data, "index"):
83
- return pd.Series(table_data.index, name="index")
83
+ return pd.Series(table_data.index, name="index", copy=False)
84
84
 
85
85
  column_data = table_data[column_name]
86
86
 
87
87
  if isinstance(column_data, np.ndarray):
88
- column_data = pd.Series(column_data, name=column_name)
88
+ column_data = pd.Series(column_data, name=column_name, copy=False)
89
89
 
90
90
  # If unit information is available, convert the unit
91
91
  if not isinstance(column_data, pd.Series):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: power-grid-model-io
3
- Version: 1.2.62
3
+ Version: 1.2.64
4
4
  Summary: Power Grid Model Input/Output
5
5
  Author-email: Contributors to the Power Grid Model project <powergridmodel@lfenergy.org>
6
6
  License: MPL-2.0
@@ -34,7 +34,8 @@ Requires-Dist: pre-commit ; extra == 'dev'
34
34
  Requires-Dist: pylint ; extra == 'dev'
35
35
  Requires-Dist: pytest ; extra == 'dev'
36
36
  Requires-Dist: pytest-cov ; extra == 'dev'
37
- Requires-Dist: pydantic ; extra == 'dev'
37
+ Requires-Dist: pydantic >2 ; extra == 'dev'
38
+ Requires-Dist: numba ; extra == 'dev'
38
39
  Provides-Extra: doc
39
40
  Requires-Dist: sphinx ; extra == 'doc'
40
41
  Requires-Dist: myst-nb ; extra == 'doc'
@@ -7,19 +7,19 @@ power_grid_model_io/config/excel/vision_en.yaml,sha256=a6BtSeMzGumsUSoDqzZHyx2cp
7
7
  power_grid_model_io/config/excel/vision_nl.yaml,sha256=ps-vKUvYcIev7fxx5rIQqHe1ukP_WjHZvqF3AcLswd8,19226
8
8
  power_grid_model_io/converters/__init__.py,sha256=kmbjFW6kVr30fmHb6mAoD7DQAqmbrsOuF1ewd8b0Q3M,408
9
9
  power_grid_model_io/converters/base_converter.py,sha256=LNrDo1kUUuBkLMgZpGm0MW5rfr8nLoFcGCJGRR7ZuiY,6044
10
- power_grid_model_io/converters/pandapower_converter.py,sha256=05iNHqqVFphXRNsNE7aumkZGybY_-FOj1S8S1UhQo64,113429
10
+ power_grid_model_io/converters/pandapower_converter.py,sha256=THJzytVLQDSOQVOj5y9HR2Wlz1QolAr0DEzZzKhntWU,113868
11
11
  power_grid_model_io/converters/pgm_json_converter.py,sha256=KKZEBLVW1hsS2YjOsUO6EBrXhvwPVl9VhkUNEw-3gWk,13066
12
12
  power_grid_model_io/converters/tabular_converter.py,sha256=hMb0pmnlq83GJEfOqr3K7XXsSiA_SYyQKHW1i6F5FSY,30577
13
13
  power_grid_model_io/converters/vision_excel_converter.py,sha256=aT_e_XSX4jQ3V-KlNxF5VGvWoM8uxOLpbL6qZCDmgAg,3636
14
14
  power_grid_model_io/data_stores/__init__.py,sha256=qwbj1j-Aa_yRB-E3j35pEVtF3mgH8CVIXAnog5mOry0,138
15
15
  power_grid_model_io/data_stores/base_data_store.py,sha256=XKdQY6Thrt_o7vtMXvTJFl1TCwBkSZVcImhbHXz23ls,1367
16
16
  power_grid_model_io/data_stores/csv_dir_store.py,sha256=H8ICXZRLDvp9OkbjkfHnoh4y7uNSXNepHAW6W53VsIw,1877
17
- power_grid_model_io/data_stores/excel_file_store.py,sha256=Pxgp_3OHLljHRnWdLtX1Ma3m7erl81v0TO8P5A1guWg,8615
17
+ power_grid_model_io/data_stores/excel_file_store.py,sha256=WI8pauQNYLOEu7hsrHU7o8yJ1tG3IAN2XUq920BQKps,8622
18
18
  power_grid_model_io/data_stores/json_file_store.py,sha256=0njL2YZn_fImNcZqnIRpHp2UtIS6WGaQQ46TjIK8tyo,3954
19
19
  power_grid_model_io/data_stores/vision_excel_file_store.py,sha256=zU-zGktLmU7a808KwppiMc2YeCPfqjo03lRW0neEuQ4,805
20
20
  power_grid_model_io/data_types/__init__.py,sha256=63A_PkOsQkVd3To7Kl4FTUX7lbPG9BS9MSLzXTW6Ktk,383
21
21
  power_grid_model_io/data_types/_data_types.py,sha256=9xH5vBGrRVUSlPh4HXmORtKo3LFEhJEy3iTQqG7wsFA,1664
22
- power_grid_model_io/data_types/tabular_data.py,sha256=JaJRWaOlVTqb7nMXoRUovUtiqnFyDPC_wFbO7O5lT7s,8341
22
+ power_grid_model_io/data_types/tabular_data.py,sha256=RRy2rZoXgNBDWYc8GuuqTRoyAK_0e_wb4CF2jULoKNE,8365
23
23
  power_grid_model_io/functions/__init__.py,sha256=pamhvKX5c_5fkVMRrUp6zhHWex2R63otRJk1Sfsw6y0,495
24
24
  power_grid_model_io/functions/_functions.py,sha256=tqwwZ0G8AeDza0IiS6CSMwKB0lV1hDo2D8e9-ARHXQM,2843
25
25
  power_grid_model_io/functions/phase_to_phase.py,sha256=zbaDXIj8S4cLO42LjkpcQoUrEW1frzBUj1OmKu-xkTg,4459
@@ -37,8 +37,8 @@ power_grid_model_io/utils/json.py,sha256=dQDRd2Vb8pfqLU2hTuWYv2cpSIBBbFhd0LOBP21
37
37
  power_grid_model_io/utils/modules.py,sha256=a4IdozSL-sOZcmIQON_aQS7-cpnCyt-3p7zs40wRFkU,928
38
38
  power_grid_model_io/utils/parsing.py,sha256=XB1QSHnslIieFJBKFXZCtiydqpOqQBiX_CXDbItXgAQ,4522
39
39
  power_grid_model_io/utils/zip.py,sha256=VXHX4xWPPZbhOlZUAbMDy3MgQFzK6_l7sRvGXihNUY4,3875
40
- power_grid_model_io-1.2.62.dist-info/LICENSE,sha256=7Pm2fWFFHHUG5lDHed1vl5CjzxObIXQglnYsEdtjo_k,14907
41
- power_grid_model_io-1.2.62.dist-info/METADATA,sha256=2tS69Nnadxj28ehsOckZix4op9Tj7zHgwx-Z1Aa-eNE,8000
42
- power_grid_model_io-1.2.62.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
43
- power_grid_model_io-1.2.62.dist-info/top_level.txt,sha256=7sq9VveemMm2R0RgTBa4tH8y_xF4_1hxbufmX9OjCTo,20
44
- power_grid_model_io-1.2.62.dist-info/RECORD,,
40
+ power_grid_model_io-1.2.64.dist-info/LICENSE,sha256=7Pm2fWFFHHUG5lDHed1vl5CjzxObIXQglnYsEdtjo_k,14907
41
+ power_grid_model_io-1.2.64.dist-info/METADATA,sha256=_wlckfWSUivW-ck5lk3ua4zDOlagu5Hkh0D3XREAqOM,8041
42
+ power_grid_model_io-1.2.64.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
43
+ power_grid_model_io-1.2.64.dist-info/top_level.txt,sha256=7sq9VveemMm2R0RgTBa4tH8y_xF4_1hxbufmX9OjCTo,20
44
+ power_grid_model_io-1.2.64.dist-info/RECORD,,