nebius/SWE-bench-extra huggingface dataset:
Repository: python-adaptive/adaptive

Issue:
AverageLearner doesn't work with 0 mean
```python
from adaptive import AverageLearner

l = AverageLearner(None, rtol=0.01)
l.tell(0, -1)
l.tell(1, 1)
l.ask(1)
```
raises
```
---------------------------------------------------------------------------
ZeroDivisionError                         Traceback (most recent call last)
<ipython-input-9-03494c6327ae> in <module>
      4 l.tell(0, -1)
      5 l.tell(1, 1)
----> 6 l.ask(1)

~/Work/adaptive/adaptive/learner/average_learner.py in ask(self, n, tell_pending)
     67             )[:n]
     68 
---> 69         loss_improvements = [self._loss_improvement(n) / n] * n
     70         if tell_pending:
     71             for p in points:

~/Work/adaptive/adaptive/learner/average_learner.py in _loss_improvement(self, n)
    119 
    120     def _loss_improvement(self, n):
--> 121         loss = self.loss()
    122         if np.isfinite(loss):
    123             return loss - self.loss(n=self.npoints + n)

~/Work/adaptive/adaptive/utils.py in wrapper(*args, **kwargs)
     35         if not hasattr(self, "_cache"):
     36             self._cache = {}
---> 37         self._cache[f.__name__] = f(*args, **kwargs)
     38         return self._cache[f.__name__]
     39 

~/Work/adaptive/adaptive/learner/average_learner.py in loss(self, real, n)
    115         standard_error = self.std / sqrt(n)
    116         return max(
--> 117             standard_error / self.atol, standard_error / abs(self.mean) / self.rtol
    118         )
    119 

ZeroDivisionError: float division by zero
```

@akhmerov, how do you think we should solve this?

Comments:

Patch:
diff --git a/adaptive/learner/average_learner.py b/adaptive/learner/average_learner.py
index ba7deb1..b571c19 100644
--- a/adaptive/learner/average_learner.py
+++ b/adaptive/learner/average_learner.py
@@ -118,9 +118,11 @@ class AverageLearner(BaseLearner):
         if n < self.min_npoints:
             return np.inf
         standard_error = self.std / sqrt(n)
-        return max(
-            standard_error / self.atol, standard_error / abs(self.mean) / self.rtol
-        )
+        aloss = standard_error / self.atol
+        rloss = standard_error / self.rtol
+        if self.mean != 0:
+            rloss /= abs(self.mean)
+        return max(aloss, rloss)
 
     def _loss_improvement(self, n):
         loss = self.loss()


Test patch:
diff --git a/adaptive/tests/test_average_learner.py b/adaptive/tests/test_average_learner.py
index 42d4726..f35794a 100644
--- a/adaptive/tests/test_average_learner.py
+++ b/adaptive/tests/test_average_learner.py
@@ -59,3 +59,11 @@ def test_min_npoints():
         )
         simple(learner, lambda l: l.loss() < 1)
         assert learner.npoints >= max(2, min_npoints)
+
+
+def test_zero_mean():
+    # see https://github.com/python-adaptive/adaptive/issues/275
+    learner = AverageLearner(None, rtol=0.01)
+    learner.tell(0, -1)
+    learner.tell(1, 1)
+    learner.loss()
Repository: python-babel/flask-babel

Issue:
`locked_cached_property` is deprecated as of Flask>=2.3.0
issue: https://github.com/pallets/flask/issues/4993
pr: https://github.com/pallets/flask/pull/4998

This is the only part where this is used. I'm wondering though, whether locking is even needed in this case or if a `werkzeug.utils.cached_property` is enough?

https://github.com/python-babel/flask-babel/blob/69d3340cd0ff52f3e23a47518285a7e6d8f8c640/flask_babel/__init__.py#L224-L228

happy to send a PR swapping the decorator. But just wanted to be sure whether the lock is actually needed.
(tests pass with `werkzeug.utils.cached_property`)


Comments:

Patch:
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index d0fac7a..c870612 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -2,7 +2,7 @@ on:
   workflow_dispatch:
   release:
     types:
-      - created
+      - published
 
 name: Release
 
diff --git a/flask_babel/__init__.py b/flask_babel/__init__.py
index a76bf7c..9f94d22 100644
--- a/flask_babel/__init__.py
+++ b/flask_babel/__init__.py
@@ -16,10 +16,10 @@ from typing import List, Callable, Optional, Union
 
 from babel.support import Translations, NullTranslations
 from flask import current_app, g
-from flask.helpers import locked_cached_property
 from babel import dates, numbers, support, Locale
 from pytz import timezone, UTC
 from werkzeug.datastructures import ImmutableDict
+from werkzeug.utils import cached_property
 
 from flask_babel.speaklater import LazyString
 
@@ -221,7 +221,7 @@ class Babel:
         """
         return get_babel().default_domain
 
-    @locked_cached_property
+    @cached_property
     def domain_instance(self):
         """The message domain for the translations.
         """


Test patch:
diff --git a/tests/test_app_factory.py b/tests/test_app_factory.py
new file mode 100644
index 0000000..0dbef3c
--- /dev/null
+++ b/tests/test_app_factory.py
@@ -0,0 +1,24 @@
+import flask
+import flask_babel as babel
+
+
+def test_app_factory():
+    b = babel.Babel()
+
+    def locale_selector():
+        return 'de_DE'
+
+    def create_app():
+        app_ = flask.Flask(__name__)
+        b.init_app(
+            app_,
+            default_locale='en_US',
+            locale_selector=locale_selector
+        )
+        return app_
+
+    app = create_app()
+    with app.test_request_context():
+        assert str(babel.get_locale()) == 'de_DE'
+        assert babel.gettext(u'Hello %(name)s!', name='Peter') == \
+               'Hallo Peter!'