internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: translate/pootle

Issue:
Pootle FS file system backends list isn't sorted



Discussion:

Resolving patch:
diff --git a/pootle/apps/pootle_fs/forms.py b/pootle/apps/pootle_fs/forms.py
--- a/pootle/apps/pootle_fs/forms.py
+++ b/pootle/apps/pootle_fs/forms.py
@@ -33,12 +33,6 @@
 
 class ProjectFSAdminForm(forms.Form):
 
-    fs_type = forms.ChoiceField(
-        label=_("Filesystem backend"),
-        help_text=_("Select a filesystem backend"),
-        choices=(),
-        widget=forms.Select(
-            attrs={'class': 'js-select2'}))
     fs_url = forms.CharField(
         label=_("Backend URL or path"),
         help_text=_(
@@ -61,36 +55,26 @@ class ProjectFSAdminForm(forms.Form):
     def should_save(self):
         return self.is_valid()
 
-    @property
-    def fs_type_choices(self):
-        return (
-            (plugin_type, plugin.name or plugin.fs_type)
-            for plugin_type, plugin
-            in fs_plugins.gather().items())
-
     def __init__(self, *args, **kwargs):
         self.project = kwargs.pop("project")
         super(ProjectFSAdminForm, self).__init__(*args, **kwargs)
-        self.fields["fs_type"].choices = self.fs_type_choices
 
         self.fields["fs_url"].initial = self.project.config.get("pootle_fs.fs_url")
-        self.fields["fs_type"].initial = (
-            self.project.config.get("pootle_fs.fs_type"))
         translation_mapping = (
             self.project.config.get("pootle_fs.translation_mappings"))
         if translation_mapping:
             self.fields["translation_mapping"].initial = (
                 translation_mapping.get("default"))
 
+    @cached_property
+    def fs_plugin(self):
+        return fs_plugins.gather()[
+            self.project.config["pootle_fs.fs_type"]]
+
     @property
     def fs_path_validator(self):
         return fs_translation_mapping_validator.get()
 
-    @cached_property
-    def fs_plugin(self):
-        if self.cleaned_data.get("fs_type"):
-            return fs_plugins.gather()[self.cleaned_data["fs_type"]]
-
     @cached_property
     def fs_url_validator(self):
         validator = fs_url_validator.get(self.fs_plugin)
@@ -115,11 +99,10 @@ def clean(self):
                 forms.ValidationError(
                     "Incorrect URL or path ('%s') for plugin type '%s': %s"
                     % (self.cleaned_data.get("fs_url"),
-                       self.cleaned_data.get("fs_type"),
+                       self.fs_plugin.fs_type,
                        e)))
 
     def save(self):
-        self.project.config["pootle_fs.fs_type"] = self.cleaned_data["fs_type"]
         self.project.config["pootle_fs.fs_url"] = self.cleaned_data["fs_url"]
         self.project.config["pootle_fs.translation_mappings"] = dict(
             default=self.cleaned_data["translation_mapping"])


Test patch:
Repository: translate/pootle

Issue:
pootle init needs a --yes option
# Steps to reproduce:
` pootle init --noinput` with an existing `pootle.conf`

# Results (Expected/Actual):
Want to automate the replacement of the `pootle.conf` for testing, but --noinput just doesn't ask for input. A `--yes` option would allow us to force an overwrite.




Discussion:

Resolving patch:
diff --git a/pootle/runner.py b/pootle/runner.py
--- a/pootle/runner.py
+++ b/pootle/runner.py
@@ -121,6 +121,12 @@ def init_command(parser, args):
 
     src_dir = os.path.abspath(os.path.dirname(__file__))
     add_help_to_parser(parser)
+    parser.add_argument("--yes", "-y",
+                        dest='overwrite_template',
+                        default=False,
+                        action='store_true',
+                        help=(u"Overwrite existing configuration file "
+                              "without asking."))
     parser.add_argument("--dev",
                         dest='settings_template',
                         default=os.path.join(src_dir,
@@ -153,7 +159,9 @@ def init_command(parser, args):
 
     if os.path.exists(config_path):
         resp = None
-        if args.noinput:
+        if args.overwrite_template:
+            resp = "yes"
+        elif args.noinput:
             resp = 'n'
         else:
             resp = input("File already exists at %r, overwrite? [Ny] "


Test patch:
Repository: translate/pootle

Issue:
Use {POOTLE_TRANSLATION_DIRECTORY} in 2.9 migration
# Steps to reproduce:
- upgrade a <= 2.8 project to 2.9

# Results (Expected/Actual):

expected: fs_url should be `{POOTLE_TRANSLATION_DIRECTORY}code`
actual: absolute path is used


Discussion:

Resolving patch:
diff --git a/pootle/apps/pootle_fs/migrations/0003_path_uses_placeholder.py b/pootle/apps/pootle_fs/migrations/0003_path_uses_placeholder.py
new file mode 100644
--- /dev/null
+++ b/pootle/apps/pootle_fs/migrations/0003_path_uses_placeholder.py
@@ -0,0 +1,36 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.10.7 on 2017-09-12 15:17
+from __future__ import unicode_literals
+
+from django.db import migrations
+
+from django.conf import settings
+
+
+def set_path_with_placeholder(apps, schema_editor):
+    Config = apps.get_model("pootle_config.Config")
+    ContentType = apps.get_model("contenttypes.ContentType")
+    Project = apps.get_model("pootle_project.Project")
+    project_ct = ContentType.objects.get_for_model(Project)
+    for project in Project.objects.all():
+        config = Config.objects.get(
+            content_type=project_ct,
+            object_pk=project.pk,
+            key="pootle_fs.fs_url")
+        if config.value.startswith(settings.POOTLE_TRANSLATION_DIRECTORY):
+            config.value = (
+                "{POOTLE_TRANSLATION_DIRECTORY}%s"
+                % config.value[
+                    len(settings.POOTLE_TRANSLATION_DIRECTORY.rstrip("/")) + 1:])
+            config.save()
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('pootle_fs', '0002_convert_localfs'),
+    ]
+
+    operations = [
+        migrations.RunPython(set_path_with_placeholder),
+    ]


Test patch:
Repository: translate/pootle

Issue:
Expire project cache when language mappings change
# Steps to reproduce:

- change language mappings for a project

# Results (Expected/Actual):

- expected is that on disk files that are now mapped should be immediately detected

# Environment (i.e. 'pootle --version', DB, OS, Browser):

2.9+



Discussion:

Resolving patch:
diff --git a/pootle/apps/pootle_project/forms.py b/pootle/apps/pootle_project/forms.py
--- a/pootle/apps/pootle_project/forms.py
+++ b/pootle/apps/pootle_project/forms.py
@@ -12,6 +12,7 @@
 
 from django_rq.queues import get_queue
 
+from pootle.core.signals import update_revisions
 from pootle.core.utils.db import useable_connection
 from pootle.i18n.gettext import ugettext as _
 from pootle_config.utils import ObjectConfig
@@ -140,8 +141,18 @@ def save(self, response_url=None, commit=True):
         if not self.cleaned_data["fs_code"]:
             if tp.language.code in mappings:
                 del mappings[tp.language.code]
+                context = self.instance.project.directory
+                update_revisions.send(
+                    context.__class__,
+                    instance=context,
+                    keys=["stats"])
         else:
             mappings[tp.language.code] = self.cleaned_data["fs_code"]
+            context = self.instance.project.directory
+            update_revisions.send(
+                context.__class__,
+                instance=context,
+                keys=["stats"])
         config["pootle.core.lang_mapping"] = dict(
             (v, k) for k, v in mappings.iteritems())
         if initialize_from_templates:


Test patch:
Repository: translate/pootle

Issue:
Adjust initdb to use {POOTLE_TRANSLATION_DIRECTORY} placeholder



Discussion:

Resolving patch:
diff --git a/pootle/core/initdb.py b/pootle/core/initdb.py
--- a/pootle/core/initdb.py
+++ b/pootle/core/initdb.py
@@ -7,9 +7,7 @@
 # AUTHORS file for copyright and authorship information.
 
 import logging
-import os
 
-from django.conf import settings
 from django.contrib.auth import get_user_model
 from django.contrib.auth.models import Permission
 from django.contrib.contenttypes.models import ContentType
@@ -246,9 +244,9 @@ def create_terminology_project(self):
         po = Format.objects.get(name="po")
         terminology = self._create_object(Project, **criteria)[0]
         terminology.filetypes.add(po)
-        terminology.config["pootle_fs.fs_url"] = os.path.join(
-            settings.POOTLE_TRANSLATION_DIRECTORY,
-            terminology.code)
+        terminology.config["pootle_fs.fs_url"] = (
+            "{POOTLE_TRANSLATION_DIRECTORY}%s"
+            % terminology.code)
         terminology.config["pootle_fs.fs_type"] = "localfs"
         terminology.config["pootle_fs.translation_mappings"] = dict(
             default="/<language_code>/<dir_path>/<filename>.<ext>")
@@ -273,9 +271,9 @@ def create_default_projects(self):
             'checkstyle': "standard"}
         tutorial = self._create_object(Project, **criteria)[0]
         tutorial.filetypes.add(po)
-        tutorial.config["pootle_fs.fs_url"] = os.path.join(
-            settings.POOTLE_TRANSLATION_DIRECTORY,
-            tutorial.code)
+        tutorial.config["pootle_fs.fs_url"] = (
+            "{POOTLE_TRANSLATION_DIRECTORY}%s"
+            % tutorial.code)
         tutorial.config["pootle_fs.fs_type"] = "localfs"
         tutorial.config["pootle_fs.translation_mappings"] = dict(
             default="/<language_code>/<dir_path>/<filename>.<ext>")


Test patch:
Repository: translate/pootle

Issue:
Pootle FS --overwrite doesn't work in default case
# Steps to reproduce:

Simple project with `one.po` file, changed in both Pootle and FS.  Wanting to discard all of Pootle and keep the FS version.

```
(pootle)~/dev/pootle/pootle/translations $ pootle fs state pfs
Conflicts (1)
-------------
Both Pootle Store and file in filesystem have changed

  /af/pfs/one.po
   <-->  /af/one.po
```

Use `resolve --overwrite` to achieve this.

```
(pootle)~/dev/pootle/pootle/translations $ pootle fs resolve --overwrite pfs
Staged for overwrite from filesystem (1)
----------------------------------------
Files staged to overwrite the corresponding Store

  /af/pfs/one.po
   <-->  /af/one.po
```
Execute `sync`

```
(pootle)~/dev/pootle/pootle/translations $ pootle fs sync pfs
No changes made
```

Recheck state:

```
(pootle)~/dev/pootle/pootle/translations $ pootle fs state pfs
Conflicts (1)
-------------
Both Pootle Store and file in filesystem have changed

  /af/pfs/one.po
   <-->  /af/one.po
```

In fact this last step can be repeated, `resolve --overwrite` says its staged, then use `state` and it indicates that it is still in conflict.




Discussion:

Resolving patch:
diff --git a/pootle/apps/pootle_fs/plugin.py b/pootle/apps/pootle_fs/plugin.py
--- a/pootle/apps/pootle_fs/plugin.py
+++ b/pootle/apps/pootle_fs/plugin.py
@@ -315,10 +315,10 @@ def resolve(self, state, response, fs_path=None, pootle_path=None,
         kwargs = {}
         if pootle_wins:
             kwargs["resolve_conflict"] = POOTLE_WINS
+        else:
+            kwargs["resolve_conflict"] = SOURCE_WINS
         if merge:
             kwargs["staged_for_merge"] = True
-            if not pootle_wins:
-                kwargs["resolve_conflict"] = SOURCE_WINS
         self.create_store_fs(state["conflict_untracked"], **kwargs)
         self.update_store_fs(state["conflict"], **kwargs)
         action_type = (


Test patch:
Repository: translate/pootle

Issue:
Init from templates doesnt create directories correctly
### Steps to reproduce:

- create a new project which has subdirectories
- load templates from fs
- init a new tp from admin ui

### Results (Expected/Actual):

- new dirs/stores are created, but the dirs dont have the correct link to their tp

### Environment (i.e. 'pootle --version', DB, OS, Browser):

2.9



Discussion:

Resolving patch:
diff --git a/pootle/apps/pootle_translationproject/models.py b/pootle/apps/pootle_translationproject/models.py
--- a/pootle/apps/pootle_translationproject/models.py
+++ b/pootle/apps/pootle_translationproject/models.py
@@ -238,6 +238,7 @@ def create_parent_dirs(self, pootle_path):
             parent, __ = Directory.objects.get_or_create(
                 pootle_path=path,
                 parent=parent,
+                tp=self,
                 name=posixpath.basename(path.rstrip("/")))
         return parent
 


Test patch:
Repository: translate/pootle

Issue:
Pootle Install 
I am a Pootle novice, I successfully installed it on the mac, but when i want to deploy to the production environment, the following installation error occurs.

# Steps to reproduce:

1. I create a virtualenv env
2. Install Pootle requirements
3. Install Pootle, using `pip install --process-dependency-links Pootle`

# Results (Expected/Actual):

```Python
Collecting Pootle
  Using cached Pootle-2.8.1.tar.bz2
    Complete output from command python setup.py egg_info:
    Pootle requires a non-PyPI dependency, when using pip ensure you use the --process-dependency-links option.
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-build-_2TvXs/Pootle/setup.py", line 453, in <module>
        long_description=parse_long_description(README_FILE, tag=True),
      File "/tmp/pip-build-_2TvXs/Pootle/setup.py", line 404, in parse_long_description
        replace_urls()
      File "/tmp/pip-build-_2TvXs/Pootle/setup.py", line 332, in replace_urls
        branch = version.get_git_branch()
      File "/tmp/pip-build-_2TvXs/Pootle/pootle/core/utils/version.py", line 231, in get_git_branch
        'HEAD']).strip()
    AttributeError: 'NoneType' object has no attribute 'strip'
```


# Environment (i.e. 'pootle --version', DB, OS, Browser):

python version: 2.7.12
system: ubuntu 16.04



Discussion:

Resolving patch:
diff --git a/pootle/core/utils/version.py b/pootle/core/utils/version.py
--- a/pootle/core/utils/version.py
+++ b/pootle/core/utils/version.py
@@ -228,10 +228,10 @@ def get_git_branch():
     'feature/proper_version'
     """
     branch = _shell_command(['/usr/bin/git', 'symbolic-ref', '-q',
-                             'HEAD']).strip()
+                             'HEAD'])
     if not branch:
         return None
-    return "/".join(branch.split("/")[2:])
+    return "/".join(branch.strip().split("/")[2:])
 
 
 @lru_cache()


Test patch:
Repository: unionai-oss/pandera

Issue:
update readme on release of next version
suggest replacing

```**Supports:** python 2.7, 3.5, 3.6```

with:

```[![PyPI pyversions](https://img.shields.io/pypi/pyversions/pandera.svg)](https://pypi.python.org/pypi/pandera/)```

when the new metadata is available on pypi.

It will be 'missing' before pypi is updated:
[![PyPI pyversions](https://img.shields.io/pypi/pyversions/pandera.svg)](https://pypi.python.org/pypi/pandera/)


Discussion:

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -35,6 +35,7 @@
         'Operating System :: OS Independent',
         'Intended Audience :: Science/Research',
         'Programming Language :: Python',
+        'Programming Language :: Python :: 2.7',
         'Programming Language :: Python :: 3',
         'Programming Language :: Python :: 3.5',
         'Programming Language :: Python :: 3.6',


Test patch:
Repository: unionai-oss/pandera

Issue:
drop python 2.7 support
since python2.7 will no longer be maintained by Jan 1, 2020, we should also no longer maintain it moving forward.

pandera v0.1.3 will be released on June 9th, 2019.

Should plan to follow up with a v0.2.0 version bump to deprecate support for python 2.7 after resolving a few more issues


Discussion:
Going to delay release of this until the 0.1.5 release milestone
this will be a multi-step transition, but first step is to stop CI support for 2.7, and remove from pypi

Resolving patch:
diff --git a/pandera/__init__.py b/pandera/__init__.py
--- a/pandera/__init__.py
+++ b/pandera/__init__.py
@@ -23,4 +23,4 @@
     )
 
 
-__version__ = "0.1.5"
+__version__ = "0.2.0"
diff --git a/pandera/pandera.py b/pandera/pandera.py
--- a/pandera/pandera.py
+++ b/pandera/pandera.py
@@ -1,7 +1,6 @@
 """Validate Pandas Data Structures."""
 
 import inspect
-import sys
 import warnings
 import pandas as pd
 import wrapt
@@ -954,10 +953,7 @@ def __repr__(self):
 
 
 def _get_fn_argnames(fn):
-    if sys.version_info.major >= 3:
-        arg_spec_args = inspect.getfullargspec(fn).args
-    else:
-        arg_spec_args = inspect.getargspec(fn).args
+    arg_spec_args = inspect.getfullargspec(fn).args
 
     if inspect.ismethod(fn) and arg_spec_args[0] == "self":
         # don't include "self" argument
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -2,10 +2,9 @@
 
 with open('README.md') as f:
     long_description = f.read()
-
 setup(
     name="pandera",
-    version="0.1.5",
+    version="0.2.0",
     author="Niels Bantilan",
     author_email="niels.bantilan@gmail.com",
     description="A light-weight and flexible validation package for pandas "
@@ -23,20 +22,18 @@
         "pandera",
     ],
     install_requires=[
-        "enum34 ; python_version<'3.4'",
         "numpy >= 1.9.0",
         "pandas >= 0.23.0",
         "wrapt",
-        "scipy ; python_version<'2.7'",
+        "scipy ; python_version>='3.5'",
     ],
-    python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*',
+    python_requires='>=3.5',
     platforms='any',
     classifiers=[
         'Development Status :: 5 - Production/Stable',
         'Operating System :: OS Independent',
         'Intended Audience :: Science/Research',
         'Programming Language :: Python',
-        'Programming Language :: Python :: 2.7',
         'Programming Language :: Python :: 3',
         'Programming Language :: Python :: 3.5',
         'Programming Language :: Python :: 3.6',
@@ -45,3 +42,4 @@
         ],
 
 )
+


Test patch:
diff --git a/ci_tests.sh b/ci_tests.sh
--- a/ci_tests.sh
+++ b/ci_tests.sh
@@ -10,7 +10,6 @@ run_ci() {
         conda remove -q -y -n pandera-ci-env-$1 --all
 }
 
-run_ci 2.7
 run_ci 3.5
 run_ci 3.6
 run_ci 3.7
Repository: unionai-oss/pandera

Issue:
Issue with duplicated index
When I'm dealing with a quite large dataframe (269779 rows) with highly duplicated index, validation became extremely slow to the degree it didn't finish even after 1 hour.

<img width="156" alt="Screen Shot 2020-04-02 at 10 31 42 PM" src="https://user-images.githubusercontent.com/12246126/78255068-c6f4ca00-7531-11ea-99b4-b2f5e6dd2aa1.png">

I used the following schema.

```py
pa.DataFrameSchema({
    "i": pa.Column(pa.Int),
    "word": pa.Column(pa.String),
    "signal": pa.Column(pa.Float),
    "userId": pa.Column(pa.String),
    "session": pa.Column(pa.Int),
    "cheat": pa.Column(pa.Bool),
    "time": pa.Column(pa.Int),
    "eltime": pa.Column(pa.Float),
    "wpm": pa.Column(pa.Float)
}, strict = True).validate(df)
```

The code like below resulted in a highly duplicated index, which, I believe, is a typical way to transform data.

```py
def explode_word(x):
   return (long python list)
df['word'] = df.apply(explode_word, axis=1)
```


Discussion:

Resolving patch:
diff --git a/pandera/schemas.py b/pandera/schemas.py
--- a/pandera/schemas.py
+++ b/pandera/schemas.py
@@ -603,19 +603,18 @@ def validate(
                 (series.name, _dtype, series.dtype))
 
         check_results = []
-
-        if isinstance(check_obj, pd.Series):
-            check_args = [series, None]
-        else:
-            _check_obj = check_obj.loc[series.index].copy()
-            _check_obj[self.name] = series
-            check_args = [_check_obj, self.name]
-
-        for check_index, check in enumerate(self.checks):
-            check_results.append(
-                _handle_check_results(
-                    self, check_index, check, check(*check_args))
-            )
+        if self.checks:
+            if isinstance(check_obj, pd.Series):
+                check_args = [series, None]
+            else:
+                _check_obj = check_obj.loc[series.index.unique()].copy()
+                check_args = [_check_obj, self.name]
+
+            for check_index, check in enumerate(self.checks):
+                check_results.append(
+                    _handle_check_results(
+                        self, check_index, check, check(*check_args))
+                )
 
         assert all(check_results)
         return check_obj


Test patch:
diff --git a/tests/test_checks_builtin.py b/tests/test_checks_builtin.py
--- a/tests/test_checks_builtin.py
+++ b/tests/test_checks_builtin.py
@@ -369,12 +369,10 @@ def test_failing(values, value, failure_cases):
 
     @staticmethod
     @pytest.mark.parametrize('series_values, value', [
-        ((1, None), 1),
-        ((-1, None, -1), -1),
-        ((pd.Timestamp("2015-02-01"),
-          None),
-         pd.Timestamp("2015-02-01")),
-        (("foo", None), "foo")
+        [(1, None), 1],
+        [(-1, None, -1), -1],
+        [(pd.Timestamp("2015-02-01"), None), pd.Timestamp("2015-02-01")],
+        [("foo", None), "foo"],
     ])
     def test_failing_with_none(series_values, value):
         """Validate the check works also on dataframes with None values"""
Repository: unionai-oss/pandera

Issue:
pandas_dtype should accept numpy scalar types
**Is your feature request related to a problem? Please describe.**

Branched off from #221, doing numpy dtypes as a separate issue

Users can specify numpy scalar types: https://numpy.org/doc/stable/reference/arrays.scalars.html#arrays-scalars-built-in


Discussion:

Resolving patch:
diff --git a/pandera/dtypes.py b/pandera/dtypes.py
--- a/pandera/dtypes.py
+++ b/pandera/dtypes.py
@@ -18,8 +18,10 @@
     "uint8", "uint16", "uint32", "uint64",
 ]
 
-NUMPY_TYPES = frozenset([item for sublist in np.sctypes.values() for item in sublist])
-NUMPY_TYPES_ALIAS = frozenset([np.complex])
+NUMPY_TYPES = (
+    frozenset([item for sublist in np.sctypes.values() for item in sublist])
+    .union(frozenset([np.complex, np.int, np.uint, np.float]))
+)
 
 # for int and float dtype, delegate string representation to the
 # default based on OS. In Windows, pandas defaults to int64 while numpy
@@ -257,16 +259,7 @@ def from_numpy_type(cls, numpy_type: np.dtype) -> "PandasDtype":
 
         :param numpy_type: numpy data type.
         """
-
-        # numpy aliases
-        pandas_dtype = {
-            np.complex: cls.Complex128  # np.complex is alias for np.complex128
-        }.get(numpy_type)
-
-        if pandas_dtype is None:
-            pandas_dtype = cls.from_str_alias(numpy_type.__name__)
-
-        return pandas_dtype
+        return cls.from_str_alias(numpy_type.__name__)
 
     def __eq__(self, other):
         # pylint: disable=comparison-with-callable
diff --git a/pandera/schemas.py b/pandera/schemas.py
--- a/pandera/schemas.py
+++ b/pandera/schemas.py
@@ -781,8 +781,7 @@ def dtype(self) -> Union[str, None]:
         elif isinstance(self._pandas_dtype, str):
             dtype = PandasDtype.from_str_alias(  # type: ignore
                 self._pandas_dtype).str_alias
-        elif self._pandas_dtype in dtypes.NUMPY_TYPES or \
-                self._pandas_dtype in dtypes.NUMPY_TYPES_ALIAS:
+        elif self._pandas_dtype in dtypes.NUMPY_TYPES:
             dtype = PandasDtype.from_numpy_type(self._pandas_dtype).str_alias
         elif isinstance(self._pandas_dtype, type):
             dtype = PandasDtype.from_python_type(self._pandas_dtype).str_alias


Test patch: