anon-iclr-submission/benchname-bug-localization huggingface dataset:
Repository: mampfes/hacs_waste_collection_schedule
Issue: Setup failed: blocking call on Polish source

I've installed via HACS

```
RuntimeError: Blocking calls must be done in the executor or a separate thread; Use `await hass.async_add_executor_job()`; at custom_components/waste_collection_schedule/waste_collection_schedule/source/warszawa19115_pl.py, line 61: geolocation_request = geolocation_session.get(OC_URL)
```

```
Detected blocking call to putrequest inside the event loop. This is causing stability issues. Please report issue to the custom component author for waste_collection_schedule doing blocking calls at custom_components/waste_collection_schedule/waste_collection_schedule/source/warszawa19115_pl.py, line 61: geolocation_request = geolocation_session.get(OC_URL)
```

I'm using the warszawa19115_pl source.

Changed files:
custom_components/waste_collection_schedule/waste_collection_schedule/source/warszawa19115_pl.py

diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/warszawa19115_pl.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/warszawa19115_pl.py
index 7d20240..4bc6e96 100644
--- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/warszawa19115_pl.py
+++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/warszawa19115_pl.py
@@ -50,11 +50,8 @@ class Source:
             raise SourceConfigurationError(
                 "Either street_address or geolocation_id must have a value"
             )
-
-        if geolocation_id is None:
-            self._geolocation_id = self.get_geolocation_id(street_address)
-        else:
-            self._geolocation_id = geolocation_id
+        self._street_address = street_address
+        self._geolocation_id = geolocation_id
 
     def get_geolocation_id(self, street_address) -> str:
         geolocation_session = requests.Session()
@@ -95,6 +92,10 @@ class Source:
         return geolocation_id
 
     def fetch(self):
+        # When only an address is specified, get geolocation on first fetch
+        if self._geolocation_id is None:
+            self._geolocation_id = self.get_geolocation_id(self._street_address)
+        
         # Calendar lookup cares about a cookie, so a Session must be used
         calendar_session = requests.Session()
         calendar_request = calendar_session.get(OC_URL)
Repository: devitocodes/devito
Issue: Check the existence of jit_dir when loading state from pickle

In the `save` method of the `Compiler` class, the `sofile` state is written into the compiler's `jit_dir`:
```python
sofile = self.get_jit_dir().joinpath(soname).with_suffix(self.so_ext)
if sofile.is_file():
    ...
else:
    with open(str(sofile), 'wb') as f:
        ...
```
However, since `jit_dir` normally resides into the `tmp` folder, it can not be present anymore when reloading the state from pickle. This is also true when transferring pickled data from one machine to another.
Checking for its existence prior to open the file would be more robust:
```python
sofile = self.get_jit_dir().joinpath(soname).with_suffix(self.so_ext)
if sofile.is_file():
    ...
else:
    if not path.exists(self.get_jit_dir()):
        makedirs(self.get_jit_dir(), exist_ok=True)
    with open(str(sofile), 'wb') as f:
        ...
```

Changed files:
devito/arch/compiler.py

diff --git a/devito/arch/compiler.py b/devito/arch/compiler.py
index f4775dcac..4714744c1 100644
--- a/devito/arch/compiler.py
+++ b/devito/arch/compiler.py
@@ -1,6 +1,6 @@
 from functools import partial
 from hashlib import sha1
-from os import environ, path
+from os import environ, path, makedirs
 from packaging.version import Version
 from subprocess import DEVNULL, PIPE, CalledProcessError, check_output, check_call, run
 import platform
@@ -235,6 +235,7 @@ class Compiler(GCCToolchain):
             debug("%s: `%s` was not saved in `%s` as it already exists"
                   % (self, sofile.name, self.get_jit_dir()))
         else:
+            makedirs(self.get_jit_dir(), exist_ok=True)
             with open(str(sofile), 'wb') as f:
                 f.write(binary)
             debug("%s: `%s` successfully saved in `%s`"
Repository: devitocodes/devito
Issue: buffering of Function accessed with stencil is broken

The issue is that the buffer halo isn't initialized, so instead of zeros, garbage is read.

```
    nt = 5
    grid = Grid(shape=(4, 4))

    u = TimeFunction(name='u', grid=grid, space_order=4, save=nt)
    u1 = TimeFunction(name='u', grid=grid, space_order=4, save=nt)

    eqn = Eq(u.forward, u.dx + 1)

    op0 = Operator(eqn, opt='noop')
    op1 = Operator(eqn, opt='buffering')

    op0.apply(time_M=nt-2)
    op1.apply(time_M=nt-2, u=u1)

    assert np.all(u.data == u1.data)
```

Changed files:
devito/passes/clusters/buffering.py, tests/test_buffering.py

diff --git a/devito/passes/clusters/buffering.py b/devito/passes/clusters/buffering.py
index 64fedd31c..a0f8efc12 100644
--- a/devito/passes/clusters/buffering.py
+++ b/devito/passes/clusters/buffering.py
@@ -463,9 +463,12 @@ class Buffer(object):
         intervals = []
         sub_iterators = {}
         directions = {}
-        for d in self.buffer.dimensions:
+        for d, h in zip(self.buffer.dimensions, self.buffer._size_halo):
             try:
                 interval, si, direction = self.itintervals_mapper[d]
+                # The initialization must comprise the halo region as well, since
+                # in principle this could be accessed through a stencil
+                interval = interval.translate(v0=-h.left, v1=h.right)
             except KeyError:
                 # E.g., the contraction Dimension `db0`
                 assert d in self.contraction_mapper.values()
diff --git a/tests/test_buffering.py b/tests/test_buffering.py
index 4cbbe02e2..2c6c8ff2e 100644
--- a/tests/test_buffering.py
+++ b/tests/test_buffering.py
@@ -663,3 +663,24 @@ def test_everything():
     op1.apply(time_m=15, time_M=35, save_shift=0, u=u1)
 
     assert np.all(u.data == u1.data)
+
+
+@pytest.mark.parametrize('subdomain', ['domain', 'interior'])
+def test_stencil_issue_1915(subdomain):
+    nt = 5
+    grid = Grid(shape=(6, 6))
+
+    u = TimeFunction(name='u', grid=grid, space_order=4, save=nt)
+    u1 = TimeFunction(name='u', grid=grid, space_order=4, save=nt)
+
+    subdomain = grid.subdomains[subdomain]
+
+    eqn = Eq(u.forward, u.dx + 1, subdomain=subdomain)
+
+    op0 = Operator(eqn, opt='noop')
+    op1 = Operator(eqn, opt='buffering')
+
+    op0.apply(time_M=nt-2)
+    op1.apply(time_M=nt-2, u=u1)
+
+    assert np.all(u.data == u1.data)
Repository: devitocodes/devito
Issue: Symbolic coefficient erroring due to factorization

Symbolic coefficient cannot be applied to `p.dx2 + q.dx2` because it is factorized as `(p+q).dx2`.

MFE:
```
from devito import Eq, Grid, Operator, TimeFunction, Coefficient, Substitutions
import numpy as np
from sympy import finite_diff_weights

grid = Grid(shape=(100,100,100))
p = TimeFunction(name='p', grid=grid, #save=tt.num,
                        space_order=8, time_order=2,
                        coefficients='symbolic' )  # the customized coefficients

q = TimeFunction(name='q', grid=grid, #save=tt.num,
                        space_order=8, time_order=2,
                        coefficients='symbolic' )  # the customized coefficients

OP = Operator( [ Eq(p.forward, p.dx2 + q.dx2)] )
```

Changed files:
tests/test_symbolic_coefficients.py, devito/passes/equations/linearity.py

diff --git a/devito/passes/equations/linearity.py b/devito/passes/equations/linearity.py
index 44429caa2..ee905041d 100644
--- a/devito/passes/equations/linearity.py
+++ b/devito/passes/equations/linearity.py
@@ -187,6 +187,11 @@ def _(expr):
     if not derivs:
         return reuse_if_untouched(expr, args)
 
+    # Cannot factorize derivatives with symbolic coefficients since
+    # they may have different coefficient values at evaluation
+    if any(d._uses_symbolic_coefficients for d in derivs):
+        return reuse_if_untouched(expr, args)
+
     # Map by type of derivative
     # Note: `D0(a) + D1(b) == D(a + b)` <=> `D0` and `D1`'s metadata match,
     # i.e. they are the same type of derivative
diff --git a/tests/test_symbolic_coefficients.py b/tests/test_symbolic_coefficients.py
index 40da905f3..05843fcc6 100644
--- a/tests/test_symbolic_coefficients.py
+++ b/tests/test_symbolic_coefficients.py
@@ -6,6 +6,7 @@ from devito import (Grid, Function, TimeFunction, Eq, Coefficient, Substitutions
                     Dimension, solve, Operator, NODE)
 from devito.finite_differences import Differentiable
 from devito.tools import as_tuple
+from devito.passes.equations.linearity import factorize_derivatives
 
 _PRECISION = 9
 
@@ -344,3 +345,17 @@ class TestSC(object):
         Operator([eq_f, eq_g])(t_m=0, t_M=1)
 
         assert np.allclose(f.data[-1], -g.data[-1], atol=1e-7)
+
+    def test_collect_w_custom_coeffs(self):
+        grid = Grid(shape=(11, 11, 11))
+        p = TimeFunction(name='p', grid=grid, space_order=8, time_order=2,
+                         coefficients='symbolic')
+
+        q = TimeFunction(name='q', grid=grid, space_order=8, time_order=2,
+                         coefficients='symbolic')
+
+        expr = p.dx2 + q.dx2
+        collected = factorize_derivatives(expr)
+        assert collected == expr
+        assert collected.is_Add
+        Operator([Eq(p.forward, expr)])(time_M=2)  # noqa
Repository: devitocodes/devito
Issue: Buggy aliases routine

https://github.com/devitocodes/devito/blob/42d45b3171bb33fc0d9f28af346aba60a5027601/devito/passes/clusters/aliases.py#L441

This error if result of `split` is None.

Changed files:
devito/passes/clusters/aliases.py, tests/test_dse.py

diff --git a/devito/passes/clusters/aliases.py b/devito/passes/clusters/aliases.py
index f635e8e74..0f366179b 100644
--- a/devito/passes/clusters/aliases.py
+++ b/devito/passes/clusters/aliases.py
@@ -431,14 +431,15 @@ def collect(exprs, ignore_collected, options):
             # Try again with fewer groups
             # Heuristic: first try retaining the larger ones
             smallest = len(min(groups, key=len))
+            fallback = groups
             groups, remainder = split(groups, lambda g: len(g) > smallest)
             if groups:
                 queue.append(remainder)
             else:
                 # No luck with the heuristic, e.g. there are two groups
                 # and both have same `len`
-                queue.append(groups[1:])
-                groups = [groups.pop(0)]
+                queue.append(fallback[1:])
+                groups = [fallback.pop(0)]
 
         for g in groups:
             c = g.pivot
diff --git a/tests/test_dse.py b/tests/test_dse.py
index d74305edc..bbb092ff9 100644
--- a/tests/test_dse.py
+++ b/tests/test_dse.py
@@ -1730,6 +1730,43 @@ class TestAliases(object):
         op1.apply(time_M=2, u=u1)
         assert np.isclose(norm(u), norm(u1), rtol=1e-7)
 
+    @pytest.mark.parametrize('rotate', [False, True])
+    def test_grouping_fallback(self, rotate):
+        """
+        MFE for issue #1477.
+        """
+        space_order = 8
+        grid = Grid(shape=(21, 21, 11))
+
+        eps = Function(name='eps', grid=grid, space_order=space_order)
+        p = TimeFunction(name='p', grid=grid, time_order=2, space_order=space_order)
+        p1 = TimeFunction(name='p0', grid=grid, time_order=2, space_order=space_order)
+
+        p.data[:] = 0.02
+        p1.data[:] = 0.02
+        eps.data_with_halo[:] =\\
+            np.linspace(0.1, 0.3, eps.data_with_halo.size).reshape(*eps.shape_with_halo)
+
+        eqn = Eq(p.forward, ((1+sqrt(eps)) * p.dy).dy + (p.dz).dz)
+
+        op0 = Operator(eqn, opt=('noop', {'openmp': True}))
+        op1 = Operator(eqn, opt=('advanced', {'openmp': True, 'cire-rotate': rotate}))
+
+        # Check code generation
+        # `min-storage` leads to one 2D and one 3D Arrays
+        xs, ys, zs = self.get_params(op1, 'x0_blk0_size', 'y0_blk0_size', 'z_size')
+        arrays = [i for i in FindSymbols().visit(op1._func_table['bf0']) if i.is_Array]
+        assert len(arrays) == 3
+        assert len([i for i in arrays if i._mem_shared]) == 1
+        assert len([i for i in arrays if i._mem_local]) == 2
+        self.check_array(arrays[0], ((4, 4),), (zs+8,))  # On purpose w/o `rotate`
+        self.check_array(arrays[1], ((4, 4), (0, 0)), (ys+8, zs), rotate)
+
+        # Check numerical output
+        op0.apply(time_M=2)
+        op1.apply(time_M=2, p=p1)
+        assert np.isclose(norm(p), norm(p1), rtol=1e-7)
+
 
 # Acoustic
 class TestIsoAcoustic(object):
Repository: devitocodes/devito
Issue: MPI + iso-acoustic self-adjoint jacobian is buggy

Still under investigation.

But the following command:

```
DEVITO_MPI=1 mpirun -n 8 --map-by numa python benchmark.py run -P acoustic_sa -op jacobian -d 152 152 152 -so 4 --tn 1000 --autotune off
```

produces broken norms  (ie != no mpi, or mpirun -n 4 which is instead == no mpi, etc)

Changed files:
benchmarks/user/benchmark.py

diff --git a/benchmarks/user/benchmark.py b/benchmarks/user/benchmark.py
index 21d5c5664..a2fdbe473 100644
--- a/benchmarks/user/benchmark.py
+++ b/benchmarks/user/benchmark.py
@@ -66,7 +66,7 @@ def run_op(solver, operator, **options):
         dm = solver.model.dm
         # Because sometime dm is zero, artificially add a non zero slice
         if dm.data.min() == 0 and dm.data.max() == 0:
-            dm.data[..., np.min([25, dm.shape[-1]//4])] = .1
+            dm.data[..., np.min([25, dm.shape_global[-1]//4])] = .1
         return op(dm, **options)
     elif operator == "jacobian_adjoint":
         # I think we want the forward + gradient call, need to merge retvals
Repository: floooh/fips
Issue: Platform error when using cygwin

```
Traceback (most recent call last):
  File "./fips", line 8, in <module>
    fips.run(fips_path, proj_path, sys.argv)
  File "/home/user/Code/fips/mod/fips.py", line 49, in run
    verb.verbs[verb_name].run(fips_path, proj_path, verb_args)
  File "/home/user/Code/fips/verbs/diag.py", line 82, in run
    check_tools(fips_dir)
  File "/home/user/Code/fips/verbs/diag.py", line 28, in check_tools
    platform = util.get_host_platform()
  File "/home/user/Code/fips/mod/util.py", line 204, in get_host_platform
    return host_platforms[platform.system()]
KeyError: 'CYGWIN_NT-6.1' 
```

What to do in this situation? At least printing a help telling to use any of the supported platforms?


Changed files:
mod/util.py

diff --git a/mod/util.py b/mod/util.py
index 85a4048..3ac0c4f 100644
--- a/mod/util.py
+++ b/mod/util.py
@@ -201,6 +201,9 @@ def get_host_platform() :
 
     :returns: platform name (osx, linux, win)
     """
+    plat = platform.system()
+    if "CYGWIN_NT" in plat:
+        return host_platforms['Linux']
     return host_platforms[platform.system()]