internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: jdb78/pytorch-forecasting

Issue:
Scale set to 0 by `TorchNormalizer(method="identity", center=False)` causing division by 0
- PyTorch-Forecasting version: 0.10.1
- PyTorch version: 1.10.2+cu111
- Python version: 3.8.10
- Operating System: Ubuntu

My goal is to run `DeepAR `with `NegativeBinomialDistributionLoss`.
As specified in the documentation, one requirement of this loss is that the original target normalizer of the `TimeSeriesDataset` should not be centered (i.e., `target_normalizer.center` should be equal to `False`), otherwise an exception is raised.
For such a loss, it seems to me that the best thing to do would be to use `TorchNormalizer(method="identity", center=False)` as target normalizer (which amounts to no normalization: the target is left untouched).

The issue is that when the targt normalizer is set to `TorchNormalizer(method="identity", center=False)`, the attribute `scale_`of the normalizer is set to 0 in method `_set_parameters` (see line 457 of file `pytorch_forecasting.data.encoders.py` where: `self.scale_ = self.center_` and `self.center_`is set to 0 few lines above). This raises a warning `scale is below 1e-7...` and causes issues in the `transform` method (division by 0, see line 500 of file `pytorch_forecasting.data.encoders.py`).

I think the logic should be changed. One idea could be not to swap center and scale when `center_ ` is close to zero for instance.

What do you think?




Discussion:

Resolving patch:
diff --git a/pytorch_forecasting/data/encoders.py b/pytorch_forecasting/data/encoders.py
--- a/pytorch_forecasting/data/encoders.py
+++ b/pytorch_forecasting/data/encoders.py
@@ -498,7 +498,7 @@ def _set_parameters(
                 q_75 = np.percentile(y_scale, 75)
                 q_25 = np.percentile(y_scale, 25)
             self.scale_ = (q_75 - q_25) / 2.0 + eps
-        if not self.center:
+        if not self.center and self.method != "identity":
             self.scale_ = self.center_
             if isinstance(y_center, torch.Tensor):
                 self.center_ = torch.zeros_like(self.center_)


Test patch:
Repository: Frojd/Wagtail-Pipit

Issue:
Use Werkzeug
Add django-extensions and Werkzeug to local requirements, and use runserver_plus in docker-entrypoint.sh.
It is a lot faster than regular runserver in Docker.


Discussion:
@rinti Have you verified this on our apps?
@marteinn Yep, It's like night and day. 
@rinti Awesome!

Resolving patch:
diff --git a/Example-Project/src/core/settings/local.py b/Example-Project/src/core/settings/local.py
--- a/Example-Project/src/core/settings/local.py
+++ b/Example-Project/src/core/settings/local.py
@@ -17,6 +17,7 @@
 # Add django debug toolbar when using local version
 INSTALLED_APPS += [
     'debug_toolbar',
+    'django_extensions',
 ]
 
 MIDDLEWARE_CLASSES += [
diff --git a/{{cookiecutter.project_name}}/src/core/settings/local.py b/{{cookiecutter.project_name}}/src/core/settings/local.py
--- a/{{cookiecutter.project_name}}/src/core/settings/local.py
+++ b/{{cookiecutter.project_name}}/src/core/settings/local.py
@@ -17,6 +17,7 @@
 # Add django debug toolbar when using local version
 INSTALLED_APPS += [
     'debug_toolbar',
+    'django_extensions',
 ]
 
 MIDDLEWARE_CLASSES += [


Test patch:
Repository: OCA/stock-logistics-warehouse

Issue:
tests of stock_reserve_sale fail with recent odoo/odoo. it works with older odoo
I'm investigating this now.



Discussion:
`git bisect` pointed the finger to: https://github.com/odoo/odoo/commit/d4152c2a40877fd62815d0a55bce5e64b053db72

related bug: https://github.com/odoo/odoo/issues/5797


Resolving patch:
diff --git a/stock_reserve/__openerp__.py b/stock_reserve/__openerp__.py
--- a/stock_reserve/__openerp__.py
+++ b/stock_reserve/__openerp__.py
@@ -21,7 +21,7 @@
 
 {'name': 'Stock Reservation',
  'summary': 'Stock reservations on products',
- 'version': '0.1',
+ 'version': '0.2',
  'author': "Camptocamp,Odoo Community Association (OCA)",
  'category': 'Warehouse',
  'license': 'AGPL-3',
diff --git a/stock_reserve/migrations/0.2/post-migration.py b/stock_reserve/migrations/0.2/post-migration.py
new file mode 100644
--- /dev/null
+++ b/stock_reserve/migrations/0.2/post-migration.py
@@ -0,0 +1,42 @@
+# -*- coding: utf-8 -*-
+#    Author: Leonardo Pistone
+#    Copyright 2015 Camptocamp SA
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+
+def migrate(cr, installed_version):
+    """Update a wrong location that is no_update in XML."""
+    if installed_version == '8.0.0.1':
+        cr.execute('''
+            UPDATE stock_location
+            SET location_id = (
+                SELECT res_id
+                FROM ir_model_data
+                WHERE name = 'stock_location_locations'
+                AND module = 'stock'
+            )
+            WHERE id = (
+                SELECT res_id
+                FROM ir_model_data
+                WHERE name = 'stock_location_reservation'
+                AND module = 'stock_reserve'
+            )
+            AND location_id = (
+                SELECT res_id
+                FROM ir_model_data
+                WHERE name = 'stock_location_company'
+                AND module = 'stock'
+            );
+        ''')


Test patch:
Repository: OCA/stock-logistics-warehouse

Issue:
[13.0] stock_request error to create or selected product
I install stock_request but get error, at create new record or select product show this error, any idea??
![image](https://user-images.githubusercontent.com/7775116/95130511-4c944500-0722-11eb-9d81-47e63047fd3f.png)



Discussion:

Resolving patch:
diff --git a/stock_request/models/stock_request_abstract.py b/stock_request/models/stock_request_abstract.py
--- a/stock_request/models/stock_request_abstract.py
+++ b/stock_request/models/stock_request_abstract.py
@@ -107,20 +107,28 @@ def _compute_product_qty(self):
     @api.depends("product_id", "warehouse_id", "location_id")
     def _compute_route_ids(self):
         route_obj = self.env["stock.location.route"]
-        for wh in self.mapped("warehouse_id"):
-            wh_routes = route_obj.search([("warehouse_ids", "=", wh.id)])
-            for record in self.filtered(lambda r: r.warehouse_id == wh):
-                routes = route_obj
-                if record.product_id:
-                    routes += record.product_id.mapped(
-                        "route_ids"
-                    ) | record.product_id.mapped("categ_id").mapped("total_route_ids")
-                if record.warehouse_id:
-                    routes |= wh_routes
-                parents = record.get_parents().ids
-                record.route_ids = routes.filtered(
-                    lambda r: any(p.location_id.id in parents for p in r.rule_ids)
+        routes = route_obj.search(
+            [("warehouse_ids", "in", self.mapped("warehouse_id").ids)]
+        )
+        routes_by_warehouse = {}
+        for route in routes:
+            for warehouse in route.warehouse_ids:
+                routes_by_warehouse.setdefault(
+                    warehouse.id, self.env["stock.location.route"]
                 )
+                routes_by_warehouse[warehouse.id] |= route
+        for record in self:
+            routes = route_obj
+            if record.product_id:
+                routes += record.product_id.mapped(
+                    "route_ids"
+                ) | record.product_id.mapped("categ_id").mapped("total_route_ids")
+            if record.warehouse_id and routes_by_warehouse.get(record.warehouse_id.id):
+                routes |= routes_by_warehouse[record.warehouse_id.id]
+            parents = record.get_parents().ids
+            record.route_ids = routes.filtered(
+                lambda r: any(p.location_id.id in parents for p in r.rule_ids)
+            )
 
     def get_parents(self):
         location = self.location_id


Test patch:
Repository: OCA/stock-logistics-warehouse

Issue:
[12.0] stock_secondary_unit "secondary qty" value in picking not affecting "initial demand"
AFFECTED VERSIONS

12.0 (it works ok on 13.0)

STEPS TO REPRODUCE

Activate Units of Measure in general settings > inventory

Inventory > Master Data > Products > Set a secondary unit in a product

![image](https://user-images.githubusercontent.com/55489873/123983258-04aa0200-d9c4-11eb-90a1-e32686f07ac4.png)

Create a new transfer > add product > select secondary UoM > input secondary qty

![image](https://user-images.githubusercontent.com/55489873/123983462-2e632900-d9c4-11eb-9b3c-c813bd2be121.png)

CURRENT BEHAVIOR

Value "Initial demand" is not affected by secondary qty input
In the same way, if "Initial demand" is set, "secondary qty" does not change - basically there is no relation between the two fields

![image](https://user-images.githubusercontent.com/55489873/123983876-7f731d00-d9c4-11eb-9686-bf8d54618d2b.png)

REQUIRED BEHAVIOR 

When "secondary qty" is updated, also "initial demand" should update - and viceversa, as it happens in SO with secondary unit modules

VIDEO

https://recordit.co/zcuDUx6xco








Discussion:

Resolving patch:
diff --git a/stock_secondary_unit/models/stock_move.py b/stock_secondary_unit/models/stock_move.py
--- a/stock_secondary_unit/models/stock_move.py
+++ b/stock_secondary_unit/models/stock_move.py
@@ -96,3 +96,21 @@ def create(self, vals):
                 'secondary_uom_id': move.secondary_uom_id.id,
             })
         return super().create(vals)
+
+    @api.multi
+    def write(self, vals):
+        for rec in self:
+            move = rec.move_id
+            if move.secondary_uom_id:
+                uom = rec.product_id.uom_id
+                factor = move.secondary_uom_id.factor * uom.factor
+                move_line_qty = vals.get('product_uom_qty', rec.product_uom_qty)
+                qty = float_round(
+                    move_line_qty / (factor or 1.0),
+                    precision_rounding=move.secondary_uom_id.uom_id.rounding
+                )
+                vals.update({
+                    'secondary_uom_qty': qty,
+                    'secondary_uom_id': move.secondary_uom_id.id,
+                })
+        return super().write(vals)


Test patch:
Repository: HypothesisWorks/hypothesis

Issue:
Allow varargs when using only keyword arguments
If a test function is wrapped by another decorator, it may be hard to avoid varargs. However, it should still be safe to use `@given` if no positional arguments are used.

I have experimented with this by modifying `run_test_with_generator` to do the following instead of the current vararg check:

``` python
        if generator_arguments and original_argspec.varargs:
            raise InvalidArgument(
                'varargs are not supported with positional arguments to @given'
            )
```

`tox -e py26,py27` passes locally for me, so I have reasonable confidence that this doesn't break anything obvious. If you're okay with this change, I'm happy to submit a pull request with the necessary tests and such.



Discussion:
Yes, this seems like a reasonable change. 


Resolving patch:
diff --git a/src/hypothesis/core.py b/src/hypothesis/core.py
--- a/src/hypothesis/core.py
+++ b/src/hypothesis/core.py
@@ -388,9 +388,9 @@ def run_test_with_generator(test):
             random = provided_random or Random()
 
         original_argspec = inspect.getargspec(test)
-        if original_argspec.varargs:
+        if generator_arguments and original_argspec.varargs:
             raise InvalidArgument(
-                'varargs are not supported with @given'
+                'varargs are not supported with positional arguments to @given'
             )
         extra_kwargs = [
             k for k in generator_kwargs if k not in original_argspec.args]


Test patch:
diff --git a/tests/cover/test_validation.py b/tests/cover/test_validation.py
--- a/tests/cover/test_validation.py
+++ b/tests/cover/test_validation.py
@@ -32,6 +32,26 @@ def has_varargs(*args):
     assert 'varargs' in e.value.args[0]
 
 
+def test_varargs_without_positional_arguments_allowed():
+    @given(somearg=integers())
+    def has_varargs(somearg, *args):
+        pass
+
+
+def test_errors_when_given_varargs_and_kwargs_with_positional_arguments():
+    with pytest.raises(InvalidArgument) as e:
+        @given(integers())
+        def has_varargs(*args, **kw):
+            pass
+    assert 'varargs' in e.value.args[0]
+
+
+def test_varargs_and_kwargs_without_positional_arguments_allowed():
+    @given(somearg=integers())
+    def has_varargs(*args, **kw):
+        pass
+
+
 def test_bare_given_errors():
     with pytest.raises(InvalidArgument):
         given()
Repository: HypothesisWorks/hypothesis

Issue:
The data strategy isn‘t documented
Spotted while triaging #519.

It doesn’t appear anywhere in <http://hypothesis.readthedocs.io/en/latest/data.html?highlight=data>.


Discussion:
Additionally, the docstring for that strategy says "See the rest of the documentation for more complete information.", but I have no idea what it's referring to.

Resolving patch:
diff --git a/src/hypothesis/strategies.py b/src/hypothesis/strategies.py
--- a/src/hypothesis/strategies.py
+++ b/src/hypothesis/strategies.py
@@ -40,14 +40,14 @@
     'choices', 'streaming',
     'booleans', 'integers', 'floats', 'complex_numbers', 'fractions',
     'decimals',
-    'characters', 'text', 'binary',
+    'characters', 'text', 'binary', 'uuids',
     'tuples', 'lists', 'sets', 'frozensets',
     'dictionaries', 'fixed_dictionaries',
     'sampled_from', 'permutations',
     'builds',
     'randoms', 'random_module',
     'recursive', 'composite',
-    'shared', 'runner',
+    'shared', 'runner', 'data',
 ]
 
 _strategies = set()


Test patch:
Repository: HypothesisWorks/hypothesis

Issue:
External pull requests currently fail the deploy task
The build on #536 is currently failing because the decryption is trying to run and it doesn't have access to the decryption environment variables because it comes from @Zac-HD's fork rather than the main repo.

The solution is just to have that task skip for external pull requests I think.


Discussion:

Resolving patch:
diff --git a/scripts/deploy.py b/scripts/deploy.py
--- a/scripts/deploy.py
+++ b/scripts/deploy.py
@@ -38,6 +38,8 @@
 
 
 if __name__ == '__main__':
+    if os.environ.get('TRAVIS_SECURE_ENV_VARS', None) != 'true':
+        sys.exit(0)
 
     print('Decrypting secrets')
 


Test patch:
Repository: HypothesisWorks/hypothesis

Issue:
Changelog doesn't check for date for *this* release
https://github.com/HypothesisWorks/hypothesis-python/pull/580 is currently passing its build but shouldn't be because its date in the changelog says TBD. However the current date was present for *another*  release.

The changelog check should check for the current date occurring on the same line as the current version number.


Discussion:

Resolving patch:
diff --git a/scripts/check-changelog.py b/scripts/check-changelog.py
--- a/scripts/check-changelog.py
+++ b/scripts/check-changelog.py
@@ -34,28 +34,18 @@
         print('No source changes found')
         sys.exit(0)
 
-    changelog = tools.changelog()
-
-    if '\n%s - ' % (tools.__version__,) not in changelog:
-        print(
-            'The current version (%s) isn\'t mentioned in the changelog' % (
-                tools.__version__,))
-        sys.exit(1)
-
     now = datetime.utcnow()
-
     hour = timedelta(hours=1)
-
-    acceptable_dates = {
-        d.strftime('%Y-%m-%d')
+    acceptable_lines = sorted(set(
+        '{} - {}'.format(tools.__version__, d.strftime('%Y-%m-%d'))
         for d in (now, now + hour, now - hour)
-    }
-
-    when = ' or '.join(sorted(acceptable_dates))
-
-    if not any(d in changelog for d in acceptable_dates):
-        print((
-            'The current date (%s) isn\'t mentioned in the changelog. '
-            'Remember this will be released as soon as you merge to master!'
-        ) % (when,))
+    ))
+
+    for line in tools.changelog().split('\n'):
+        if line.strip() in acceptable_lines:
+            break
+    else:
+        print('No line with version and current date (%s) in the changelog. '
+              'Remember this will be released as soon as you merge to master!'
+              % ' or '.join(repr(line) for line in acceptable_lines))
         sys.exit(1)


Test patch:
Repository: HypothesisWorks/hypothesis

Issue:
Sampled_from() should work with collections.OrderedDict
OrderedDict should satisfy the replayability requirement, so sampling from it should be possible.
Currently it raises exception:
`HypothesisDeprecationWarning: Cannot sample from odict_values`


Discussion:
You could throw in a `list` call to stop Hypothesis complaining.

However, the iteration order of an `OrderedDict` is stable (obviously), so I think this ought to be allowed, unless there's some nuance I missed here.
Yep, this seems like a straight up bug/oversight. Patch shortly.

Resolving patch:
diff --git a/src/hypothesis/internal/conjecture/utils.py b/src/hypothesis/internal/conjecture/utils.py
--- a/src/hypothesis/internal/conjecture/utils.py
+++ b/src/hypothesis/internal/conjecture/utils.py
@@ -19,7 +19,7 @@
 
 import enum
 import math
-from collections import Sequence
+from collections import Sequence, OrderedDict
 
 from hypothesis._settings import note_deprecation
 from hypothesis.internal.compat import hbytes, bit_length, int_to_bytes, \
@@ -105,7 +105,7 @@ def centered_integer_range(data, lower, upper, center):
 
 
 def check_sample(values):
-    if not isinstance(values, (Sequence, enum.EnumMeta)):
+    if not isinstance(values, (OrderedDict, Sequence, enum.EnumMeta)):
         note_deprecation(
             ('Cannot sample from %r, not a sequence.  ' % (values,)) +
             'Hypothesis goes to some length to ensure that sampling an '
diff --git a/src/hypothesis/version.py b/src/hypothesis/version.py
--- a/src/hypothesis/version.py
+++ b/src/hypothesis/version.py
@@ -17,5 +17,5 @@
 
 from __future__ import division, print_function, absolute_import
 
-__version_info__ = (3, 11, 2)
+__version_info__ = (3, 11, 3)
 __version__ = '.'.join(map(str, __version_info__))


Test patch:
diff --git a/tests/cover/test_sampled_from.py b/tests/cover/test_sampled_from.py
--- a/tests/cover/test_sampled_from.py
+++ b/tests/cover/test_sampled_from.py
@@ -18,6 +18,7 @@
 from __future__ import division, print_function, absolute_import
 
 import enum
+import collections
 
 from hypothesis import given, settings
 from hypothesis.errors import HypothesisDeprecationWarning
@@ -26,6 +27,8 @@
 
 an_enum = enum.Enum('A', 'a b c')
 
+an_ordereddict = collections.OrderedDict([('a', 1), ('b', 2), ('c', 3)])
+
 
 @given(sampled_from((1, 2)))
 @settings(min_satisfying_examples=10)
@@ -44,6 +47,16 @@ def test_can_sample_sets_while_deprecated():
         assert sampled_from(set('abc')).example() in 'abc'
 
 
+def test_can_sample_sequence_without_warning():
+    with settings(strict=True):
+        sampled_from([1, 2, 3]).example()
+
+
+def test_can_sample_ordereddict_without_warning():
+    with settings(strict=True):
+        sampled_from(an_ordereddict).example()
+
+
 @given(sampled_from(an_enum))
 def test_can_sample_enums(member):
     with settings(strict=True):
Repository: HypothesisWorks/hypothesis

Issue:
Travis CI should build new changelog before checking documentation
It's currently something of a hole in our build process - we're not actually building the up to date changelog as part of the documentation build because it doesn't get updated until we do the deploy.


Discussion:

Resolving patch:
diff --git a/scripts/hypothesistooling.py b/scripts/hypothesistooling.py
--- a/scripts/hypothesistooling.py
+++ b/scripts/hypothesistooling.py
@@ -124,6 +124,12 @@ def has_source_changes(version=None):
     ]) != 0
 
 
+def has_uncommitted_changes(filename):
+    return subprocess.call([
+        'git', 'diff', '--exit-code', filename
+    ]) != 0
+
+
 def git(*args):
     subprocess.check_call(('git',) + args)
 
@@ -247,7 +253,7 @@ def parse_release_file():
     return release_type, release_contents
 
 
-def update_for_pending_release():
+def update_changelog_and_version():
     global __version_info__
     global __version__
 
@@ -313,10 +319,14 @@ def update_for_pending_release():
     with open(CHANGELOG_FILE, 'w') as o:
         o.write('\n'.join(new_changelog_parts))
 
+
+def update_for_pending_release():
+    update_changelog_and_version()
+
     git('rm', RELEASE_FILE)
     git('add', CHANGELOG_FILE, VERSION_FILE)
 
     git(
         'commit',
-        '-m', 'Bump version to %s and update changelog' % (new_version_string,)
+        '-m', 'Bump version to %s and update changelog' % (__version__,)
     )
diff --git a/scripts/update-changelog-for-docs.py b/scripts/update-changelog-for-docs.py
new file mode 100644
--- /dev/null
+++ b/scripts/update-changelog-for-docs.py
@@ -0,0 +1,39 @@
+#!/usr/bin/env python
+
+# coding=utf-8
+#
+# This file is part of Hypothesis, which may be found at
+# https://github.com/HypothesisWorks/hypothesis-python
+#
+# Most of this work is copyright (C) 2013-2017 David R. MacIver
+# (david@drmaciver.com), but it contains contributions by others. See
+# CONTRIBUTING.rst for a full list of people who may hold copyright, and
+# consult the git log if you need to determine who owns an individual
+# contribution.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public License,
+# v. 2.0. If a copy of the MPL was not distributed with this file, You can
+# obtain one at http://mozilla.org/MPL/2.0/.
+#
+# END HEADER
+
+from __future__ import division, print_function, absolute_import
+
+import os
+import sys
+
+import hypothesistooling as tools
+
+sys.path.append(os.path.dirname(__file__))  # noqa
+
+
+if __name__ == '__main__':
+    if not tools.has_release():
+        sys.exit(0)
+    if tools.has_uncommitted_changes(tools.CHANGELOG_FILE):
+        print(
+            'Cannot build documentation with uncommitted changes to '
+            'changelog and a pending release. Please commit your changes or '
+            'delete your release file.')
+        sys.exit(1)
+    tools.update_changelog_and_version()


Test patch:
Repository: HypothesisWorks/hypothesis

Issue:
Pushing to master in deploy isn't working
As far as I can tell the deploy process is just completely failing to push to master every time and succeeding at pushing the tag every time. This suggests the problem is not github flakiness like I believed.

Notes:

* I could swear I've seen this working at least once, but maybe I'm misremembering.
* The command it's running *does* work locally
* It's running as me, so it should be allowed to push to master due to my admin privileges

I'm not really sure what's going on. I'll make a speculative pull request shortly to try and fix it, but it's hard to debug and I'm mostly just guessing at this point.


Discussion:

Resolving patch:
diff --git a/scripts/hypothesistooling.py b/scripts/hypothesistooling.py
--- a/scripts/hypothesistooling.py
+++ b/scripts/hypothesistooling.py
@@ -145,16 +145,13 @@ def create_tag_and_push():
     )
     git('tag', __version__)
 
-    for command in [
-        'git push ssh-origin --tags',
-        'git push ssh-origin HEAD:master',
-    ]:
-        subprocess.check_call([
-            'ssh-agent', 'sh', '-c',
-            'chmod 0600 deploy_key && ' +
-            'ssh-add deploy_key && ' +
-            command
-        ])
+    subprocess.check_call([
+        'ssh-agent', 'sh', '-c',
+        'chmod 0600 deploy_key && ' +
+        'ssh-add deploy_key && ' +
+        'git push ssh-origin HEAD:master &&'
+        'git push ssh-origin --tags'
+    ])
 
 
 def build_jobs():


Test patch: