nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: mila-udem/fuel
Pull request #126 (2015-05-19 19:04:58)

Add ConcatenatedScheme.


Patch:
diff --git a/fuel/schemes.py b/fuel/schemes.py
index ec300ee..ba8ed07 100644
--- a/fuel/schemes.py
+++ b/fuel/schemes.py
@@ -83,6 +83,26 @@ class BatchScheme(IterationScheme):
         self.batch_size = batch_size
 
 
+class ConcatenatedScheme(IterationScheme):
+    """Build an iterator by concatenating several schemes' iterators.
+
+    Useful for iterating through different subsets of data in a specific
+    order.
+
+    Parameters
+    ----------
+    schemes : list
+        A list of :class:`IterationSchemes`, whose request iterators
+        are to be concatenated in the order given.
+
+    """
+    def __init__(self, schemes):
+        self.schemes = schemes
+
+    def get_request_iterator(self):
+        return chain(*[sch.get_request_iterator() for sch in self.schemes])
+
+
 @add_metaclass(ABCMeta)
 class IndexScheme(IterationScheme):
     """Iteration schemes that return single indices.


Test patch:
diff --git a/tests/test_schemes.py b/tests/test_schemes.py
index eff39b8..4fd4146 100644
--- a/tests/test_schemes.py
+++ b/tests/test_schemes.py
@@ -3,7 +3,7 @@ from numpy.testing import assert_raises
 
 from fuel.schemes import (ConstantScheme, SequentialExampleScheme,
                           SequentialScheme, ShuffledExampleScheme,
-                          ShuffledScheme)
+                          ShuffledScheme, ConcatenatedScheme)
 
 
 def iterator_requester(scheme):
@@ -95,3 +95,11 @@ def test_sequential_example_scheme():
     get_request_iterator = iterator_requester(SequentialExampleScheme)
     assert list(get_request_iterator(7)) == list(range(7))
     assert list(get_request_iterator(range(7)[::-1])) == list(range(7)[::-1])
+
+
+def test_concatenated_scheme():
+    sch = ConcatenatedScheme(schemes=[ConstantScheme(batch_size=10, times=5),
+                                      ConstantScheme(batch_size=20, times=3),
+                                      ConstantScheme(batch_size=30, times=1)])
+    assert (list(sch.get_request_iterator()) ==
+            ([10] * 5) + ([20] * 3) + [30])
Repository: mila-udem/fuel
Pull request #149 (2015-06-02 21:42:24)

Improve IndexableDataset with non-ndarray sources.
If the request is an instance of ~~collections.Container~~ collections.Iterable but not a numpy.ndarray, do not attempt to do fancy indexing; instead, perform the indexing in a loop. This allows one to use an IndexableDataset with list sources in conjunction with a BatchScheme.

dwf: In truth I think maybe collections.Iterable is a better fit here. Let me update.

Patch:
diff --git a/fuel/datasets/base.py b/fuel/datasets/base.py
index 52785ac..a4064d9 100644
--- a/fuel/datasets/base.py
+++ b/fuel/datasets/base.py
@@ -1,5 +1,7 @@
 import collections
 from abc import ABCMeta, abstractmethod
+
+import numpy
 from six import add_metaclass
 
 from picklable_itertools import iter_, izip
@@ -340,4 +342,13 @@ class IndexableDataset(Dataset):
     def get_data(self, state=None, request=None):
         if state is not None or request is None:
             raise ValueError
-        return tuple(indexable[request] for indexable in self.indexables)
+        if isinstance(request, collections.Iterable):
+            returned = []
+            for indexable in self.indexables:
+                if isinstance(indexable, numpy.ndarray):
+                    returned.append(indexable[request])
+                else:
+                    returned.append([indexable[r] for r in request])
+            return tuple(returned)
+        else:
+            return tuple(indexable[request] for indexable in self.indexables)


Test patch:
diff --git a/tests/test_datasets.py b/tests/test_datasets.py
index 2ec20d7..3294974 100644
--- a/tests/test_datasets.py
+++ b/tests/test_datasets.py
@@ -7,7 +7,7 @@ from six.moves import zip, range
 
 from fuel.datasets import Dataset, IterableDataset, IndexableDataset
 from fuel.streams import DataStream
-from fuel.schemes import BatchSizeScheme, ConstantScheme
+from fuel.schemes import ShuffledScheme, BatchSizeScheme, ConstantScheme
 from fuel.transformers import Mapping
 
 
@@ -117,6 +117,18 @@ class TestIndexableDataset(object):
         assert_raises(
             ValueError, IndexableDataset([1, 2, 3]).get_data, None, None)
 
+    def test_batch_iteration_scheme_with_lists(self):
+        """Batch schemes should work with more than ndarrays."""
+        data = IndexableDataset(OrderedDict([('foo', list(range(50))),
+                                             ('bar', list(range(1, 51)))]))
+        stream = DataStream(data,
+                            iteration_scheme=ShuffledScheme(data.num_examples,
+                                                            5))
+        returned = [sum(batches, []) for batches in
+                    zip(*list(stream.get_epoch_iterator()))]
+        assert set(returned[0]) == set(range(50))
+        assert set(returned[1]) == set(range(1, 51))
+
 
 def test_sources_selection():
     features = [5, 6, 7, 1]
Repository: mila-udem/fuel
Pull request #315 (2016-02-24 00:11:48)

Simpler way of checking if a directory exists
See #314 


Patch:
diff --git a/fuel/downloaders/base.py b/fuel/downloaders/base.py
index 0656c5c..bb0afeb 100644
--- a/fuel/downloaders/base.py
+++ b/fuel/downloaders/base.py
@@ -88,11 +88,9 @@ def ensure_directory_exists(directory):
         The directory to create
 
     """
-    try:
-        os.makedirs(directory)
-    except OSError as e:
-        if e.errno != os.errno.EEXIST:
-            raise
+    if os.path.isdir(directory):
+        return
+    os.makedirs(directory)
 
 
 def default_downloader(directory, urls, filenames, url_prefix=None,


Test patch:
diff --git a/tests/test_downloaders.py b/tests/test_downloaders.py
index e41a131..bae89cd 100644
--- a/tests/test_downloaders.py
+++ b/tests/test_downloaders.py
@@ -87,7 +87,7 @@ def test_ensure_directory_exists():
     with open(filepath, 'w') as f:
         f.write(' ')
 
-    assert_raises(OSError, ensure_directory_exists(filepath))
+    assert_raises(OSError, ensure_directory_exists, filepath)
 
     shutil.rmtree(dirpath, ignore_errors=True)
Repository: mill1000/midea-msmart
Pull request #163 (2024-08-15 17:26:04)

Catch request exceptions from httpx
Catch additional exceptions from httpx during cloud requests.


Patch:
diff --git a/msmart/cloud.py b/msmart/cloud.py
index ba1b97a..1cefdc0 100644
--- a/msmart/cloud.py
+++ b/msmart/cloud.py
@@ -111,6 +111,8 @@ class Cloud:
                         retries -= 1
                     else:
                         raise CloudError("No response from server.") from e
+                except httpx.RequestError as e:
+                    raise CloudError("Request failed.") from e
 
     async def _api_request(self, endpoint: str, body: Dict[str, Any]) -> Optional[dict]:
         """Make a request to the Midea cloud return the results."""


Test patch:
diff --git a/msmart/tests/test_cloud.py b/msmart/tests/test_cloud.py
index 2803c6b..2ab73c0 100644
--- a/msmart/tests/test_cloud.py
+++ b/msmart/tests/test_cloud.py
@@ -50,6 +50,17 @@ class TestCloud(unittest.IsolatedAsyncioTestCase):
         with self.assertRaises(CloudError):
             await client.get_token(BAD_UDPID)
 
+    async def test_connect_exception(self) -> None:
+        """Test that an exception is thrown when the cloud connection fails."""
+
+        client = Cloud(OPEN_MIDEA_APP_ACCOUNT, OPEN_MIDEA_APP_PASSWORD)
+
+        # Override URL to an invalid domain
+        client._base_url = "https://fake_server.invalid."
+
+        with self.assertRaises(CloudError):
+            await client.login()
+
 
 if __name__ == "__main__":
     unittest.main()
Repository: mill1000/midea-msmart
Pull request #184 (2025-01-05 01:45:07)

Revert "Scale binary energy values by an additional factor of 10"
Reverts mill1000/midea-msmart#180

Another user reported (https://github.com/mill1000/midea-ac-py/issues/276) that scaling by another factor of 10 is not correct for all devices.

Instead we'll keep the original scaling, and have midea-ac-py perform the scaling 


Patch:
diff --git a/msmart/device/AC/command.py b/msmart/device/AC/command.py
index 85ae3b8..6af37eb 100644
--- a/msmart/device/AC/command.py
+++ b/msmart/device/AC/command.py
@@ -1024,11 +1024,10 @@ class EnergyUsageResponse(Response):
                    100 * decode_bcd(d[1]) +
                    1 * decode_bcd(d[2]) +
                    0.01 * decode_bcd(d[3]))
-            # Scale binary energy by an extra power of 10. See mill1000/midea-msmart#174
             binary = ((d[0] << 24) +
                       (d[1] << 16) +
                       (d[2] << 8) +
-                      d[3]) / 100
+                      d[3]) / 10
             return bcd, binary
 
         def parse_power(d: bytes) -> tuple[float, float]:


Test patch:
diff --git a/msmart/device/AC/test_command.py b/msmart/device/AC/test_command.py
index fdede07..28eacb1 100644
--- a/msmart/device/AC/test_command.py
+++ b/msmart/device/AC/test_command.py
@@ -844,7 +844,7 @@ class TestGroupDataResponse(_TestResponseBase):
         """Test we decode binary energy usage responses correctly."""
         TEST_RESPONSES = {
             # https://github.com/mill1000/midea-ac-py/issues/204#issuecomment-2314705021
-            (15.04, .06, 279.5): bytes.fromhex("aa22ac00000000000803c1210144000005e00000000000000006000aeb000000487a5e"),
+            (150.4, .6, 279.5): bytes.fromhex("aa22ac00000000000803c1210144000005e00000000000000006000aeb000000487a5e"),
 
             # https://github.com/mill1000/midea-msmart/pull/116#issuecomment-2218753545
             (None, None, None): bytes.fromhex("aa20ac00000000000303c1210144000000000000000000000000000000000843bc"),
diff --git a/msmart/device/AC/test_device.py b/msmart/device/AC/test_device.py
index 80a9abb..dc82018 100644
--- a/msmart/device/AC/test_device.py
+++ b/msmart/device/AC/test_device.py
@@ -297,7 +297,7 @@ class TestUpdateStateFromResponse(unittest.TestCase):
         """Test parsing of EnergyUsageResponses into device state with binary format."""
         TEST_RESPONSES = {
             # https://github.com/mill1000/midea-ac-py/issues/204#issuecomment-2314705021
-            (15.04, .06, 279.5): bytes.fromhex("aa22ac00000000000803c1210144000005e00000000000000006000aeb000000487a5e"),
+            (150.4, .6, 279.5): bytes.fromhex("aa22ac00000000000803c1210144000005e00000000000000006000aeb000000487a5e"),
 
             # https://github.com/mill1000/midea-msmart/pull/116#issuecomment-2218753545
             (None, None, None): bytes.fromhex("aa20ac00000000000303c1210144000000000000000000000000000000000843bc"),
Repository: CodeForPhilly/chime
Pull request #365 (2020-03-30 16:14:44)

Compute census forecasts as far forward as admissions


Patch:
diff --git a/src/penn_chime/charts.py b/src/penn_chime/charts.py
index 03cdb48..98e4a0c 100644
--- a/src/penn_chime/charts.py
+++ b/src/penn_chime/charts.py
@@ -45,7 +45,7 @@ def build_admits_chart(
         .transform_filter(alt.datum.day == 0)
         .mark_rule(color="black", opacity=0.35, size=2)
     )
-    return alt.layer(points, bar, data=admits_df)
+    return alt.layer(points, bar, data=ceil_df)
 
 
 
diff --git a/src/penn_chime/models.py b/src/penn_chime/models.py
index 457f4df..f50654c 100644
--- a/src/penn_chime/models.py
+++ b/src/penn_chime/models.py
@@ -312,7 +312,7 @@ def build_census_df(
         'date': admits_df.date,
         **{
             key: (
-                admits_df[key].cumsum().iloc[:-los]
+                admits_df[key].cumsum()
                 - admits_df[key].cumsum().shift(los).fillna(0)
             ).apply(np.ceil)
             for key, los in lengths_of_stay.items()


Test patch:
diff --git a/tests/test_app.py b/tests/test_app.py
index eaf683b..82a74b9 100644
--- a/tests/test_app.py
+++ b/tests/test_app.py
@@ -245,7 +245,7 @@ def test_admits_chart():
     admits_df = pd.read_csv("tests/by_doubling_time/2020-03-28_projected_admits.csv")
     chart = build_admits_chart(alt=alt, admits_df=admits_df)
     assert isinstance(chart, (alt.Chart, alt.LayerChart))
-    assert round(chart.data.iloc[40].icu, 0) == 38
+    assert round(chart.data.iloc[40].icu, 0) == 39
 
     # test fx call with no params
     with pytest.raises(TypeError):
Repository: Delgan/loguru
Pull request #34 (2019-01-16 11:40:05)

Fixes "MMMM" and "MMM".
There is no need to `-1` here.

> ### calendar.month_name
> An array that represents the months of the year in the current locale. This follows normal convention of January being month number 1, so it has a length of 13 and month_name[0] is the empty string.

> ### calendar.month_abbr
> An array that represents the abbreviated months of the year in the current locale. This follows normal convention of January being month number 1, so it has a length of 13 and month_abbr[0] is the empty string.


Patch:
diff --git a/CHANGELOG.rst b/CHANGELOG.rst
index 64329af..3aa9008 100644
--- a/CHANGELOG.rst
+++ b/CHANGELOG.rst
@@ -1,6 +1,7 @@
 Unreleased
 ==========
 
+- Fix incorrect time formatting of locale month using ``MMM`` and ``MMMM`` tokens (`#34 <https://github.com/Delgan/loguru/pull/34>`_, thanks `@nasyxx <https://github.com/nasyxx>`_)
 - Fix race condition permitting to write on a stopped handler
 
 
diff --git a/README.rst b/README.rst
index 9da21fc..34e8e13 100644
--- a/README.rst
+++ b/README.rst
@@ -323,7 +323,7 @@ Using the logger in your scripts is easy, and you can |configure|_ it at start.
     # For scripts
     config = {
         "handlers": [
-            {"sink": sys.stdout, format="{time} - {message}"},
+            {"sink": sys.stdout, "format": "{time} - {message}"},
             {"sink": "file.log", "serialize": True},
         ],
         "extra": {"user": "someone"}
diff --git a/loguru/_datetime.py b/loguru/_datetime.py
index 4010a9e..a8e648a 100644
--- a/loguru/_datetime.py
+++ b/loguru/_datetime.py
@@ -29,8 +29,8 @@ class datetime(datetime_):
             "YYYY": "%04d" % year,
             "YY": "%02d" % (year % 100),
             "Q": "%d" % ((month - 1) // 3 + 1),
-            "MMMM": month_name[month - 1],
-            "MMM": month_abbr[month - 1],
+            "MMMM": month_name[month],
+            "MMM": month_abbr[month],
             "MM": "%02d" % month,
             "M": "%d" % month,
             "DDDD": "%03d" % yearday,


Test patch:
diff --git a/tests/test_datetime.py b/tests/test_datetime.py
index e882da7..97304cf 100644
--- a/tests/test_datetime.py
+++ b/tests/test_datetime.py
@@ -1,4 +1,5 @@
 import pytest
+import datetime
 from loguru import logger
 import sys
 
@@ -38,6 +39,14 @@ def test_formatting(writer, monkeypatch_date, time_format, date, expected):
     assert result == expected + "\n"
 
 
+def test_locale_formatting(writer, monkeypatch_date):
+    date = (2011, 1, 1, 22, 22, 22, 0)
+    monkeypatch_date(*date)
+    logger.add(writer, format="{time:MMMM MMM dddd ddd}")
+    logger.debug("Test")
+    assert writer.read() == datetime.datetime(*date).strftime("%B %b %A %a\n")
+
+
 def test_stdout_formatting(monkeypatch_date, capsys):
     monkeypatch_date(2015, 12, 25, 19, 13, 18, 0, "A", 5400)
     logger.add(sys.stdout, format="{time:YYYY [MM] DD HHmmss Z} {message}")
Repository: Quramy/prisma-fabbrica
Pull request #59 (2022-11-29 05:14:31)

fix: Complex unique fields auto scalar generate
Related #58 


Patch:
diff --git a/packages/prisma-fabbrica/src/templates/index.ts b/packages/prisma-fabbrica/src/templates/index.ts
index 449909b..9c25358 100644
--- a/packages/prisma-fabbrica/src/templates/index.ts
+++ b/packages/prisma-fabbrica/src/templates/index.ts
@@ -249,7 +249,10 @@ export const autoGenerateModelScalarsOrEnumsFieldArgs = (
           model.fields.find(byName(field))!.isId || model.primaryKey?.fields.includes(field.name)
             ? ast.true()
             : ast.false(),
-        IS_UNIQUE: model.fields.find(byName(field))!.isUnique ? ast.true() : ast.false(),
+        IS_UNIQUE:
+          model.fields.find(byName(field))!.isUnique || model.uniqueFields.flat().includes(field.name)
+            ? ast.true()
+            : ast.false(),
       })
     : ast.stringLiteral(extractFirstEnumValue(enums, field));
 


Test patch:
diff --git a/packages/prisma-fabbrica/src/templates/autoGenerateModelScalarsOrEnumsFieldArgs.test.ts b/packages/prisma-fabbrica/src/templates/autoGenerateModelScalarsOrEnumsFieldArgs.test.ts
index 25f1e11..9ea331e 100644
--- a/packages/prisma-fabbrica/src/templates/autoGenerateModelScalarsOrEnumsFieldArgs.test.ts
+++ b/packages/prisma-fabbrica/src/templates/autoGenerateModelScalarsOrEnumsFieldArgs.test.ts
@@ -41,6 +41,20 @@ describe(autoGenerateModelScalarsOrEnumsFieldArgs, () => {
         scalarFieldValueGenerator.String({ modelName: "TestModel", fieldName: "uniqueField", isId: false, isUnique: true, seq })
       `,
     },
+    {
+      datamodel: `
+        model TestModel {
+          id Int @id
+          uniqueField1 String
+          uniqueField2 String
+          @@unique([uniqueField1, uniqueField2])
+        }
+      `,
+      targetField: "uniqueField1",
+      expected: `
+        scalarFieldValueGenerator.String({ modelName: "TestModel", fieldName: "uniqueField1", isId: false, isUnique: true, seq })
+      `,
+    },
     {
       datamodel: `
         model TestModel {
Repository: QCoDeS/Qcodes
Pull request #5447 (2023-10-19 14:12:49)

Port changes from 0.41.x to main


Patch:
diff --git a/docs/changes/0.41.1.rst b/docs/changes/0.41.1.rst
new file mode 100644
index 000000000..cdabb59e2
--- /dev/null
+++ b/docs/changes/0.41.1.rst
@@ -0,0 +1,8 @@
+QCoDeS 0.41.1 (2023-10-19)
+==========================
+
+Improved:
+---------
+
+- Corrected a bug where non integer step sizes were incorrectly rejected
+  from parameters without integer validators. (:pr:`5446`)
diff --git a/docs/changes/index.rst b/docs/changes/index.rst
index 262f1ce98..f2401ec3c 100644
--- a/docs/changes/index.rst
+++ b/docs/changes/index.rst
@@ -3,6 +3,7 @@ Changelogs
 
 .. toctree::
    Unreleased <unreleased>
+   0.41.1 <0.41.1>
    0.41.0 <0.41.0>
    0.40.0 <0.40.0>
    0.39.1 <0.39.1>
diff --git a/src/qcodes/parameters/parameter_base.py b/src/qcodes/parameters/parameter_base.py
index 06a99fe9b..7a8ddbcfd 100644
--- a/src/qcodes/parameters/parameter_base.py
+++ b/src/qcodes/parameters/parameter_base.py
@@ -838,7 +838,7 @@ class ParameterBase(MetadatableWithName):
             self._step = None
         elif step <= 0:
             raise ValueError("step must be positive")
-        elif not all(isinstance(vals, Ints) for vals in self._vals) and not isinstance(
+        elif any(isinstance(vals, Ints) for vals in self._vals) and not isinstance(
             step, int
         ):
             raise TypeError("step must be a positive int for an Ints parameter")


Test patch:
diff --git a/src/qcodes/tests/parameter/test_validators.py b/src/qcodes/tests/parameter/test_validators.py
index e3e89da46..faee51975 100644
--- a/src/qcodes/tests/parameter/test_validators.py
+++ b/src/qcodes/tests/parameter/test_validators.py
@@ -3,7 +3,7 @@ import pytest
 from hypothesis import given
 
 from qcodes.parameters import Parameter
-from qcodes.validators import Ints
+from qcodes.validators import Ints, Numbers
 
 
 def test_add_ints_validator_to_parameter():
@@ -187,3 +187,19 @@ def test_replace_vals():
     p.remove_validator()
     p.vals = None
     assert len(p.validators) == 0
+
+
+def test_validators_step_int() -> None:
+    # this parameter should allow step to be set as a float since the parameter is in it self a float
+    param = Parameter("a", get_cmd=False, set_cmd=False, vals=Numbers(0, 10))
+
+    param.step = 0.1
+    param.step = 1.0
+
+    param.add_validator(Ints(0, 10))
+
+    # but once we add an integer validator we no longer can set a step size as a float
+    with pytest.raises(
+        TypeError, match="step must be a positive int for an Ints parameter"
+    ):
+        param.step = 0.1
Repository: octokit/webhooks.js
Pull request #458 (2021-02-11 15:12:28)

feat(typescript): compile-time missing options error
Like at run time https://github.com/octokit/webhooks.js/blob/80ee43fc95d8853ba1439d55a54f1b9cee7813e1/test/integration/server-test.ts#L26-L27


Patch:
diff --git a/src/event-handler/index.ts b/src/event-handler/index.ts
index cc878d4..f2b1306 100644
--- a/src/event-handler/index.ts
+++ b/src/event-handler/index.ts
@@ -30,11 +30,11 @@ interface EventHandler<TTransformed> {
 }
 
 export function createEventHandler<TTransformed>(
-  options: Options<TTransformed>
+  options?: Options<TTransformed>
 ): EventHandler<TTransformed> {
   const state: State = {
     hooks: {},
-    log: createLogger(options.log),
+    log: createLogger(options && options.log),
   };
 
   if (options && options.transform) {
diff --git a/src/index.ts b/src/index.ts
index 3848c88..12ac19d 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -40,7 +40,7 @@ class Webhooks<TTransformed> {
     options: EmitterWebhookEvent & { signature: string }
   ) => Promise<void>;
 
-  constructor(options?: Options<TTransformed>) {
+  constructor(options: Options<TTransformed>) {
     if (!options || !options.secret) {
       throw new Error("[@octokit/webhooks] options.secret required");
     }


Test patch:
diff --git a/test/integration/server-test.ts b/test/integration/server-test.ts
index 2562bfc..c33f6a2 100644
--- a/test/integration/server-test.ts
+++ b/test/integration/server-test.ts
@@ -23,6 +23,7 @@ describe("server-test", () => {
 
   test("initialised without options", (t) => {
     try {
+      // @ts-expect-error
       new Webhooks();
       t.fail("should throw error");
     } catch (error) {
diff --git a/test/typescript-validate.ts b/test/typescript-validate.ts
index cd0fc12..e022144 100644
--- a/test/typescript-validate.ts
+++ b/test/typescript-validate.ts
@@ -59,7 +59,8 @@ on("code_scanning_alert.fixed", (event) => {
 });
 
 export default async function () {
-  // Check empty constructor
+  // @ts-expect-error TS2554:
+  //  Expected 1 arguments, but got 0.
   new Webhooks();
 
   // Check that all options are optional except for secret