nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: PMEAL/OpenPNM
Pull request #656 (2016-11-08 18:49:21)

Fixed a bug in (rate) function
There was a bug in the 'single' mode of the 'rate' function. Apparently, at some point, 'len' has been replaced by 'size'. I changed it to 'shape'.


Patch:
diff --git a/OpenPNM/Algorithms/__GenericLinearTransport__.py b/OpenPNM/Algorithms/__GenericLinearTransport__.py
index 90b1831ef..815d4e9c5 100644
--- a/OpenPNM/Algorithms/__GenericLinearTransport__.py
+++ b/OpenPNM/Algorithms/__GenericLinearTransport__.py
@@ -861,7 +861,7 @@ class GenericLinearTransport(GenericAlgorithm):
         elif mode == 'single':
             t = network.find_neighbor_throats(pores, flatten=False,
                                               mode='not_intersection')
-            throat_group_num = sp.size(t)
+            throat_group_num = sp.shape(t)[0]
         for i in sp.r_[0: throat_group_num]:
             if mode == 'group':
                 throats = t


Test patch:
diff --git a/test/integration/script_test.py b/test/integration/script_test.py
index ac9e3e7d7..533b86dd6 100644
--- a/test/integration/script_test.py
+++ b/test/integration/script_test.py
@@ -73,6 +73,11 @@ def test_linear_solvers():
         round(sp.absolute(alg_3.rate(BC2_pores))[0], 14)
     assert round(sp.absolute(sp.sum(alg_4.rate(BC2_pores, mode='single'))), 14) ==\
         round(sp.absolute(alg_4.rate(BC2_pores))[0], 14)
+    BC5_pores = [37,57]
+    assert round(sp.absolute(sp.sum(alg_3.rate(BC5_pores, mode='single'))), 14) ==\
+        round(sp.absolute(alg_3.rate(BC5_pores))[0], 14)
+    assert round(sp.absolute(sp.sum(alg_4.rate(BC5_pores, mode='single'))), 14) ==\
+        round(sp.absolute(alg_4.rate(BC5_pores))[0], 14)
 
 
 def test_add_boundary():
Repository: PMEAL/OpenPNM
Pull request #670 (2017-01-22 00:49:38)

Fix for issue #664
Added the ability to handle 'pore.prop' as well as just 'pore' in _parse_element


Patch:
diff --git a/OpenPNM/Base/__Core__.py b/OpenPNM/Base/__Core__.py
index c326c6443..2bd8cd74b 100644
--- a/OpenPNM/Base/__Core__.py
+++ b/OpenPNM/Base/__Core__.py
@@ -1377,7 +1377,11 @@ class Core(dict):
         # Convert element to a list for subsequent processing
         if type(element) is str:
             element = [element]
+        # Convert 'pore.prop' and 'throat.prop' into just 'pore' and 'throat'
+        element = [item.split('.')[0] for item in element]
+        # Make sure all are lowercase
         element = [item.lower() for item in element]
+        # Deal with an plurals
         element = [item.rsplit('s', maxsplit=1)[0] for item in element]
         for item in element:
             if item not in ['pore', 'throat']:


Test patch:
diff --git a/test/unit/Base/CoreTest.py b/test/unit/Base/CoreTest.py
index 6ef59de4d..f25b6281b 100644
--- a/test/unit/Base/CoreTest.py
+++ b/test/unit/Base/CoreTest.py
@@ -436,7 +436,6 @@ class CoreTest:
     def test_object_name_array_conflict(self):
         with pytest.raises(Exception):
             self.geo.name = 'coords'
-
         Np = self.geo.Np
         Nt = self.geo.Nt
         assert self.geo.Np == Np
@@ -764,6 +763,10 @@ class CoreTest:
         a = self.net._parse_element(element=['pore'], single=True)
         assert a == 'pore'
 
+    def test_parse_element_props(self):
+        a = self.net._parse_element(element=['pore.diameter'], single=True)
+        assert a == 'pore'
+
     def test_parse_labels_none(self):
         with pytest.raises(Exception):
             self.net._parse_labels(labels=None, element='pore')
Repository: PMEAL/OpenPNM
Pull request #845 (2018-04-04 14:22:21)

Enhancing clear methods
This PR is to flesh out the behavior of ``clear`` on all the objects


Patch:
diff --git a/openpnm/core/Project.py b/openpnm/core/Project.py
index eb635886a..3c296649f 100644
--- a/openpnm/core/Project.py
+++ b/openpnm/core/Project.py
@@ -29,6 +29,34 @@ class Project(list):
     def append(self, obj):
         self.extend(obj)
 
+    def clear(self, objtype=[]):
+        r"""
+        Clears objects from the project entirely or selectively, depdening on
+        the received arguments.
+
+        Parameters
+        ----------
+        objtype : list of strings
+            A list containing the object type(s) to be removed.  If no types
+            are specified, then all objects are removed.  To clear only objects
+            of a specific type, use *'network'*, *'geometry'*, *'phase'*,
+            *'physics'*, or *'algorithm'*.  It's also possible to use
+            abbreviations, like *'geom'*.
+
+        """
+        if len(objtype) == 0:
+            super().clear()
+        else:
+            names = [obj.name for obj in self]
+            for name in names:
+                try:
+                    obj = self[name]
+                    for t in objtype:
+                        if obj._isa(t):
+                            self.purge_object(obj)
+                except KeyError:
+                    pass
+
     @property
     def workspace(self):
         return ws


Test patch:
diff --git a/tests/unit/core/ProjectTest.py b/tests/unit/core/ProjectTest.py
index 89234a84f..7da97f9c8 100644
--- a/tests/unit/core/ProjectTest.py
+++ b/tests/unit/core/ProjectTest.py
@@ -191,6 +191,14 @@ class ProjectTest:
         assert phys2 is not phys3
         assert phys3 is not phys4
 
+    def test_clear(self):
+        proj = self.ws.copy_project(self.net.project)
+        assert len(proj) == 9
+        proj.clear(objtype=['phase'])
+        assert len(proj) == 3
+        proj.clear()
+        assert len(proj) == 0
+
 
 if __name__ == '__main__':
Repository: phoenixframework/phoenix
Pull request #3834 (2020-05-11 12:50:46)

Update Phoenix.Logger docs

chrismccord: This doesn't appear to be something we emit from telemetry. What are you seeing `result` come from? Thanks!

Patch:
diff --git a/lib/phoenix/logger.ex b/lib/phoenix/logger.ex
index 2d859d805..3460a55b1 100644
--- a/lib/phoenix/logger.ex
+++ b/lib/phoenix/logger.ex
@@ -69,7 +69,7 @@ defmodule Phoenix.Logger do
 
     * `[:phoenix, :channel_joined]` - dispatched at the end of a channel join
       * Measurement: `%{duration: native_time}`
-      * Metadata: `%{params: term, socket: Phoenix.Socket.t}`
+      * Metadata: `%{result: :ok | :error, params: term, socket: Phoenix.Socket.t}`
       * Disable logging: This event cannot be disabled
 
     * `[:phoenix, :channel_handled_in]` - dispatched at the end of a channel handle in


Test patch:
diff --git a/guides/testing/testing_controllers.md b/guides/testing/testing_controllers.md
index 965093f87..72a7b6a9d 100644
--- a/guides/testing/testing_controllers.md
+++ b/guides/testing/testing_controllers.md
@@ -47,11 +47,11 @@ def index(conn, _params) do
 end
 ```
 
-It gets all posts and renders the "index.html" template. The template can be found in "lib/hello_web/templates/page/index.html.eex".
+It gets all posts and renders the "index.html" template. The template can be found in `lib/hello_web/templates/page/index.html.eex`.
 
 The test looks like this:
 
-```elixi
+```elixir
 describe "index" do
   test "lists all posts", %{conn: conn} do
     conn = get(conn, Routes.post_path(conn, :index))
Repository: phoenixframework/phoenix
Pull request #3840 (2020-05-12 10:13:14)

Do not digest Brotli compressed files
`mix phx.digest` should not digest Brotli compressed files, which may come from third-party asset bundlers.

See #3836.

josevalim: Looks great, we just need a test. :)
jayjun: My bad, tests pushed!

Patch:
diff --git a/lib/phoenix/digester.ex b/lib/phoenix/digester.ex
index 2c90453aa..26c898e7d 100644
--- a/lib/phoenix/digester.ex
+++ b/lib/phoenix/digester.ex
@@ -119,7 +119,7 @@ defmodule Phoenix.Digester do
 
   defp compiled_file?(file_path) do
     Regex.match?(@digested_file_regex, Path.basename(file_path)) ||
-      Path.extname(file_path) == ".gz" ||
+      Path.extname(file_path) in ~w(.gz .br) ||
       Path.basename(file_path) == "cache_manifest.json"
   end
 


Test patch:
diff --git a/test/fixtures/digest/priv/static/precompressed.js.br b/test/fixtures/digest/priv/static/precompressed.js.br
new file mode 100644
index 000000000..5a090955f
--- /dev/null
+++ b/test/fixtures/digest/priv/static/precompressed.js.br
@@ -0,0 +1,1 @@
+Brotli
diff --git a/test/fixtures/digest/priv/static/precompressed.js.gz b/test/fixtures/digest/priv/static/precompressed.js.gz
new file mode 100644
index 000000000..d234d64b1
--- /dev/null
+++ b/test/fixtures/digest/priv/static/precompressed.js.gz
@@ -0,0 +1,1 @@
+gzip
diff --git a/test/phoenix/digester_test.exs b/test/phoenix/digester_test.exs
index 03b25c2ab..37df1b8d6 100644
--- a/test/phoenix/digester_test.exs
+++ b/test/phoenix/digester_test.exs
@@ -84,6 +84,19 @@ defmodule Phoenix.DigesterTest do
                "93pY5dBa8nHHi0Zfj75O/vXCBXb+UvEVCyU7Yd3pzOJ7o1wkYBWbvs3pVXhBChEmo8MDANT11vsggo2+bnYqoQ=="
     end
 
+    test "excludes compiled files" do
+      input_path = "test/fixtures/digest/priv/static/"
+      assert :ok = Phoenix.Digester.compile(input_path, @output_path)
+      output_files = assets_files(@output_path)
+
+      json = Path.join(@output_path, "cache_manifest.json") |> json_read!()
+      refute json["latest"]["precompressed.js.gz"]
+      refute json["latest"]["precompressed.js.br"]
+
+      assert :ok = Phoenix.Digester.compile(@output_path, @output_path)
+      assert output_files == assets_files(@output_path)
+    end
+
     test "old versions maintain their mtime" do
       source_path = "test/fixtures/digest/priv/static/"
       input_path = "tmp/digest/static"