internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: scikit-image/scikit-image

Issue:
Argument 'cache' of skimage.measure.regionprops_table (and regionprops) doesn't seem to have any effect
### Description:

When passing cache=False to regionprops_table (or regionprops directly), it seems that properties still get cached in RegionProperties._cache. 
I think that an easy solution would be to return f(obj) when obj._cache_active is False in '_cached' decorator.

### Way to reproduce:

```python
import numpy as np
import skimage as ski

a = np.array([[0,0], [0,1]])

with_cache = ski.measure.regionprops(a, cache=True)[0]
with_cache.perimeter # acces one property to get data into cache

without_cache = ski.measure.regionprops(a, cache=False)[0]
without_cache.perimeter # acces one property to get data into cache

assert with_cache._cache != {} # expected
assert without_cache._cache == {} # will fail

```

### Version information:

_No response_


Discussion:

Resolving patch:
diff --git a/skimage/measure/_regionprops.py b/skimage/measure/_regionprops.py
--- a/skimage/measure/_regionprops.py
+++ b/skimage/measure/_regionprops.py
@@ -235,7 +235,10 @@ def wrapper(obj):
         cache = obj._cache
         prop = f.__name__
 
-        if not ((prop in cache) and obj._cache_active):
+        if not obj._cache_active:
+            return f(obj)
+
+        if prop not in cache:
             cache[prop] = f(obj)
 
         return cache[prop]


Test patch:
diff --git a/skimage/measure/tests/test_regionprops.py b/skimage/measure/tests/test_regionprops.py
--- a/skimage/measure/tests/test_regionprops.py
+++ b/skimage/measure/tests/test_regionprops.py
@@ -1236,6 +1236,16 @@ def test_cache():
     assert np.any(f0 != f1)
 
 
+def test_disabled_cache_is_empty():
+    SAMPLE_mod = SAMPLE.copy()
+    region = regionprops(SAMPLE_mod, cache=False)[0]
+    # Access one property to trigger cache
+    _ = region.image_filled
+
+    # Cache should be empty
+    assert region._cache == dict()
+
+
 def test_docstrings_and_props():
     def foo():
         """foo"""
Repository: scikit-image/scikit-image

Issue:
Typo in `skimage.measure.find_contours`
### Description:

There is a typo in the `skimage.measure.find_contours` docstring: 
Uses the “marching squares” method to compute **a the** iso-valued contours

### Way to reproduce:

_No response_

### Version information:

_No response_


Discussion:
You are right @lvsltz, thanks for the report! Would you like to make a PR to fix it? :) 
No. Many thanks!

Resolving patch:
diff --git a/skimage/measure/_find_contours.py b/skimage/measure/_find_contours.py
--- a/skimage/measure/_find_contours.py
+++ b/skimage/measure/_find_contours.py
@@ -12,7 +12,7 @@ def find_contours(
 ):
     """Find iso-valued contours in a 2D array for a given level value.
 
-    Uses the "marching squares" method to compute a the iso-valued contours of
+    Uses the "marching squares" method to compute the iso-valued contours of
     the input 2D array for a particular level value. Array values are linearly
     interpolated to provide better precision for the output contours.
 
@@ -33,7 +33,7 @@ def find_contours(
     positive_orientation : str, {'low', 'high'}
          Indicates whether the output contours will produce positively-oriented
          polygons around islands of low- or high-valued elements. If 'low' then
-         contours will wind counter- clockwise around elements below the
+         contours will wind counter-clockwise around elements below the
          iso-value. Alternately, this means that low-valued elements are always
          on the left of the contour. (See below for details.)
     mask : (M, N) ndarray of bool or None
@@ -55,7 +55,7 @@ def find_contours(
     The marching squares algorithm is a special case of the marching cubes
     algorithm [1]_.  A simple explanation is available here:
 
-    http://users.polytech.unice.fr/~lingrand/MarchingCubes/algo.html
+    https://users.polytech.unice.fr/~lingrand/MarchingCubes/algo.html
 
     There is a single ambiguous case in the marching squares algorithm: when
     a given ``2 x 2``-element square has two high-valued and two low-valued
@@ -85,7 +85,7 @@ def find_contours(
 
     The order of the contours in the output list is determined by the position
     of the smallest ``x,y`` (in lexicographical order) coordinate in the
-    contour.  This is a side-effect of how the input array is traversed, but
+    contour.  This is a side effect of how the input array is traversed, but
     can be relied upon.
 
     .. warning::
@@ -100,7 +100,7 @@ def find_contours(
     midway between the expected "light" and "dark" values. In particular,
     given a binarized array, *do not* choose to find contours at the low or
     high value of the array. This will often yield degenerate contours,
-    especially around structures that are a single array element wide. Instead
+    especially around structures that are a single array element wide. Instead,
     choose a middle value, as above.
 
     References


Test patch:
Repository: pretalx/pretalx

Issue:
deleting a room, which is in use yields ProtectedError
When you try to delete a room, which has talks assigned to it the app displays an ProtectedError. This can probably be handled it [deleting a submission type](https://github.com/openeventstack/pretalx/blob/master/src/pretalx/orga/views/cfp.py#L147-L152).


Discussion:

Resolving patch:
diff --git a/src/pretalx/orga/views/settings.py b/src/pretalx/orga/views/settings.py
--- a/src/pretalx/orga/views/settings.py
+++ b/src/pretalx/orga/views/settings.py
@@ -3,6 +3,7 @@
 from django.contrib import messages
 from django.contrib.auth import login
 from django.core.exceptions import PermissionDenied
+from django.db.models.deletion import ProtectedError
 from django.shortcuts import redirect
 from django.urls import reverse
 from django.utils.crypto import get_random_string
@@ -239,8 +240,12 @@ class RoomList(TemplateView):
 class RoomDelete(View):
 
     def dispatch(self, request, event, pk):
-        request.event.rooms.get(pk=pk).delete()
-        messages.success(self.request, _('Room deleted. Hopefully nobody was still in there …'))
+        try:
+            request.event.rooms.get(pk=pk).delete()
+            messages.success(self.request, _('Room deleted. Hopefully nobody was still in there …'))
+        except ProtectedError:  # TODO: show which/how many talks are concerned
+            messages.error(request, _('There is or was a talk scheduled in this room. It cannot be deleted.'))
+
         return redirect(request.event.orga_urls.room_settings)
 
 


Test patch:
Repository: pretalx/pretalx

Issue:
Restructure CSS
- [x] Use `$brand_color`
- [ ] Break SCSS up into more files 


Discussion:

Resolving patch:
diff --git a/src/pretalx/common/tasks.py b/src/pretalx/common/tasks.py
--- a/src/pretalx/common/tasks.py
+++ b/src/pretalx/common/tasks.py
@@ -23,12 +23,12 @@ def regenerate_css(event_id: int):
         return
 
     for local_app in local_apps:
+        path = os.path.join(settings.STATIC_ROOT, local_app, 'scss/main.scss')
         sassrules = []
+
         if event.primary_color:
             sassrules.append('$brand-primary: {};'.format(event.primary_color))
-
-        path = os.path.join(settings.STATIC_ROOT, local_app, 'scss/main.scss')
-        sassrules.append(f'@import "{path}";')
+            sassrules.append(f'@import "{path}";')
 
         cf = dict(django_libsass.CUSTOM_FUNCTIONS)
         cf['static'] = static


Test patch:
Repository: pretalx/pretalx

Issue:
Regenerate css on start
<!--- Provide a general summary of the issue in the Title above -->

## Expected Behavior

When some commit changes the pretalx css, events custom css should also be changed.

## Current Behavior

The css is not regenerated, so changes do not appear at all.

## Possible Solution

Regenerate on start.
Regenerate css on start
<!--- Provide a general summary of the issue in the Title above -->

## Expected Behavior

When some commit changes the pretalx css, events custom css should also be changed.

## Current Behavior

The css is not regenerated, so changes do not appear at all.

## Possible Solution

Regenerate on start.


Discussion:

Resolving patch:
diff --git a/src/pretalx/common/__init__.py b/src/pretalx/common/__init__.py
--- a/src/pretalx/common/__init__.py
+++ b/src/pretalx/common/__init__.py
@@ -4,9 +4,22 @@
 
 
 class CommonConfig(AppConfig):
-    label = 'pretalxcommon'
     name = 'pretalx.common'
 
+    def ready(self):
+        from pretalx.event.models import Event
+        from pretalx.common.tasks import regenerate_css
+        from django.db import connection
+
+        if Event._meta.db_table not in connection.introspection.table_names():
+            # commands like `compilemessages` execute ready(), but do not
+            # require a database to be present. Bail out early, if the Event
+            # table has not been created yet.
+            return
+
+        for event in Event.objects.all():
+            regenerate_css.apply_async(args=(event.pk,))
+
 
 with suppress(ImportError):
     import pretalx.celery_app as celery  # NOQA
diff --git a/src/pretalx/settings.py b/src/pretalx/settings.py
--- a/src/pretalx/settings.py
+++ b/src/pretalx/settings.py
@@ -259,7 +259,7 @@ def reduce_dict(data):
     'bootstrap4',
     'jquery',
     'djangoformsetjs',
-    'pretalx.common',
+    'pretalx.common.CommonConfig',
     'pretalx.event',
     'pretalx.mail',
     'pretalx.person',


Test patch:
Repository: pretalx/pretalx

Issue:
Incorrect invite token yields server exception
When using an incorrect invitation token, pretalx does not fail gracefully.
Incorrect invite token yields server exception
When using an incorrect invitation token, pretalx does not fail gracefully.


Discussion:

Resolving patch:
diff --git a/src/pretalx/cfp/views/user.py b/src/pretalx/cfp/views/user.py
--- a/src/pretalx/cfp/views/user.py
+++ b/src/pretalx/cfp/views/user.py
@@ -5,7 +5,7 @@
 from django.core.exceptions import ValidationError
 from django.core.validators import validate_email
 from django.http import Http404
-from django.shortcuts import redirect
+from django.shortcuts import get_object_or_404, redirect
 from django.utils.decorators import method_decorator
 from django.utils.functional import cached_property
 from django.views.generic import (
@@ -258,7 +258,8 @@ class SubmissionInviteAcceptView(LoggedInEventPageMixin, DetailView):
     context_object_name = 'submission'
 
     def get_object(self, *args, **kwargs):
-        return Submission.objects.get(
+        return get_object_or_404(
+            Submission,
             code__iexact=self.kwargs['code'],
             invitation_token__iexact=self.kwargs['invitation'],
         )


Test patch:
diff --git a/src/tests/functional/cfp/test_user.py b/src/tests/functional/cfp/test_user.py
--- a/src/tests/functional/cfp/test_user.py
+++ b/src/tests/functional/cfp/test_user.py
@@ -244,3 +244,12 @@ def test_can_accept_invitation(orga_client, submission):
     submission.refresh_from_db()
     assert response.status_code == 200
     assert submission.speakers.count() == 2
+
+
+@pytest.mark.django_db
+def test_wrong_acceptance_link(orga_client, submission):
+    assert submission.speakers.count() == 1
+    response = orga_client.post(submission.urls.accept_invitation + 'olololol', follow=True)
+    submission.refresh_from_db()
+    assert response.status_code == 404
+    assert submission.speakers.count() == 1
Repository: pretalx/pretalx

Issue:
When redirecting to login view, urlquote path
Paths need to be urlquoted and get params need to be passed aswell.


Discussion:

Resolving patch:
diff --git a/src/pretalx/common/middleware.py b/src/pretalx/common/middleware.py
--- a/src/pretalx/common/middleware.py
+++ b/src/pretalx/common/middleware.py
@@ -1,3 +1,4 @@
+import urllib
 from contextlib import suppress
 
 import pytz
@@ -50,7 +51,8 @@ def _is_reviewer_url(self, url):
 
     def _handle_orga_url(self, request, url):
         if request.user.is_anonymous and url.url_name not in self.UNAUTHENTICATED_ORGA_URLS:
-            return reverse('orga:login') + f'?next={request.path}'
+            params = '&' + request.GET.urlencode() if request.GET else ''
+            return reverse('orga:login') + f'?next={urllib.parse.quote(request.path)}' + params
         if hasattr(request, 'event') and request.event:
             if not (request.is_orga or request.is_reviewer):
                 raise PermissionDenied()
diff --git a/src/pretalx/orga/views/auth.py b/src/pretalx/orga/views/auth.py
--- a/src/pretalx/orga/views/auth.py
+++ b/src/pretalx/orga/views/auth.py
@@ -28,9 +28,10 @@ def post(self, request: HttpRequest, *args, **kwargs) -> HttpResponseRedirect:
             return redirect('orga:login')
 
         login(request, user)
-        url = urllib.parse.unquote(request.GET.get('next', ''))
+        params = request.GET.copy()
+        url = urllib.parse.unquote(params.pop('next', [''])[0])
         if url and is_safe_url(url, request.get_host()):
-            return redirect(url)
+            return redirect(url + ('?' + params.urlencode() if params else ''))
 
         # check where to reasonably redirect:
         # orga of a running event? go to that event.


Test patch:
diff --git a/src/tests/functional/orga/test_auth.py b/src/tests/functional/orga/test_auth.py
--- a/src/tests/functional/orga/test_auth.py
+++ b/src/tests/functional/orga/test_auth.py
@@ -9,3 +9,17 @@ def test_orga_successful_login(client, user):
     response = client.post(reverse('orga:login'), data={'username': user.nick, 'password': 'testtest'}, follow=True)
     assert response.status_code == 200
     assert 'Uh, a new event?' in response.content.decode()
+
+
+@pytest.mark.django_db
+def test_orga_redirect_login(client, orga_user, event):
+    queryparams = 'foo=bar&something=else'
+    request_url = event.orga_urls.base + '/?' + queryparams
+    response = client.get(request_url, follow=True)
+    assert response.status_code == 200
+    assert response.redirect_chain[-1] == (f'/orga/login/?next={event.orga_urls.base}/&{queryparams}', 302)
+
+    response = client.post(response.redirect_chain[-1][0], data={'username': orga_user.nick, 'password': 'orgapassw0rd'}, follow=True)
+    assert response.status_code == 200
+    assert event.name in response.content.decode()
+    assert response.redirect_chain[-1][0] == request_url
Repository: pretalx/pretalx

Issue:
Adding a speaker question does not pre-select "speaker question"
In the question list view, one can click "Add new question" either for speaker questions or for submission questions. In the following form, the question type is not preselected, which is unexpected.


Discussion:

Resolving patch:
diff --git a/src/pretalx/orga/views/cfp.py b/src/pretalx/orga/views/cfp.py
--- a/src/pretalx/orga/views/cfp.py
+++ b/src/pretalx/orga/views/cfp.py
@@ -133,6 +133,14 @@ def get_context_data(self, *args, **kwargs):
         ctx['formset'] = self.formset
         return ctx
 
+    def get_form_kwargs(self, *args, **kwargs):
+        kwargs = super().get_form_kwargs(*args, **kwargs)
+        if not self.get_object():
+            initial = kwargs['initial'] or dict()
+            initial['target'] = self.request.GET.get('type')
+            kwargs['initial'] = initial
+        return kwargs
+
     def get_success_url(self) -> str:
         obj = self.get_object() or self.instance
         return obj.urls.base


Test patch:
Repository: pretalx/pretalx

Issue:
Actually use celery and set it up



Discussion:

Resolving patch:
diff --git a/src/pretalx/common/management/commands/rebuild.py b/src/pretalx/common/management/commands/rebuild.py
new file mode 100644
--- /dev/null
+++ b/src/pretalx/common/management/commands/rebuild.py
@@ -0,0 +1,11 @@
+from django.core.management import call_command
+from django.core.management.base import BaseCommand
+
+
+class Command(BaseCommand):
+    help = "Rebuild static files and language files"
+
+    def handle(self, *args, **options):
+        call_command('compilemessages', verbosity=1, interactive=False)
+        call_command('collectstatic', verbosity=1, interactive=False)
+        call_command('compress', verbosity=1, interactive=False)
diff --git a/src/pretalx/settings.py b/src/pretalx/settings.py
--- a/src/pretalx/settings.py
+++ b/src/pretalx/settings.py
@@ -48,8 +48,11 @@ def reduce_dict(data):
         'ssl': 'True',
     },
     'cache': {
-
-    }
+    },
+    'celery': {
+        'broker': '',
+        'backend': '',
+    },
 })
 
 legacy_config = {
@@ -100,6 +103,10 @@ def reduce_dict(data):
         'host': os.getenv('PRETALX_DB_HOST'),
         'port': os.getenv('PRETALX_DB_PORT'),
     },
+    'celery': {
+        'broker': os.getenv('PRETALX_CELERY_BROKER'),
+        'backend': os.getenv('PRETALX_CELERY_BACKEND'),
+    },
 }
 
 config.read_dict(reduce_dict(legacy_config))
@@ -226,6 +233,12 @@ def reduce_dict(data):
     else:
         SESSION_ENGINE = "django.contrib.sessions.backends.db"
 
+HAS_CELERY = bool(config.get('celery', 'broker'))
+if HAS_CELERY:
+    CELERY_BROKER_URL = config.get('celery', 'broker')
+    CELERY_RESULT_BACKEND = config.get('celery', 'backend')
+else:
+    CELERY_TASK_ALWAYS_EAGER = True
 
 # Internal settings
 LANGUAGES = [
@@ -452,9 +465,6 @@ def reduce_dict(data):
     messages.SUCCESS: 'success',
 }
 
-# For now, to ease development
-CELERY_TASK_ALWAYS_EAGER = True
-
 
 def log_initial():
     from pretalx.common.console import start_box, end_box, print_line


Test patch:
Repository: pretalx/pretalx

Issue:
Mail config doesn't work
The fallback/default config is not used, even when an event's mail config is untouched.


Discussion:

Resolving patch:
diff --git a/src/pretalx/settings.py b/src/pretalx/settings.py
--- a/src/pretalx/settings.py
+++ b/src/pretalx/settings.py
@@ -45,7 +45,7 @@ def reduce_dict(data):
         'user': '',
         'password': '',
         'tls': 'False',
-        'ssl': 'True',
+        'ssl': 'False',
     },
     'cache': {
     },


Test patch:
Repository: pretalx/pretalx

Issue:
Unable to add questions
The following link doesn't do anything: `https://[Domain]/orga/event/[CFP_name]/cfp/questions/new`

## Expected Behavior

Being be to create a question

## Current Behavior

Unable to create a question

## Possible Solution

Fix the edit button.

## Steps to Reproduce (for bugs)

1. Create a new CFP
2. Go on `https://[Domain]/orga/event/[CFP_name]/cfp/questions/new`
3. Click on the edit button (the pen)

## Context

Creating a CFP

## Your Environment
* Version used: 0.4
* Environment name and version: Firefox 58.0.1 & Chromium 64.0.3282.119
* Operating System and version: Ubuntu 17.10 / Server: Ubuntu 16.04 with python 3.6


Discussion:

Resolving patch:
diff --git a/src/pretalx/orga/views/cfp.py b/src/pretalx/orga/views/cfp.py
--- a/src/pretalx/orga/views/cfp.py
+++ b/src/pretalx/orga/views/cfp.py
@@ -83,7 +83,8 @@ class CfPQuestionDetail(PermissionRequired, ActionFromUrl, CreateOrUpdateView):
     write_permission_required = 'orga.edit_question'
 
     def get_template_names(self):
-        if self.request.path.lstrip('/').endswith('edit'):
+        action = self.request.path.lstrip('/').rpartition('/')[2]
+        if action in ('edit', 'new'):
             return 'orga/cfp/question_form.html'
         return 'orga/cfp/question_detail.html'
 


Test patch:
Repository: pretalx/pretalx

Issue:
installation crashes when there are no config files
## Current Behavior
```
$ cd pretalx
$ pip-3.6 install . --user
(...)
      File "<frozen importlib._bootstrap>", line 994, in _gcd_import
      File "<frozen importlib._bootstrap>", line 971, in _find_and_load
      File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
      File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
      File "<frozen importlib._bootstrap_external>", line 678, in exec_module
      File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
      File "/tmp/pip-xa87l9tk-build/pretalx/settings.py", line 460, in <module>
        plugins=PLUGINS
      File "/tmp/pip-xa87l9tk-build/pretalx/common/settings/utils.py", line 11, in log_initial
        (f'Read from: {", ".join(config_files)}', False),
    TypeError: can only join an iterable
```

if there are no config files at all, the installation crashes, because `config_files` is `None`.

## Your Environment

* Version used: master
* Operating System and version (desktop or mobile): FreeBSD



Discussion:

Resolving patch:
diff --git a/src/pretalx/common/settings/config.py b/src/pretalx/common/settings/config.py
--- a/src/pretalx/common/settings/config.py
+++ b/src/pretalx/common/settings/config.py
@@ -128,7 +128,7 @@ def read_config_files(config):
             os.path.expanduser('~/.pretalx.cfg'),
             'pretalx.cfg',
         ], encoding='utf-8')
-    return config, config_files
+    return config, config_files or []  # .read() returns None, if there are no config files
 
 
 def read_layer(layer_name, config):


Test patch:
Repository: pretalx/pretalx

Issue:
Prevent removing the last organiser of an event
… because this is a really bad idea.


Discussion:

Resolving patch:
diff --git a/src/pretalx/orga/views/event.py b/src/pretalx/orga/views/event.py
--- a/src/pretalx/orga/views/event.py
+++ b/src/pretalx/orga/views/event.py
@@ -185,6 +185,16 @@ def _find_user(cls, email):
         from pretalx.person.models import User
         return User.objects.filter(nick=email).first() or User.objects.filter(email=email).first()
 
+    def _count_orga_permissions(self, permissions):
+        return len([p for p in permissions if p.is_orga])
+
+    def has_remaining_team(self):
+        return (
+            self._count_orga_permissions(self.formset.new_objects)
+            + self._count_orga_permissions(self.formset.changed_objects)
+            - self._count_orga_permissions(self.formset.deleted_objects)
+        ) > 0
+
     @transaction.atomic
     def post(self, request, *args, **kwargs):
         if not self.formset.is_valid():
@@ -193,6 +203,10 @@ def post(self, request, *args, **kwargs):
         permissions = self.formset.save(commit=False)
         mails = []
 
+        if not self.has_remaining_team():
+            messages.error(request, _("That would be a pretty lonely event. You can't remove the last remaining team member."))
+            return redirect(self.request.event.orga_urls.team_settings)
+
         for permission in self.formset.deleted_objects:
             permission.delete()
 


Test patch:
diff --git a/src/tests/functional/orga/test_settings.py b/src/tests/functional/orga/test_settings.py
--- a/src/tests/functional/orga/test_settings.py
+++ b/src/tests/functional/orga/test_settings.py
@@ -200,6 +200,26 @@ def test_invite_orga_member(orga_client, event):
     assert not perm.is_reviewer
 
 
+@pytest.mark.django_db
+def test_remove_last_orga_member(orga_client, event):
+    assert EventPermission.objects.filter(event=event).count() == 1
+    perm = EventPermission.objects.filter(event=event).first()
+    response = orga_client.post(
+        event.orga_urls.team_settings,
+        {
+            'permissions-TOTAL_FORMS': 1,
+            'permissions-INITIAL_FORMS': 1,
+            'permissions-0-invitation_email': '',
+            'permissions-0-is_orga': 'on',
+            'permissions-0-review_override_count': '0',
+            'permissions-0-id': str(perm.id),
+            'permissions-0-DELETE': 'on',
+        }, follow=True,
+    )
+    assert response.status_code == 200
+    assert EventPermission.objects.filter(event=event).count() == 1
+
+
 @pytest.mark.django_db
 def test_retract_invitation(orga_client, event):
     perm = EventPermission.objects.filter(event=event).first()