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

Issue:
[bug] Wrong algorithm "id" for fdbx and fdxb (pypower fast decoupled)
### Bug report checklis

- [X] Searched the [issues page](https://github.com/e2nIEE/pandapower/issues) for similar reports

- [X] Read the relevant sections of the [documentation](https://pandapower.readthedocs.io/en/latest/about.html)

- [X] Browse the [tutorials](https://github.com/e2nIEE/pandapower/tree/develop/tutorials) and [tests](https://github.com/e2nIEE/pandapower/tree/develop/pandapower/test) for usefull code snippets and examples of use

- [X] Reproduced the issue after updating with `pip install --upgrade pandapower` (or `git pull`)

- [X] Tried basic troubleshooting (if a bug/error) like restarting the interpreter and checking the pythonpath


### Reproducible Example

```python
# I had to dive deep in the code to find this error, it's not reproducible "as is" as it is a mixed up between fdxb and fdbx somewhere in a file.
```


### Issue Description and Traceback

In pandapower/pf/runpf_pypower.py line81 there is: 
>>> algorithm_pypower_dict = {'nr': 1, 'fdbx': 2, 'fdxb': 3, 'gs': 4}
see https://github.com/e2nIEE/pandapower/blob/80ca87dbb991c682f56e48ea90ea4035be3dff6c/pandapower/pf/runpf_pypower.py#L81

This would imply that fdbx is the algorithm id 2.

But I think "fdxb" and "fdbx" are mixed up. Indeed: 

In pypower (module pandapower/pypower), it is written that `alg==2` is XB method, see for example: 
https://github.com/e2nIEE/pandapower/blob/80ca87dbb991c682f56e48ea90ea4035be3dff6c/pandapower/pypower/makeB.py#L36C7-L36C8

We can also see that the XB method is alg 2 here:
https://github.com/e2nIEE/pandapower/blob/80ca87dbb991c682f56e48ea90ea4035be3dff6c/pandapower/pypower/ppoption.py#L14C1-L14C1


### Expected Behavior

I think the code should be replaced by:

>>> algorithm_pypower_dict = {'nr': 1, 'fdbx': 3, 'fdxb': 2, 'gs': 4}

### Installed Versions

I just look at the code in the repo, so all version with current code are concerned (and this bug probably originates a long time ago)

### Label

- [x] Relevant labels are selected



Discussion:
Hi @Bdonnot, thank you! I will adjust it.

Best regards,
Roman

Resolving patch:
diff --git a/pandapower/pf/runpf_pypower.py b/pandapower/pf/runpf_pypower.py
--- a/pandapower/pf/runpf_pypower.py
+++ b/pandapower/pf/runpf_pypower.py
@@ -78,7 +78,7 @@ def _get_options(options, **kwargs):
     max_iteration = options["max_iteration"]
 
     # algorithms implemented within pypower
-    algorithm_pypower_dict = {'nr': 1, 'fdbx': 2, 'fdxb': 3, 'gs': 4}
+    algorithm_pypower_dict = {'nr': 1, 'fdxb': 2, 'fdbx': 3, 'gs': 4}
 
     ppopt = ppoption(ENFORCE_Q_LIMS=enforce_q_lims, PF_TOL=tolerance_mva,
                      PF_ALG=algorithm_pypower_dict[algorithm], **kwargs)


Test patch:
Repository: e2nIEE/pandapower

Issue:
connected_components documentation error
### Feature Checklist

- [X] Searched the [issues page](https://github.com/e2nIEE/pandapower/issues) for similar reports

- [X] Read the relevant sections of the [documentation](https://pandapower.readthedocs.io/en/latest/about.html)

- [ ] Browse the [tutorials](https://github.com/e2nIEE/pandapower/tree/develop/tutorials) and [tests](https://github.com/e2nIEE/pandapower/tree/develop/pandapower/test) for usefull code snippets and examples of use


### Issue

Error in the Docs of `pandapower.topology.connected_components(mg, notravbuses={})`

The examples states:
```python
    import pandapower.topology as top
    mg = top.create_nxgraph(net)
    cc = top.connected_components(net, 5)
```
but it should be
```python
    import pandapower.topology as top
    mg = top.create_nxgraph(net)
    cc = top.connected_components(mg, 5)
```
note the `net` in the last line. connected components takes a graph not a pandapowerNet.

### Label

- [ ] Relevant labels are selected



Discussion:

Resolving patch:
diff --git a/pandapower/topology/graph_searches.py b/pandapower/topology/graph_searches.py
--- a/pandapower/topology/graph_searches.py
+++ b/pandapower/topology/graph_searches.py
@@ -70,7 +70,7 @@ def connected_components(mg, notravbuses=set()):
 
          mg = top.create_nxgraph(net)
 
-         cc = top.connected_components(net, 5)
+         cc = top.connected_components(mg, 5)
 
     """
 


Test patch:
Repository: e2nIEE/pandapower

Issue:
[bug] __format_version__ not increased.
### Issue Description

The `__format_version__` in `_version.py` has not been increased eventhough the format got changed!

This is an issue in the develop branch **not** in master!

In my fork I made an update to many test cases since I changed the format, so I saved many networks in as files, they contain the current format_version (2.14.0). After merging the current version of develop I got some tests that suddenly failed eventhough my code should not mess with them. So I did a little diging and found that the expected and actual results differ in `net.res_switch_est` DataFrame. This is because the expected result only contains the old columns while the actual result contains the updated columns.

This is because the expected results are loaded form file using the `pandapower.from_json` function and since then format version is the same as the current format verison in `_version.py` the conversion to the newest format is not done. So the network is returned as loaded from file.
The actual results however are a product of a conversion from a different network type. So they are the output of a converter that creates a new pandapowerNet. These then contain all new columns.

If new columns are added `__format_version__` should be incremented at least in the bugfix number. But I would expect that this constitutes at least a minor release as a new format version most likely breaks backwards compatibility. On a bugfix version I would expect I go backwards and forwards without issue. But this is not the case if the format version changes! A 2.13.1 Network should sucessfully load on 2.13.0 but this will not work if new columns are added. So this change should be reflected by an increase of the format verison to at least 2.15.0 in my opinion.

The breaking commit is 516f8af as it changed the format without changeing the format version.



Discussion:

Resolving patch:
diff --git a/pandapower/_version.py b/pandapower/_version.py
--- a/pandapower/_version.py
+++ b/pandapower/_version.py
@@ -1,4 +1,4 @@
 import importlib.metadata
 
 __version__ = importlib.metadata.version("pandapower")
-__format_version__ = "2.14.0"
+__format_version__ = "2.15.0"


Test patch:
Repository: e-valuation/EvaP

Issue:
Update installation instructions
https://evap.readthedocs.org/en/latest/installation.html

Someone should follow these instructions and see if they are correct and complete.

The short version at https://github.com/fsr-itse/EvaP should also be checked again.



Discussion:

Resolving patch:
diff --git a/evap/settings.py b/evap/settings.py
--- a/evap/settings.py
+++ b/evap/settings.py
@@ -251,7 +251,7 @@
     }
 }
 
-# Create a local_settings.py if you want to override settings per machine
+# Create a localsettings.py if you want to override settings per machine
 # or user, e.g. for development or different settings in deployments using
 # multiple servers.
 _LOCAL_SETTINGS_FILENAME = os.path.join(SITE_ROOT, "localsettings.py")


Test patch:
Repository: e-valuation/EvaP

Issue:
Disable results link for courses without published votes
Currently in the results overview, you can click on courses which have no published votes. The course page is not helpful then, so the link should be disabled.

if the course has comments but no votes, the link should be enabled for the respective contributors.



Discussion:
Additionally, the overall grade should not be shown if the link is disabled.

see #266 


Resolving patch:
diff --git a/evap/evaluation/tools.py b/evap/evaluation/tools.py
--- a/evap/evaluation/tools.py
+++ b/evap/evaluation/tools.py
@@ -44,6 +44,9 @@ def avg(iterable):
     return float(sum(items)) / len(items)
 
 
+def can_publish_grades(course, staff_member=False):
+    return staff_member or (course.num_voters >= settings.MIN_ANSWER_COUNT and float(course.num_voters) / course.num_participants >= settings.MIN_ANSWER_PERCENTAGE)
+
 def calculate_results(course, staff_member=False):
     """Calculates the result data for a single course. Returns a list of
     `ResultSection` tuples. Each of those tuples contains the questionnaire, the
@@ -58,7 +61,7 @@ def calculate_results(course, staff_member=False):
         return prior_results
 
     # check if grades for the course will be published
-    show = staff_member or (course.num_voters >= settings.MIN_ANSWER_COUNT and float(course.num_voters) / course.num_participants >= settings.MIN_ANSWER_PERCENTAGE)
+    show = can_publish_grades(course, staff_member)
 
     # there will be one section per relevant questionnaire--contributor pair
     sections = []
diff --git a/evap/results/views.py b/evap/results/views.py
--- a/evap/results/views.py
+++ b/evap/results/views.py
@@ -6,7 +6,7 @@
 
 from evap.evaluation.auth import login_required, fsr_required
 from evap.evaluation.models import Semester
-from evap.evaluation.tools import calculate_results, calculate_average_grade, TextResult
+from evap.evaluation.tools import calculate_results, calculate_average_grade, TextResult, can_publish_grades
 
 from evap.results.exporters import ExcelExporter
 
@@ -30,6 +30,7 @@ def semester_detail(request, semester_id):
     for course in courses:
         # first, make sure that there is no preexisting grade attribute
         course.grade = calculate_average_grade(course)
+        course.can_publish_grades = can_publish_grades(course, request.user.is_staff)
 
     return render_to_response(
         "results_semester_detail.html",


Test patch:
Repository: e-valuation/EvaP

Issue:
Grade preview
There must be an option for FSR members to see the grades for a course before publishing it.
This should be available in "in evaluation", "evaluated" and "reviewed".



Discussion:
![bildschirmfoto 2014-06-12 um 18 55 40](https://cloud.githubusercontent.com/assets/335438/3260862/68f97ee0-f252-11e3-8388-22db3afd28ba.png)

The preview should also include the grades for all individual questions.

The current Travis fail can be ignored as it just failed for python 2.6 for which we just now dropped support.
@normanrz It would be nice if you could have a look at the individual grade preview though - maybe you have some ideas for it ;)


Resolving patch:
diff --git a/evap/results/views.py b/evap/results/views.py
--- a/evap/results/views.py
+++ b/evap/results/views.py
@@ -63,7 +63,13 @@ def semester_export(request, semester_id):
 @login_required
 def course_detail(request, semester_id, course_id):
     semester = get_object_or_404(Semester, id=semester_id)
-    course = get_object_or_404(semester.course_set.filter(state="published"), id=course_id)
+    
+    # staff can see preview of results even when course is not published
+    if request.user.is_staff:
+        course = get_object_or_404(semester.course_set.filter(state__in=['inEvaluation', 'evaluated', 'reviewed', 'published']), id=course_id)
+    # everyone else can only see published results
+    else:
+        course = get_object_or_404(semester.course_set.filter(state="published"), id=course_id)
 
     sections = calculate_results(course, request.user.is_staff)
 
@@ -78,18 +84,24 @@ def course_detail(request, semester_id, course_id):
         # remove empty sections
         sections = [section for section in sections if section.results]
 
-    # check whether results are published
-    published = course.num_voters >= settings.MIN_ANSWER_COUNT and float(course.num_voters) / course.num_participants >= settings.MIN_ANSWER_PERCENTAGE
+    # show a warning if course is still in evaluation (for staff preview)
+    evaluation_warning = course.state != 'published'
+
+    # check whether course has a sufficient number of votes for publishing it
+    sufficient_votes = course.num_voters >= settings.MIN_ANSWER_COUNT and float(course.num_voters) / course.num_participants >= settings.MIN_ANSWER_PERCENTAGE
 
-    # show a publishing warning to fsr members when the results are not publicly available
-    warning = (not published) and request.user.is_staff
+    # results for a course might not be visible because there are not enough answers
+    # but it can still be "published" e.g. to show the comment results to lecturers
+    # the FSR can still see all results but gets a warning message
+    sufficient_votes_warning = (not sufficient_votes) and request.user.is_staff
 
     return render_to_response(
         "results_course_detail.html",
         dict(
             course=course,
             sections=sections,
-            warning=warning
+            evaluation_warning=evaluation_warning,
+            sufficient_votes_warning=sufficient_votes_warning
         ),
         context_instance=RequestContext(request))
 


Test patch:
Repository: e-valuation/EvaP

Issue:
Result detail pages need to show total grades and participation
The `results/course_detail` pages should again show the information that is already given on the overview page (average and medium grades and participation).



Discussion:

Resolving patch:
diff --git a/evap/results/views.py b/evap/results/views.py
--- a/evap/results/views.py
+++ b/evap/results/views.py
@@ -95,6 +95,9 @@ def course_detail(request, semester_id, course_id):
     # the FSR can still see all results but gets a warning message
     sufficient_votes_warning = (not sufficient_votes) and request.user.is_staff
 
+    course.avg_grade, course.med_grade = calculate_average_and_medium_grades(course)
+    course.can_publish_grades = can_publish_grades(course, request.user.is_staff)
+
     return render_to_response(
         "results_course_detail.html",
         dict(


Test patch:
Repository: e-valuation/EvaP

Issue:
remove raven dependency
because we don't use it.



Discussion:
sentry never worked again?

no, but i don't know whether we actually tried...

raven has some occurrences in settings.py, which should also be removed.


Resolving patch:
diff --git a/evap/settings.py b/evap/settings.py
--- a/evap/settings.py
+++ b/evap/settings.py
@@ -212,14 +212,6 @@
     'evap.contributor',
 #   'django_auth_kerberos',
 )
-if not DEBUG:
-    INSTALLED_APPS += (
-        'raven.contrib.django.raven_compat',
-    )
-
-RAVEN_CONFIG = {
-    'dsn': 'http://public:secret@example.com/1',
-}
 
 # A sample logging configuration. The only tangible logging
 # performed by this configuration is to send an email to
@@ -235,10 +227,6 @@
          }
      },
     'handlers': {
-        'sentry': {
-            'level': 'ERROR',
-            'class': 'raven.contrib.django.handlers.SentryHandler',
-        },
         'mail_admins': {
             'level': 'ERROR',
             'filters': ['require_debug_false'],
@@ -258,16 +246,6 @@
         'evap.evaluation.management.commands.import_evaj': {
             'handlers': ['console'],
             'level': 'INFO'
-        },
-        'raven': {
-            'level': 'DEBUG',
-            'handlers': ['console'],
-            'propagate': False,
-        },
-        'sentry.errors': {
-            'level': 'DEBUG',
-            'handlers': ['console'],
-            'propagate': False,
         }
     }
 }


Test patch:
Repository: e-valuation/EvaP

Issue:
include the debug toolbar
we should include the debug toolbar so it shows up whenever debug mode is enabled. all pages with lots of sql statements will take about 3x the time to load, but the issue is not the toolbar, but the number of queries then :)



Discussion:

Resolving patch:
diff --git a/evap/settings.py b/evap/settings.py
--- a/evap/settings.py
+++ b/evap/settings.py
@@ -253,6 +253,18 @@
     }
 }
 
+#django debug toolbar settings
+ENABLE_DEBUG_TOOLBAR = False
+if DEBUG and ENABLE_DEBUG_TOOLBAR:
+    DEBUG_TOOLBAR_PATCH_SETTINGS = False
+    INSTALLED_APPS += ('debug_toolbar',)
+    MIDDLEWARE_CLASSES = ('debug_toolbar.middleware.DebugToolbarMiddleware',) + MIDDLEWARE_CLASSES
+    def show_toolbar(request):
+        return True
+    DEBUG_TOOLBAR_CONFIG = {
+        'SHOW_TOOLBAR_CALLBACK': 'evap.settings.show_toolbar',
+    }
+
 # Create a localsettings.py if you want to override settings per machine
 # or user, e.g. for development or different settings in deployments using
 # multiple servers.
diff --git a/evap/urls.py b/evap/urls.py
--- a/evap/urls.py
+++ b/evap/urls.py
@@ -23,3 +23,9 @@
     urlpatterns += patterns('',
         url(r'^media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}),
    )
+
+if settings.DEBUG and settings.ENABLE_DEBUG_TOOLBAR:
+    import debug_toolbar
+    urlpatterns += patterns('',
+        url(r'^__debug__/', include(debug_toolbar.urls)),
+    )


Test patch:
Repository: e-valuation/EvaP

Issue:
Ampersand not correctly formatted in emails
The ampersand character (&) is formatted as `&amp;` in emails that are sent by the system.

Ampersand not correctly formatted in emails
The ampersand character (&) is formatted as `&amp;` in emails that are sent by the system.



Discussion:

Resolving patch:
diff --git a/evap/evaluation/models.py b/evap/evaluation/models.py
--- a/evap/evaluation/models.py
+++ b/evap/evaluation/models.py
@@ -641,7 +641,7 @@ def recipient_list_for_course(cls, course, send_to_editors, send_to_contributors
 
     @classmethod
     def render_string(cls, text, dictionary):
-        return Template(text).render(Context(dictionary))
+        return Template(text).render(Context(dictionary, autoescape=False))
 
     def send_courses(self, courses, send_to_editors=False, send_to_contributors=False, send_to_due_participants=False, send_to_all_participants=False):
         # pivot course-user relationship


Test patch:
Repository: e-valuation/EvaP

Issue:
Missing access to contributor page for delegate
Delegates for responsible users can't see the contributor page when they don't have own contributions.
Every delegate of any user with edit rights should have access to this page.

(Example: In the test data set, the user "delegate" can't see the page, although it should be possible.)



Discussion:

Resolving patch:
diff --git a/evap/evaluation/models.py b/evap/evaluation/models.py
--- a/evap/evaluation/models.py
+++ b/evap/evaluation/models.py
@@ -554,7 +554,7 @@ def is_responsible(self):
 
     @property
     def is_delegate(self):
-        return self.delegates.exists()
+        return self.user.represented_users.exists()
 
     @property
     def is_editor_or_delegate(self):


Test patch:
Repository: e-valuation/EvaP

Issue:
UserProfile missing when User is not created during import
Users which are not created by an enrollment data import but by logging in for the first time (using Kerberos authentication, so they don't need to have a local account first) don't have a UserProfile. This leads to undefined behavior.

UserProfile missing when User is not created during import
Users which are not created by an enrollment data import but by logging in for the first time (using Kerberos authentication, so they don't need to have a local account first) don't have a UserProfile. This leads to undefined behavior.



Discussion:

Resolving patch:
diff --git a/evap/evaluation/views.py b/evap/evaluation/views.py
--- a/evap/evaluation/views.py
+++ b/evap/evaluation/views.py
@@ -50,6 +50,8 @@ def index(request):
 
         return render_to_response("index.html", dict(new_key_form=new_key_form, login_key_form=login_key_form, login_username_form=login_username_form), context_instance=RequestContext(request))
     else:
+        userprofile, _ = UserProfile.objects.get_or_create(user=request.user)
+
         # check for redirect variable
         redirect_to = request.GET.get("next", None)
         if redirect_to is not None:
@@ -57,7 +59,7 @@ def index(request):
                 if request.user.is_staff:
                     return redirect(redirect_to)
             elif redirect_to.startswith("/contributor/"):
-                if UserProfile.get_for_user(request.user).is_contributor:
+                if userprofile.is_contributor:
                     return redirect(redirect_to)
             else:
                 return redirect(redirect_to)
@@ -65,7 +67,7 @@ def index(request):
         # redirect user to appropriate start page
         if request.user.is_staff:
             return redirect('evap.fsr.views.index')
-        elif UserProfile.get_for_user(request.user).is_editor_or_delegate:
+        elif userprofile.is_editor_or_delegate:
             return redirect('evap.contributor.views.index')
         else:
             return redirect('evap.student.views.index')


Test patch:
Repository: e-valuation/EvaP

Issue:
Creating a duplicate user results in Server Error
When creating a user with a username that already exists, the `ValidationError` for the form seems to be not correctly raised because the server returns an Internal Server Error caused by this:

```
IntegrityError: null value in column "username" violates not-null constraint
```

This also happens when the username field is empty when submitting the form.



Discussion:

Resolving patch:
diff --git a/evap/fsr/forms.py b/evap/fsr/forms.py
--- a/evap/fsr/forms.py
+++ b/evap/fsr/forms.py
@@ -385,6 +385,9 @@ def clean_username(self):
         raise forms.ValidationError(_(u"A user with the username '%s' already exists") % self.cleaned_data.get('username'))
 
     def _post_clean(self, *args, **kw):
+        if self._errors:
+            return
+            
         # first save the user, so that the profile gets created for sure
         self.instance.user.username = self.cleaned_data.get('username').strip().lower()
         self.instance.user.first_name = self.cleaned_data.get('first_name').strip()


Test patch:
Repository: e-valuation/EvaP

Issue:
Missing translations on course selection pages
On all course selection pages (for reverting, approving, etc.) there are some translations missing.
The states of the courses and the button texts are always in English.

Missing translations on course selection pages
On all course selection pages (for reverting, approving, etc.) there are some translations missing.
The states of the courses and the button texts are always in English.



Discussion:

Resolving patch:
diff --git a/evap/fsr/forms.py b/evap/fsr/forms.py
--- a/evap/fsr/forms.py
+++ b/evap/fsr/forms.py
@@ -6,6 +6,7 @@
 from django.utils.translation import ugettext_lazy as _
 from django.utils.text import normalize_newlines
 
+from evap.evaluation.tools import STATES_ORDERED
 from evap.evaluation.forms import BootstrapMixin, QuestionnaireMultipleChoiceField
 from evap.evaluation.models import Contribution, Course, Question, Questionnaire, \
                                    Semester, UserProfile, FaqSection, FaqQuestion, \
@@ -323,7 +324,7 @@ def __init__(self, degree, courses, filter_func, *args, **kwargs):
 
         for course in self.courses:
             if self.filter_func(course):
-                label = course.name + " (" + course.kind + ")" + " (" + course.state + ")"
+                label = '%s (%s) (%s)' % (course.name, course.kind, STATES_ORDERED[course.state])
                 self.fields[str(course.id)] = forms.BooleanField(label=label, required=False)
 
     def clean(self):


Test patch: