internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: e2nIEE/pandapower

Issue:
Confusing parameter descriptions in documentation
Parameter description is confusing in seveal places in the documentation.  For ex. lines results are described as below. 

i_**from**_ka Current at **to** bus [kA]
i_**to**_ka  Current at **from** bus [kA]
Is this a mistake??

https://pandapower.readthedocs.io/en/v2.2.2/elements/line.html





Discussion:
> Is this a mistake??

Yes it is, obviously it is the other way around... funny that no one every noticed. ;) Do you want to put in a Pull Request?

Resolving patch:
diff --git a/pandapower/create.py b/pandapower/create.py
--- a/pandapower/create.py
+++ b/pandapower/create.py
@@ -484,9 +484,6 @@ def create_empty_network(name="", f_hz=50., sn_mva=1, add_stdtypes=True):
         "f_hz": f_hz,
         "sn_mva": sn_mva
     })
-    net._empty_res_line_sc = net._empty_res_line
-    net._empty_res_trafo_sc = net._empty_res_trafo
-    net._empty_res_trafo3w_sc = net._empty_res_trafo3w
     
     net._empty_res_load_3ph = net._empty_res_load
     net._empty_res_sgen_3ph = net._empty_res_sgen
diff --git a/pandapower/shortcircuit/results.py b/pandapower/shortcircuit/results.py
--- a/pandapower/shortcircuit/results.py
+++ b/pandapower/shortcircuit/results.py
@@ -13,7 +13,6 @@
 from pandapower.results_bus import _get_bus_idx, _set_buses_out_of_service
 from pandapower.results import _get_aranged_lookup, _get_branch_results
 from pandapower.shortcircuit.idx_bus import C_MIN, C_MAX
-from pandapower.results import reset_results
 
 def _extract_results(net, ppc, ppc_0):
     _get_bus_results(net, ppc, ppc_0)
@@ -23,6 +22,10 @@ def _extract_results(net, ppc, ppc_0):
         _get_trafo3w_results(net, ppc)
 
 def _extract_single_results(net, ppc):
+    for element in ["line", "trafo"]:
+        net["res_%s_sc"%element] = pd.DataFrame(np.nan, index=net[element].index,
+                                                columns=net["_empty_res_%s"%element].columns,
+                                                dtype='float')
     _get_single_bus_results(net, ppc)
     net["_options"]["ac"] = True
     net["_options"]["trafo_loading"] = "current"


Test patch:
Repository: e2nIEE/pandapower

Issue:
Wrong deprecated warning in init_time_steps
In the timeseries module there seems to be an error, as the following code produces some nonesense:

```
def init_time_steps(net, time_steps, **kwargs):
    # initializes time steps if as a range
    if not isinstance(time_steps, Iterable):
        if time_steps is None and ("start_step" in kwargs and "stop_step" in kwargs):
            logger.warning("start_step and stop_step are depricated. "
                           "Please use a tuple like time_steps = (start_step, stop_step) instead or a list")
            time_steps = range(kwargs["start_step"], kwargs["stop_step"] + 1)
        elif isinstance(time_steps, tuple):
            time_steps = range(time_steps[0], time_steps[1])
        else:
            logger.warning("No time steps to calculate are specified. "
                           "I'll check the datasource of the first controller for avaiable time steps")
            max_timestep = net.controller.object.at[0].data_source.get_time_steps_len()
            time_steps = range(max_timestep)
    return time_steps
```

Tuples are iterables, which is why when using (start_step, stop_step) only those two steps will be simulated, whereas when using start_step and stop_step as kwargs a deprecated warning occurs. Can we change this to check for tuples as the very first step?


Discussion:

Resolving patch:
diff --git a/pandapower/timeseries/run_time_series.py b/pandapower/timeseries/run_time_series.py
--- a/pandapower/timeseries/run_time_series.py
+++ b/pandapower/timeseries/run_time_series.py
@@ -196,12 +196,12 @@ def get_recycle_settings(net, **kwargs):
 def init_time_steps(net, time_steps, **kwargs):
     # initializes time steps if as a range
     if not isinstance(time_steps, Iterable):
-        if time_steps is None and ("start_step" in kwargs and "stop_step" in kwargs):
+        if isinstance(time_steps, tuple):
+            time_steps = range(time_steps[0], time_steps[1])
+        elif time_steps is None and ("start_step" in kwargs and "stop_step" in kwargs):
             logger.warning("start_step and stop_step are depricated. "
                            "Please use a tuple like time_steps = (start_step, stop_step) instead or a list")
             time_steps = range(kwargs["start_step"], kwargs["stop_step"] + 1)
-        elif isinstance(time_steps, tuple):
-            time_steps = range(time_steps[0], time_steps[1])
         else:
             logger.warning("No time steps to calculate are specified. "
                            "I'll check the datasource of the first controller for avaiable time steps")


Test patch:
Repository: e2nIEE/pandapower

Issue:
Estimation results
Hello,

I think in python file pandapower -> estimation -> results.py there is a baseMVA missing in the calculation.

I think line 22 should be adjusted to this, or similar:

`Sbus = np.multiply(V, np.conj(Ybus * V)) * baseMVA`

Thanks


Discussion:
Hi @bbadetcauk, I think you are right. Thanks a lot for reporting it!

Resolving patch:
diff --git a/pandapower/estimation/results.py b/pandapower/estimation/results.py
--- a/pandapower/estimation/results.py
+++ b/pandapower/estimation/results.py
@@ -19,7 +19,7 @@ def _calc_power_flow(ppci, V):
     ppci['bus'], ppci['gen'], ppci['branch'] = pfsoln(baseMVA, bus, gen, branch, Ybus, Yf, Yt, V, ref, ref_gens)
 
     # calculate bus power injections
-    Sbus = np.multiply(V, np.conj(Ybus * V))
+    Sbus = np.multiply(V, np.conj(Ybus * V)) * baseMVA
     ppci["bus"][:, PD] = -Sbus.real  # saved in per unit, injection -> demand
     ppci["bus"][:, QD] = -Sbus.imag  # saved in per unit, injection -> demand
     return ppci


Test patch:
diff --git a/pandapower/test/estimation/test_opt_lp_estimation.py b/pandapower/test/estimation/test_opt_lp_estimation.py
--- a/pandapower/test/estimation/test_opt_lp_estimation.py
+++ b/pandapower/test/estimation/test_opt_lp_estimation.py
@@ -18,8 +18,8 @@
 from copy import deepcopy
 
 
-def test_case30_compare_classical_wls_opt_wls():
-    net = nw.case30()
+def test_case9_compare_classical_wls_opt_wls():
+    net = nw.case9()
     pp.runpp(net)
     add_virtual_meas_from_loadflow(net)
     
@@ -44,7 +44,7 @@ def test_case30_compare_classical_wls_opt_wls():
 
 
 def test_lp_lav():
-    net = nw.case14()
+    net = nw.case9()
     pp.runpp(net)
     add_virtual_meas_from_loadflow(net, p_std_dev=0.01, q_std_dev=0.01)
Repository: e2nIEE/pandapower

Issue:
Missing dependencies: xlswriter, xlrd, cryptography
Hi,

I am currently following the instructions for the installation of the development version, as shown here: https://www.pandapower.org/start/#develop

I have a brand new virtual environment on Python 3.8.3 (Windows 10, 64 bits), and the tests failed because of the following missing dependencies:

> Edit: Same result on Python 3.7.8.

1. xlsxwriter: `FAILED pandapower\test\api\test_file_io.py::test_excel[1] - ModuleNotFoundError: No module named 'xlsxwriter'`
2. xlrd: `FAILED pandapower\test\api\test_file_io.py::test_excel[1] - ImportError: Missing optional dependency 'xlrd'. Install xlrd >= 1.0.0 for Excel support Use pip or conda to install xlrd.`
3. cryptography: `FAILED pandapower\test\api\test_file_io.py::test_encrypted_json[1] - ModuleNotFoundError: No module named 'cryptography'`

The permanent solution would most likely be to add those to setup.py and mention them in the documentation, but you might want to check if you should restrict the version.

P.S.: The tests still ended up failing, but that's a seperate issue (see issue #876 ).


Discussion:

Resolving patch:
diff --git a/pandapower/__init__.py b/pandapower/__init__.py
--- a/pandapower/__init__.py
+++ b/pandapower/__init__.py
@@ -1,4 +1,4 @@
-__version__ = "2.3.0"
+__version__ = "2.3.1"
 
 import os
 pp_dir = os.path.dirname(os.path.realpath(__file__))
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -33,10 +33,10 @@
 
 setup(
     name='pandapower',
-    version='2.3.0',
+    version='2.3.1',
     author='Leon Thurner, Alexander Scheidler',
     author_email='leon.thurner@iee.fraunhofer.de, alexander.scheidler@iee.fraunhofer.de',
-    description='Convenient Power System Modelling and Analysis based on PYPOWER and pandas',
+    description='An easy to use open source tool for power system modeling, analysis and optimization with a high degree of automation.',
     long_description=long_description,
 	long_description_content_type='text/x-rst',
     url='http://www.pandapower.org',
@@ -45,11 +45,14 @@
                       "networkx",
                       "scipy",
                       "numpy>=0.11",
-                      "packaging"],
-    extras_require={":python_version<'3.0'": ["future"],
-                    "docs": ["numpydoc", "sphinx", "sphinx_rtd_theme"],
-                    "plotting": ["plotly", "matplotlib", "python-igraph"],
-                    "test": ["pytest", "pytest-xdist"]},
+                      "packaging",
+					  "xlsxwriter",
+					  "xlrd",
+					  "cryptography"],
+    extras_require={
+		"docs": ["numpydoc", "sphinx", "sphinx_rtd_theme"],
+		"plotting": ["plotly", "matplotlib", "python-igraph"],
+		"test": ["pytest", "pytest-xdist"]},
     packages=find_packages(),
     include_package_data=True,
     classifiers=classifiers


Test patch:
Repository: e2nIEE/pandapower

Issue:
bug in WLSZeroInjectionConstraintsAlgorithm
code in line 135 of the file, https://github.com/e2nIEE/pandapower/blob/develop/pandapower/estimation/algorithm/base.py

bugs when zero_injection_bus is empty.





Discussion:
Hi, I will add a warning here, since this algorithm is only for network with zero injection

Resolving patch:
diff --git a/pandapower/estimation/algorithm/base.py b/pandapower/estimation/algorithm/base.py
--- a/pandapower/estimation/algorithm/base.py
+++ b/pandapower/estimation/algorithm/base.py
@@ -132,6 +132,8 @@ class WLSZeroInjectionConstraintsAlgorithm(BaseAlgorithm):
     def estimate(self, eppci, **kwargs):
         # state vector built from delta, |V| and zero injections
         # Find pq bus with zero p,q and shunt admittance
+        if not np.any(eppci["bus"][:, bus_cols + ZERO_INJ_FLAG]):
+            raise UserWarning("Network has no bus with zero injections! Please use WLS instead!")
         zero_injection_bus = np.argwhere(eppci["bus"][:, bus_cols + ZERO_INJ_FLAG] == True).ravel()
         eppci["bus"][zero_injection_bus, [bus_cols + P, bus_cols + P_STD, bus_cols + Q, bus_cols + Q_STD]] = np.NaN
         # Withn pq buses with zero injection identify those who have also no p or q measurement


Test patch:
Repository: e2nIEE/pandapower

Issue:
networkx compatibility issue with python3.9
There's a networkx>=2.5 dependency to run pandapower under python3.9 as gcd has to be imported from math instead of fractions.


Discussion:

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -43,7 +43,7 @@
     url='http://www.pandapower.org',
     license='BSD',
     install_requires=["pandas>=0.17",
-                      "networkx",
+                      "networkx>=2.5",
                       "scipy<=1.6.0",
                       "numpy>=0.11",
                       "packaging",


Test patch:
Repository: e2nIEE/pandapower

Issue:
'plot_gens' unexpected in simple_plot()
It seems that `plot_gens` is an argument in `simple_plot()`, but is not documented. When attempting to set `plot_gens` when calling `simple_plot()`, I get the following error:

> TypeError: simple_plot() got an unexpected keyword argument 'plot_gens'

Version: 2.7.0


Discussion:

Resolving patch:
diff --git a/pandapower/plotting/simple_plot.py b/pandapower/plotting/simple_plot.py
--- a/pandapower/plotting/simple_plot.py
+++ b/pandapower/plotting/simple_plot.py
@@ -51,6 +51,8 @@ def simple_plot(net, respect_switches=False, line_width=1.0, bus_size=1.0, ext_g
             **trafo_size** (float, 1.0) - Relative size of trafos to plot.
 
             **plot_loads** (bool, False) - Flag to decide whether load symbols should be drawn.
+            
+            **plot_gens** (bool, False) - Flag to decide whether gen symbols should be drawn.
 
             **plot_sgens** (bool, False) - Flag to decide whether sgen symbols should be drawn.
 


Test patch:
Repository: e2nIEE/pandapower

Issue:
Problem with JSON serialization / deserialization when using numpy dtypes
In PR #1413 I came across a problem in one of the tests that makes use of a Tap Controller. In this controller type, some numpy types are used for attribute values, e.g. the attribute `element_in_service` is of type numpy._bool instead of bool. This can lead to errors in the JSON serialization / deserialization:

- In case of boolean values, the value is saved as string, when the type is numpy._bool. It is then retrieved as string and cannot be used correctly any more
- In case of numerical (e.g. numpy.float64), the precision between the original and retrieved value can differ, when restoring it as float.

How can we overcome this problem? This probably only occurs for JSONSerializables or pandapowerNet attributes, as we don't save other types of objects (except numpy and pandas, which automatically deal with this). I would suggest to change the serialization of numpy dtypes to also use signatures.

@rbolgaryn @lthurner Can you comment on this?


Discussion:

Resolving patch:
diff --git a/pandapower/io_utils.py b/pandapower/io_utils.py
--- a/pandapower/io_utils.py
+++ b/pandapower/io_utils.py
@@ -318,7 +318,9 @@ def transform_net_with_df_and_geo(net, point_geo_columns, line_geo_columns):
 
 
 def isinstance_partial(obj, cls):
-    if isinstance(obj, (pandapowerNet, tuple)):
+    # this function shall make sure that for the given classes, no default string functions are
+    # used, but the registered ones (to_serializable registry)
+    if isinstance(obj, (pandapowerNet, tuple, numpy.floating)):
         return False
     return isinstance(obj, cls)
 
@@ -802,13 +804,28 @@ def json_array(obj):
 @to_serializable.register(numpy.integer)
 def json_npint(obj):
     logger.debug("integer")
-    return int(obj)
+    d = with_signature(obj, int(obj), obj_module="numpy")
+    d.pop('dtype')
+    return d
 
 
 @to_serializable.register(numpy.floating)
 def json_npfloat(obj):
     logger.debug("floating")
-    return float(obj)
+    if numpy.isnan(obj):
+        d = with_signature(obj, str(obj), obj_module="numpy")
+    else:
+        d = with_signature(obj, float(obj), obj_module="numpy")
+    d.pop('dtype')
+    return d
+
+
+@to_serializable.register(numpy.bool_)
+def json_npbool(obj):
+    logger.debug("boolean")
+    d = with_signature(obj, "true" if obj else "false", obj_module="numpy")
+    d.pop('dtype')
+    return d
 
 
 @to_serializable.register(numbers.Number)


Test patch:
diff --git a/pandapower/test/api/test_file_io.py b/pandapower/test/api/test_file_io.py
--- a/pandapower/test/api/test_file_io.py
+++ b/pandapower/test/api/test_file_io.py
@@ -6,15 +6,15 @@
 import copy
 import json
 import os
-import sys
 
 import numpy as np
+import pandas as pd
+import pytest
+
 import pandapower as pp
 import pandapower.control as control
 import pandapower.networks as networks
 import pandapower.topology as topology
-import pandas as pd
-import pytest
 from pandapower import pp_dir
 from pandapower.io_utils import PPJSONEncoder, PPJSONDecoder
 from pandapower.test.toolbox import assert_net_equal, create_test_network
Repository: e2nIEE/pandapower

Issue:
Deprecation warning due to import from pandas.util.testing
In future, it shall be importing from pandas.testing . When should we implement this? I am not very sure of which is the earliest version of pandas that is compatible with the new practice. So, for backwards compatibility we might still keep it that way...


Discussion:
As far as I can see, pandas.util.testing has been replaced by pandas.testing in all imports in pandapower. Can we close this issue, or would you prefer to have a version check @SteffenMeinecke ?
A version check would be better. As fas as I reviewed, the change of `util.testing` to `testing` came with version 0.x -> 1.x.
https://github.com/pandas-dev/pandas/blob/0.25.x/pandas/testing.py

Resolving patch:
diff --git a/pandapower/io_utils.py b/pandapower/io_utils.py
--- a/pandapower/io_utils.py
+++ b/pandapower/io_utils.py
@@ -22,7 +22,11 @@
 from networkx.readwrite import json_graph
 from numpy import ndarray, generic, equal, isnan, allclose, any as anynp
 from packaging import version
-from pandas.testing import assert_series_equal, assert_frame_equal
+
+try:
+    from pandas.testing import assert_series_equal, assert_frame_equal
+except ImportError:
+    from pandas.util.testing import assert_series_equal, assert_frame_equal
 
 try:
     from cryptography.fernet import Fernet
diff --git a/pandapower/toolbox.py b/pandapower/toolbox.py
--- a/pandapower/toolbox.py
+++ b/pandapower/toolbox.py
@@ -9,11 +9,10 @@
 from collections.abc import Iterable
 from itertools import chain
 
+import networkx as nx
 import numpy as np
 import pandas as pd
-import pandas.testing as pdt
 from packaging import version
-
 from pandapower.auxiliary import get_indices, pandapowerNet, _preserve_dtypes
 from pandapower.create import create_switch, create_line_from_parameters, \
     create_impedance, create_empty_network, create_gen, create_ext_grid, \
@@ -21,7 +20,11 @@
 from pandapower.opf.validate_opf_input import _check_necessary_opf_parameters
 from pandapower.run import runpp
 from pandapower.std_types import change_std_type
-import networkx as nx
+
+try:
+    import pandas.testing as pdt
+except ImportError:
+    import pandas.util.testing as pdt
 
 try:
     from networkx.utils.misc import graphs_equal


Test patch:
Repository: e2nIEE/pandapower

Issue:
create_annotation_collection is not working
I get the Error Message `AttributeError: 'CustomTextPath' object has no attribute 'set_size'` when I want to create an annotation _collection. There is a minimal example below to reproduce the issue.

The set_size method is provided by the [TextPath class in matplotlib](https://github.com/matplotlib/matplotlib/blob/d82a61fdc563b49cce2744a3616ea43ac9a306d6/lib/matplotlib/textpath.py#L394) and CustomTextPath [creates an object](https://github.com/e2nIEE/pandapower/blob/8c7844aa97e307933bda8910a503ea16dd5ae84e/pandapower/plotting/collections.py#L58) of that class, so it would be reasonable to think the 'CustomTextPath' object had the attribute 'set_size'. Any ideas?

```
import numpy as np
import pandapower.plotting as plot
import pandapower.networks as nw

net = nw.mv_oberrhein()
buses = net.bus.index.tolist() # list of all bus indices
coords = zip(net.bus_geodata.x.loc[buses].values, net.bus_geodata.y.loc[buses].values) # tuples of all bus coords

bic = plot.create_annotation_collection(size=300, texts=np.char.mod('%d', buses), coords=coords, zorder=3, color='k')
plot.draw_collections([bic], figsize=(8,6)) # plot lines, buses and bus indices
```

-->
```
Traceback (most recent call last):
  File "...\lib\site-packages\IPython\core\interactiveshell.py", line 3251, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-14-91bac5e5930c>", line 9, in <module>
    bic = plot.create_annotation_collection(size=300, texts=np.char.mod('%d', buses), coords=coords, zorder=3, color='k')
  File "...\pandapower\plotting\collections.py", line 98, in create_annotation_collection
    tp.append(PathPatch(CustomTextPath(c, t, size=size, prop=prop)))
  File "...\pandapower\plotting\collections.py", line 58, in __init__
    TextPath.__init__(self, xy, s, size=size, prop=prop,
  File "...\lib\site-packages\matplotlib\textpath.py", line 384, in __init__
    self.set_size(size)
AttributeError: 'CustomTextPath' object has no attribute 'set_size'
```
Python: 3.9.9
matplotlib: 3.5.1
pandapower: develop, commit dde080ba1a86bb042085852c9bcd3546e0fee6f5 (7.2.2022)


Discussion:

Resolving patch:
diff --git a/pandapower/plotting/collections.py b/pandapower/plotting/collections.py
--- a/pandapower/plotting/collections.py
+++ b/pandapower/plotting/collections.py
@@ -33,7 +33,7 @@
 logger = logging.getLogger(__name__)
 
 
-class CustomTextPath():
+class CustomTextPath(TextPath):
     """
     Create a path from the text. This class provides functionality for deepcopy, which is not
     implemented for TextPath.


Test patch:
Repository: e2nIEE/pandapower

Issue:
plotting.geo convert_gis_to_geodata leads to issue if run after convert_geodata_to_gis
```python
import pandapower.plotting.geo as geo
import pandapower.networks as pn

net = pn.mv_oberrhein()

geo.convert_geodata_to_gis(net)
geo.convert_gis_to_geodata(net)
```

results in `AttributeError: 'Series' object has no attribute 'geometry'`


Discussion:

Resolving patch:
diff --git a/pandapower/plotting/geo.py b/pandapower/plotting/geo.py
--- a/pandapower/plotting/geo.py
+++ b/pandapower/plotting/geo.py
@@ -77,7 +77,7 @@ def _transform_branch_geometry_to_coords(branch_geo):
     :type branch_geo: geopandas.GeoDataFrame
     :return: branch_geo - The given geodataframe with coords
     """
-    branch_geo["coords"] = branch_geo["coords"].geometry.apply(lambda x: list(x.coords))
+    branch_geo["coords"] = branch_geo.geometry.apply(lambda x: list(x.coords))
     return branch_geo
 
 


Test patch:
Repository: e2nIEE/pandapower

Issue:
fix bug with old values from AC power flow for results of DC power fl…
…ow for res_bus (fixes #1996)


Discussion:
@marceldipp can you please take a look?

Resolving patch:
diff --git a/pandapower/estimation/util.py b/pandapower/estimation/util.py
--- a/pandapower/estimation/util.py
+++ b/pandapower/estimation/util.py
@@ -60,8 +60,9 @@ def _get_bus_ppc_mapping(net, bus_to_be_fused):
         set(net.ext_grid.bus)).union(set(net.ward.bus)).union(
         set(net.xward.bus))
     # Run dc pp to get the ppc we need
-    pp.rundcpp(net)
-
+    #pp.rundcpp(net)
+    
+    pp.runpp(net, calculate_voltage_angles=True)
 
     bus_ppci = pd.DataFrame(data=net._pd2ppc_lookups['bus'], columns=["bus_ppci"])
     bus_ppci['bus_with_elements'] = bus_ppci.index.isin(bus_with_elements)


Test patch:
diff --git a/pandapower/test/estimation/test_wls_estimation.py b/pandapower/test/estimation/test_wls_estimation.py
--- a/pandapower/test/estimation/test_wls_estimation.py
+++ b/pandapower/test/estimation/test_wls_estimation.py
@@ -712,7 +712,7 @@ def create_net_with_bb_switch():
 def test_net_with_bb_switch_no_fusing():
     net = create_net_with_bb_switch()
     success_none = estimate(net, tolerance=1e-5, fuse_buses_with_bb_switch=None)
-
+    pp.runpp(net, calculate_voltage_angles=True)
     assert success_none
     assert np.allclose(net.res_bus.va_degree.values,net.res_bus_est.va_degree.values, 1e-2)
     assert np.allclose(net.res_bus.vm_pu.values,net.res_bus_est.vm_pu.values, 1e-2)
@@ -724,6 +724,7 @@ def test_net_with_bb_switch_no_fusing():
 def test_net_with_bb_switch_fuse_one():
     net = create_net_with_bb_switch()
     success = estimate(net, tolerance=1e-5, fuse_buses_with_bb_switch=[1])
+    pp.runpp(net, calculate_voltage_angles=True)
     assert success
     assert np.allclose(net.res_bus.va_degree.values,net.res_bus_est.va_degree.values, 1e-2)
     assert np.allclose(net.res_bus.vm_pu.values,net.res_bus_est.vm_pu.values, 1e-2)