prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <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
  
  </issue>
  <code>
  [start of pandapower/estimation/results.py]
  1 # -*- coding: utf-8 -*-
  2 
  3 # Copyright (c) 2016-2020 by University of Kassel and Fraunhofer Institute for Energy Economics
  4 # and Energy System Technology (IEE), Kassel. All rights reserved.
  5 
  6 import numpy as np
  7 
  8 from pandapower.pypower.idx_bus import PD, QD
  9 from pandapower.pf.ppci_variables import _get_pf_variables_from_ppci
  10 from pandapower.pf.pfsoln_numba import pfsoln
  11 from pandapower.results import _copy_results_ppci_to_ppc, _extract_results_se, init_results
  12 from pandapower.auxiliary import _add_pf_options, get_values, _clean_up
  13 
  14 def _calc_power_flow(ppci, V):
  15     # store results for all elements
  16     # calculate branch results (in ppc_i)
  17     baseMVA, bus, gen, branch, ref, pv, pq, _, _, _, ref_gens = _get_pf_variables_from_ppci(ppci)
  18     Ybus, Yf, Yt = ppci['internal']['Ybus'], ppci['internal']['Yf'], ppci['internal']['Yt']
  19     ppci['bus'], ppci['gen'], ppci['branch'] = pfsoln(baseMVA, bus, gen, branch, Ybus, Yf, Yt, V, ref, ref_gens)
  20 
  21     # calculate bus power injections
  22     Sbus = np.multiply(V, np.conj(Ybus * V))
  23     ppci["bus"][:, PD] = -Sbus.real  # saved in per unit, injection -> demand
  24     ppci["bus"][:, QD] = -Sbus.imag  # saved in per unit, injection -> demand
  25     return ppci
  26 
  27 
  28 def _extract_result_ppci_to_pp(net, ppc, ppci):
  29     # convert to pandapower indices
  30     ppc = _copy_results_ppci_to_ppc(ppci, ppc, mode="se")
  31 
  32     # extract results from ppc
  33     try:
  34         _add_pf_options(net, tolerance_mva=1e-8, trafo_loading="current",
  35                         numba=True, ac=True, algorithm='nr', max_iteration="auto")
  36     except:
  37         pass
  38     # writes res_bus.vm_pu / va_degree and res_line
  39     _extract_results_se(net, ppc)
  40 
  41     # restore backup of previous results
  42     _rename_results(net)
  43 
  44     # additionally, write bus power demand results (these are not written in _extract_results)
  45     mapping_table = net["_pd2ppc_lookups"]["bus"]
  46     net.res_bus_est.index = net.bus.index
  47     net.res_bus_est.p_mw = get_values(ppc["bus"][:, 2], net.bus.index.values,
  48                                       mapping_table)
  49     net.res_bus_est.q_mvar = get_values(ppc["bus"][:, 3], net.bus.index.values,
  50                                         mapping_table)
  51 
  52     _clean_up(net)
  53     # delete results which are not correctly calculated
  54     for k in list(net.keys()):
  55         if k.startswith("res_") and k.endswith("_est") and \
  56                 k not in ("res_bus_est", "res_line_est", "res_trafo_est", "res_trafo3w_est"):
  57             del net[k]
  58     return net
  59 
  60 
  61 def _copy_power_flow_results(net):
  62     """
  63     copy old power flow results (if they exist) into res_*_power_flow tables for backup
  64     :param net: pandapower grid
  65     :return:
  66     """
  67     elements_to_init = ["bus", "ext_grid", "line", "load", "load_3ph" "sgen", "sgen_3ph", "trafo", "trafo3w",
  68                         "shunt", "impedance", "gen", "ward", "xward", "dcline"]
  69     for element in elements_to_init:
  70         res_name = "res_" + element
  71         res_name_pf = res_name + "_power_flow"
  72         if res_name in net:
  73             net[res_name_pf] = (net[res_name]).copy()
  74     init_results(net)
  75 
  76 
  77 def _rename_results(net):
  78     """
  79     write result tables to result tables for estimation (e.g., res_bus -> res_bus_est)
  80     reset backed up result tables (e.g., res_bus_power_flow -> res_bus)
  81     :param net: pandapower grid
  82     :return:
  83     """
  84     elements_to_init = ["bus", "ext_grid", "line", "load", "sgen", "trafo", "trafo3w",
  85                         "shunt", "impedance", "gen", "ward", "xward", "dcline"]
  86     # rename res_* tables to res_*_est and then res_*_power_flow to res_*
  87     for element in elements_to_init:
  88         res_name = "res_" + element
  89         res_name_pf = res_name + "_power_flow"
  90         res_name_est = res_name + "_est"
  91         net[res_name_est] = net[res_name]
  92         if res_name_pf in net:
  93             net[res_name] = net[res_name_pf]
  94         else:
  95             del net[res_name]
  96 
  97 def eppci2pp(net, ppc, eppci):
  98     # calculate the branch power flow and bus power injection based on the estimated voltage vector
  99     eppci = _calc_power_flow(eppci, eppci.V)
  100 
  101     # extract the result from ppci to ppc and pandpower network
  102     net = _extract_result_ppci_to_pp(net, ppc, eppci)
  103     return net
  104 
  105
  [end of pandapower/estimation/results.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: 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 @@
       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
  
verification_info: {"golden_diff": "diff --git a/pandapower/estimation/results.py b/pandapower/estimation/results.py\n--- a/pandapower/estimation/results.py\n+++ b/pandapower/estimation/results.py\n@@ -19,7 +19,7 @@\n     ppci['bus'], ppci['gen'], ppci['branch'] = pfsoln(baseMVA, bus, gen, branch, Ybus, Yf, Yt, V, ref, ref_gens)\n \n     # calculate bus power injections\n-    Sbus = np.multiply(V, np.conj(Ybus * V))\n+    Sbus = np.multiply(V, np.conj(Ybus * V)) * baseMVA\n     ppci[\"bus\"][:, PD] = -Sbus.real  # saved in per unit, injection -> demand\n     ppci[\"bus\"][:, QD] = -Sbus.imag  # saved in per unit, injection -> demand\n     return ppci\n", "issue": "Estimation results\nHello,\r\n\r\nI think in python file pandapower -> estimation -> results.py there is a baseMVA missing in the calculation.\r\n\r\nI think line 22 should be adjusted to this, or similar:\r\n\r\n`Sbus = np.multiply(V, np.conj(Ybus * V)) * baseMVA`\r\n\r\nThanks\n", "before_files": [{"content": "# -*- coding: utf-8 -*-\n\n# Copyright (c) 2016-2020 by University of Kassel and Fraunhofer Institute for Energy Economics\n# and Energy System Technology (IEE), Kassel. All rights reserved.\n\nimport numpy as np\n\nfrom pandapower.pypower.idx_bus import PD, QD\nfrom pandapower.pf.ppci_variables import _get_pf_variables_from_ppci\nfrom pandapower.pf.pfsoln_numba import pfsoln\nfrom pandapower.results import _copy_results_ppci_to_ppc, _extract_results_se, init_results\nfrom pandapower.auxiliary import _add_pf_options, get_values, _clean_up\n\ndef _calc_power_flow(ppci, V):\n    # store results for all elements\n    # calculate branch results (in ppc_i)\n    baseMVA, bus, gen, branch, ref, pv, pq, _, _, _, ref_gens = _get_pf_variables_from_ppci(ppci)\n    Ybus, Yf, Yt = ppci['internal']['Ybus'], ppci['internal']['Yf'], ppci['internal']['Yt']\n    ppci['bus'], ppci['gen'], ppci['branch'] = pfsoln(baseMVA, bus, gen, branch, Ybus, Yf, Yt, V, ref, ref_gens)\n\n    # calculate bus power injections\n    Sbus = np.multiply(V, np.conj(Ybus * V))\n    ppci[\"bus\"][:, PD] = -Sbus.real  # saved in per unit, injection -> demand\n    ppci[\"bus\"][:, QD] = -Sbus.imag  # saved in per unit, injection -> demand\n    return ppci\n\n\ndef _extract_result_ppci_to_pp(net, ppc, ppci):\n    # convert to pandapower indices\n    ppc = _copy_results_ppci_to_ppc(ppci, ppc, mode=\"se\")\n\n    # extract results from ppc\n    try:\n        _add_pf_options(net, tolerance_mva=1e-8, trafo_loading=\"current\",\n                        numba=True, ac=True, algorithm='nr', max_iteration=\"auto\")\n    except:\n        pass\n    # writes res_bus.vm_pu / va_degree and res_line\n    _extract_results_se(net, ppc)\n\n    # restore backup of previous results\n    _rename_results(net)\n\n    # additionally, write bus power demand results (these are not written in _extract_results)\n    mapping_table = net[\"_pd2ppc_lookups\"][\"bus\"]\n    net.res_bus_est.index = net.bus.index\n    net.res_bus_est.p_mw = get_values(ppc[\"bus\"][:, 2], net.bus.index.values,\n                                      mapping_table)\n    net.res_bus_est.q_mvar = get_values(ppc[\"bus\"][:, 3], net.bus.index.values,\n                                        mapping_table)\n\n    _clean_up(net)\n    # delete results which are not correctly calculated\n    for k in list(net.keys()):\n        if k.startswith(\"res_\") and k.endswith(\"_est\") and \\\n                k not in (\"res_bus_est\", \"res_line_est\", \"res_trafo_est\", \"res_trafo3w_est\"):\n            del net[k]\n    return net\n\n\ndef _copy_power_flow_results(net):\n    \"\"\"\n    copy old power flow results (if they exist) into res_*_power_flow tables for backup\n    :param net: pandapower grid\n    :return:\n    \"\"\"\n    elements_to_init = [\"bus\", \"ext_grid\", \"line\", \"load\", \"load_3ph\" \"sgen\", \"sgen_3ph\", \"trafo\", \"trafo3w\",\n                        \"shunt\", \"impedance\", \"gen\", \"ward\", \"xward\", \"dcline\"]\n    for element in elements_to_init:\n        res_name = \"res_\" + element\n        res_name_pf = res_name + \"_power_flow\"\n        if res_name in net:\n            net[res_name_pf] = (net[res_name]).copy()\n    init_results(net)\n\n\ndef _rename_results(net):\n    \"\"\"\n    write result tables to result tables for estimation (e.g., res_bus -> res_bus_est)\n    reset backed up result tables (e.g., res_bus_power_flow -> res_bus)\n    :param net: pandapower grid\n    :return:\n    \"\"\"\n    elements_to_init = [\"bus\", \"ext_grid\", \"line\", \"load\", \"sgen\", \"trafo\", \"trafo3w\",\n                        \"shunt\", \"impedance\", \"gen\", \"ward\", \"xward\", \"dcline\"]\n    # rename res_* tables to res_*_est and then res_*_power_flow to res_*\n    for element in elements_to_init:\n        res_name = \"res_\" + element\n        res_name_pf = res_name + \"_power_flow\"\n        res_name_est = res_name + \"_est\"\n        net[res_name_est] = net[res_name]\n        if res_name_pf in net:\n            net[res_name] = net[res_name_pf]\n        else:\n            del net[res_name]\n\ndef eppci2pp(net, ppc, eppci):\n    # calculate the branch power flow and bus power injection based on the estimated voltage vector\n    eppci = _calc_power_flow(eppci, eppci.V)\n\n    # extract the result from ppci to ppc and pandpower network\n    net = _extract_result_ppci_to_pp(net, ppc, eppci)\n    return net\n\n", "path": "pandapower/estimation/results.py"}]}