anon-iclr-submission/benchname-bug-localization huggingface dataset:
Repository: openforcefield/openff-interchange
Issue: Incorrect 1-4 vdW energies differences with OpenMM

Using the README example:

```python
In [32]: get_summary_data(out, combine_nonbonded_forces=True)
Out[32]:
             Bond      Angle   Torsion  Nonbonded       vdW  Electrostatics  RBTorsion
OpenMM   0.153073  37.844839  4.352785 -16.943223       NaN             NaN        NaN
Amber    0.151879  37.843025  4.352615        NaN  0.663164      -17.604598        NaN
GROMACS  0.153099  37.844906  4.352784        NaN  0.659480      -17.608341        0.0
LAMMPS   0.157495  37.844841  4.352785        NaN  0.655790      -17.617824        NaN

In [33]: get_summary_data(out, combine_nonbonded_forces=False)
Out[33]:
             Bond      Angle   Torsion  Electrostatics       vdW  RBTorsion
OpenMM   0.153073  37.844839  4.352785      -17.600324  1.316730        NaN
Amber    0.151879  37.843025  4.352615      -17.604598  0.663164        NaN
GROMACS  0.153099  37.844906  4.352784      -17.608341  0.659480        0.0
LAMMPS   0.157495  37.844841  4.352785      -17.617824  0.655790        NaN

In [34]: get_openmm_energies(out, combine_nonbonded_forces=False, detailed=True)
Out[34]: EnergyReport(energies={'vdW': <Quantity(-0.00252833093, 'kilojoule / mole')>, 'Electrostatics': <Quantity(20.0885625, 'kilojoule / mole')>, 'vdW 1-4': <Quantity(1.31925812, 'kilojoule / mole')>, 'Electrostatics 1-4': <Quantity(-37.6888862, 'kilojoule / mole')>, 'Torsion': <Quantity(4.35278514, 'kilojoule / mole')>, 'Angle': <Quantity(37.8448388, 'kilojoule / mole')>, 'Bond': <Quantity(0.153072926, 'kilojoule / mole')>})
```

The error appears to be isolated to OpenMM, using `combine_nonbonded_forces=False`, and likely results from errors in the 1-4 vdW force.

Changed files:
openff/interchange/interop/openmm/_nonbonded.py

diff --git a/openff/interchange/interop/openmm/_nonbonded.py b/openff/interchange/interop/openmm/_nonbonded.py
index 7b15a107..604511a0 100644
--- a/openff/interchange/interop/openmm/_nonbonded.py
+++ b/openff/interchange/interop/openmm/_nonbonded.py
@@ -956,7 +956,7 @@ def _get_14_scaling_factors(data: _DATA_DICT) -> tuple[float, float]:
     else:
         coul_14 = 1.0
 
-    if data.get("vdw_handler", None) is not None:
+    if data.get("vdw_collection", None) is not None:
         vdw_14 = data["vdw_collection"].scale_14  # type: ignore[union-attr]
     else:
         vdw_14 = 1.0
Repository: qutech/qupulse
Issue: Problems of JSON output of rewritten serialization routines

Compared to the old serialization routines, the new ones do not
- format the resulting JSON string (tabs + newlines missing) so it is not a nicely readable
- sort the keys in the JSON string. This is inconvenient for use with (external) versioning systems (git, svn, etc) as JSON representations of pulses might change due to reordering between subsequent savings even if the pulse itself didn't change

Implement the above two features

Changed files:
tests/serialization_tests.py, qctoolkit/serialization.py

diff --git a/qctoolkit/serialization.py b/qctoolkit/serialization.py
index 2e5675f4..b441cb28 100644
--- a/qctoolkit/serialization.py
+++ b/qctoolkit/serialization.py
@@ -679,7 +679,7 @@ class PulseStorage:
             if is_transaction_begin:
                 self._transaction_storage = dict()
 
-            encoder = JSONSerializableEncoder(self)
+            encoder = JSONSerializableEncoder(self, sort_keys=True, indent=4)
 
             serialization_data = serializable.get_serialization_data()
             serialized = encoder.encode(serialization_data)
diff --git a/tests/serialization_tests.py b/tests/serialization_tests.py
index e8b01091..1853318e 100644
--- a/tests/serialization_tests.py
+++ b/tests/serialization_tests.py
@@ -522,7 +522,7 @@ class PulseStorageTests(unittest.TestCase):
         self.assertNotIn('my_id_2', self.backend)
         self.assertIs(previous_inner, self.storage['my_id_1'])
 
-        enc = JSONSerializableEncoder(None)
+        enc = JSONSerializableEncoder(None, sort_keys=True, indent=4)
         expected = enc.encode(previous_inner.get_serialization_data())
         self.assertEqual(expected, self.backend['my_id_1'])
 
@@ -554,6 +554,24 @@ class PulseStorageTests(unittest.TestCase):
 
         self.assertFalse(self.storage.temporary_storage)
 
+    def test_beautified_json(self) -> None:
+        data = {'e': 89, 'b': 151, 'c': 123515, 'a': 123, 'h': 2415}
+        template = DummySerializable(data=data)
+        pulse_storage = PulseStorage(DummyStorageBackend())
+        pulse_storage['foo'] = template
+
+        expected = """{
+    \\"#type\\": \\"""" + DummySerializable.get_type_identifier() + """\\",
+    \\"data\\": {
+        \\"a\\": 123,
+        \\"b\\": 151,
+        \\"c\\": 123515,
+        \\"e\\": 89,
+        \\"h\\": 2415
+    }
+}"""
+        self.assertEqual(expected, pulse_storage._storage_backend['foo'])
+
 
 class JSONSerializableDecoderTests(unittest.TestCase):
     def test_filter_serializables(self):
Repository: 21cmfast/21cmfast
Issue: [BUG] unexpected behaviour for `write=False`

**Describe the bug:**
When calling `p21.run_lightcone` with `write = False`, it still caches all the files. The same probably holds for all underlying functions.

**Expected behavior:**
Even with the new flexibility of the `write` flag, I assume making it `False` should turn off all caching/writing.

Changed files:
src/py21cmfast/wrapper.py

diff --git a/src/py21cmfast/wrapper.py b/src/py21cmfast/wrapper.py
index 07645d3..a240102 100644
--- a/src/py21cmfast/wrapper.py
+++ b/src/py21cmfast/wrapper.py
@@ -123,7 +123,7 @@ def _configure_inputs(
     defaults: list,
     *datasets,
     ignore: list = ["redshift"],
-    flag_none: [list, None] = None,
+    flag_none: Union[list, None] = None,
 ):
     """Configure a set of input parameter structs.
 
@@ -261,17 +261,19 @@ def _get_config_options(
 ) -> Tuple[str, bool, Dict[Callable, Dict[str, Any]]]:
 
     direc = str(os.path.expanduser(config["direc"] if direc is None else direc))
-    hooks = hooks or {}
 
-    if callable(write) and write not in hooks:
-        hooks[write] = {"direc": direc}
+    if hooks is None or len(hooks) > 0:
+        hooks = hooks or {}
 
-    if not hooks:
-        if write is None:
-            write = config["write"]
+        if callable(write) and write not in hooks:
+            hooks[write] = {"direc": direc}
 
-        if not callable(write) and write:
-            hooks["write"] = {"direc": direc}
+        if not hooks:
+            if write is None:
+                write = config["write"]
+
+            if not callable(write) and write:
+                hooks["write"] = {"direc": direc}
 
     return (
         direc,
Repository: pyfar/pyfar
Issue: Make python-soundfile optional

## General

python-soundfile sometines makes problems depending on the os and processor. It would be good to make pyfar importable in that case and raise a warning if soundfile could not be imported.

Changed files:
pyfar/io/io.py

diff --git a/pyfar/io/io.py b/pyfar/io/io.py
index 5fab96ae..cad17262 100644
--- a/pyfar/io/io.py
+++ b/pyfar/io/io.py
@@ -14,10 +14,19 @@ import warnings
 import sofar as sf
 import zipfile
 import io
-import soundfile
 import tempfile
 import numpy as np
 
+try:
+    import soundfile
+    soundfile_imported = True
+except ModuleNotFoundError or OSError:
+    soundfile_imported = False
+    soundfile_warning = (
+        "python-soundfile could not be imported. Try to install it using `pip "
+        "install soundfile`. If this not works search the documentation for "
+        "help: https://python-soundfile.readthedocs.io")
+
 import pyfar
 from pyfar import Signal, FrequencyData, Coordinates
 from . import _codec as codec
@@ -276,6 +285,10 @@ def read_audio(filename, dtype='float64', **kwargs):
       [-1.0, 1.0). If the file contains ``np.array([42.6], dtype='float32')``,
       you will read ``np.array([43], dtype='int32')`` for ``dtype='int32'``.
     """
+    if not soundfile_imported:
+        warnings.warn(soundfile_warning)
+        return
+
     data, sampling_rate = soundfile.read(
         file=filename, dtype=dtype, always_2d=True, **kwargs)
     signal = Signal(data.T, sampling_rate, domain='time', dtype=dtype)
@@ -317,6 +330,10 @@ def write_audio(signal, filename, subtype=None, overwrite=True, **kwargs):
       amplitudes larger than +/- 1 are clipped.
 
     """
+    if not soundfile_imported:
+        warnings.warn(soundfile_warning)
+        return
+
     sampling_rate = signal.sampling_rate
     data = signal.time
 
@@ -426,6 +443,10 @@ def audio_formats():
      'MAT5': 'MAT5 (GNU Octave 2.1 / Matlab 5.0)'}
 
     """
+    if not soundfile_imported:
+        warnings.warn(soundfile_warning)
+        return
+
     return soundfile.available_formats()
 
 
@@ -450,6 +471,10 @@ def audio_subtypes(format=None):
      'PCM_S8': 'Signed 8 bit PCM'}
 
     """
+    if not soundfile_imported:
+        warnings.warn(soundfile_warning)
+        return
+
     return soundfile.available_subtypes(format=format)
 
 
@@ -469,6 +494,10 @@ def default_audio_subtype(format):
     'DOUBLE'
 
     """
+    if not soundfile_imported:
+        warnings.warn(soundfile_warning)
+        return
+
     return soundfile.default_subtype(format)
 
 
@@ -480,6 +509,10 @@ def _clipped_audio_subtypes():
     to disk. It needs to be called manually:
     pyfar.io.io._clipped_audio_subtypes().
     """
+    if not soundfile_imported:
+        warnings.warn(soundfile_warning)
+        return
+
     collection = {}
     signal = pyfar.Signal([-1.5, -1, -.5, 0, .5, 1, 1.5]*100, 44100)
     with tempfile.TemporaryDirectory() as tmpdir:
Repository: pyfar/pyfar
Issue: Global import of external samplings breaks setup 

## Description

Import error of `pyfar.spatial.external` which is a private submodule, not a global module.

Occurs on local install on some systems running `python setup.py install`.

## What I Did

Corresponding traceback of install.

```
File "import_pyfar_test.py", line 1, in <module>
    from pyfar import spatial
  File "/usr/local/Caskroom/miniconda/base/envs/pyfar/lib/python3.8/site-packages/pyfar-0.1.0-py3.8.egg/pyfar/__init__.py", line 15, in <module>
    from . import spatial
  File "/usr/local/Caskroom/miniconda/base/envs/pyfar/lib/python3.8/site-packages/pyfar-0.1.0-py3.8.egg/pyfar/spatial/__init__.py", line 6, in <module>
    from . import samplings
  File "/usr/local/Caskroom/miniconda/base/envs/pyfar/lib/python3.8/site-packages/pyfar-0.1.0-py3.8.egg/pyfar/spatial/samplings.py", line 10, in <module>
    from pyfar.spatial.external import (
ModuleNotFoundError: No module named 'pyfar.spatial.external'
```


Changed files:
pyfar/spatial/samplings.py, pyfar/dsp/filter.py

diff --git a/pyfar/dsp/filter.py b/pyfar/dsp/filter.py
index 36cac98c..88be8a18 100644
--- a/pyfar/dsp/filter.py
+++ b/pyfar/dsp/filter.py
@@ -3,7 +3,7 @@ import scipy.signal as spsignal
 
 from .classes import (FilterIIR, FilterSOS)
 
-import pyfar.dsp._audiofilter as iir
+from . import _audiofilter as iir
 
 
 def butter(signal, N, frequency, btype='lowpass', sampling_rate=None):
diff --git a/pyfar/spatial/samplings.py b/pyfar/spatial/samplings.py
index 91cd9236..8d0ed35e 100644
--- a/pyfar/spatial/samplings.py
+++ b/pyfar/spatial/samplings.py
@@ -7,8 +7,8 @@ import urllib3
 import os
 import scipy.io as sio
 from pyfar.coordinates import Coordinates
-from pyfar.spatial.external import (
-    samplings_lebedev, eq_area_partitions)
+
+from .external import (samplings_lebedev, eq_area_partitions)
 
 
 def cart_equidistant_cube(n_points):
Repository: pyfar/pyfar
Issue: Coordinates __getitem__, slicing bug

## Description

Slicing of coordinates changes the original object instead of returning a new object.

## What I Did

```
import pyfar
coords = pyfar.Coordinates([0,1], [0,1], [0,1])
coords_sliced = coords[0]
coords.cshape == (2,)
```

Changed files:
tests/test_coordinates.py, pyfar/coordinates.py

diff --git a/pyfar/coordinates.py b/pyfar/coordinates.py
index acf494a0..38f3848e 100644
--- a/pyfar/coordinates.py
+++ b/pyfar/coordinates.py
@@ -1632,9 +1632,9 @@ class Coordinates(object):
         return kdtree
 
     def __getitem__(self, index):
-        """Return mutable slice of Coordinates object at index."""
+        """Return copied slice of Coordinates object at index."""
 
-        new = self
+        new = self.copy()
         # slice points
         new._points = new._points[index]
         # slice weights
diff --git a/tests/test_coordinates.py b/tests/test_coordinates.py
index 5e863d88..13df4bc3 100644
--- a/tests/test_coordinates.py
+++ b/tests/test_coordinates.py
@@ -413,6 +413,13 @@ def test_getitem():
     assert isinstance(new, Coordinates)
     assert new.cshape == (1, 5)
 
+    # test if sliced object stays untouched
+    coords = Coordinates([0, 1], [0, 1], [0, 1])
+    new = coords[0]
+    new.set_cart(2, 2, 2)
+    assert coords.cshape == (2,)
+    npt.assert_allclose(coords.get_cart()[0], np.array([0, 0, 0]))
+
 
 def test_get_nearest_k():
     # 1D cartesian, nearest point
Repository: pyfar/pyfar
Issue: Import pyfar produced undesired console output

## General

* pyfar version: 0.3.0

## Description

importing pyfar creates a matplotlib figure and undesired command line output
`<Figure size 432x288 with 0 Axes>`

## What I Did

```
import pyfar
```

Changed files:
pyfar/plot/_utils.py

diff --git a/pyfar/plot/_utils.py b/pyfar/plot/_utils.py
index bdb1bbe1..5e312891 100644
--- a/pyfar/plot/_utils.py
+++ b/pyfar/plot/_utils.py
@@ -6,7 +6,7 @@ from matplotlib.tight_layout import get_subplotspec_list
 from pyfar import (Signal, FrequencyData)
 
 
-def _tight_layout(fig=plt.gcf()):
+def _tight_layout(fig=None):
     """
     Apply Matplotlibs tight_layout only when it is likely to work.
 
@@ -17,8 +17,12 @@ def _tight_layout(fig=plt.gcf()):
 
     Parameters
     ----------
-    fig : Matplotlib Figure
+    fig : Matplotlib Figure, optional
+        The default is ``None`` which uses ``plt.gcf()``
     """
+    if fig is None:
+        fig = plt.gcf()
+
     subplotspec_list = get_subplotspec_list(fig.get_axes())
     if None not in subplotspec_list:
         plt.tight_layout()
Repository: pyfar/pyfar
Issue: Math in docstrings

## General

* pyfar version: 0.5.1

## Description

Formulas in the docstrings are not displayed correctly. Seems to be broken since Sphinx 5.3 (or similar)

Changed files:
tests/test_dsp_normalize.py, docs/conf.py, pyfar/dsp/dsp.py

diff --git a/docs/conf.py b/docs/conf.py
index 0ebb1b71..27dfad79 100755
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -38,7 +38,7 @@ extensions = [
     'sphinx.ext.napoleon',
     'sphinx.ext.autosummary',
     'matplotlib.sphinxext.plot_directive',
-    'sphinx.ext.imgmath',
+    'sphinx.ext.mathjax',
     'autodocsumm']
 
 # show tocs for classes and functions of modules using the autodocsumm
@@ -49,8 +49,6 @@ autodoc_default_options = {'autosummary': True}
 # package matplotlib.sphinxext.plot_directive
 plot_include_source = True
 
-imgmath_latex_preamble = r'\\usepackage{array}'
-
 # Add any paths that contain templates here, relative to this directory.
 # templates_path = ['_templates']
 
diff --git a/pyfar/dsp/dsp.py b/pyfar/dsp/dsp.py
index 8b77aa1c..a0fcc665 100644
--- a/pyfar/dsp/dsp.py
+++ b/pyfar/dsp/dsp.py
@@ -1366,7 +1366,7 @@ def find_impulse_response_start(
     """
     ir_squared = np.abs(impulse_response.time)**2
 
-    mask_start = np.int(0.9*impulse_response.n_samples)
+    mask_start = int(0.9*impulse_response.n_samples)
 
     mask = np.arange(mask_start, ir_squared.shape[-1])
     noise = np.mean(np.take(ir_squared, mask, axis=-1), axis=-1)
diff --git a/tests/test_dsp_normalize.py b/tests/test_dsp_normalize.py
index d4bf0ec9..1402a65d 100644
--- a/tests/test_dsp_normalize.py
+++ b/tests/test_dsp_normalize.py
@@ -44,11 +44,11 @@ def test_domains_normalization():
     time = pf.dsp.normalize(signal, domain="time")
     freq = pf.dsp.normalize(signal, domain="freq")
 
-    assert np.max(np.abs(time.time)) == 1
+    npt.assert_allclose(np.max(np.abs(time.time)), 1)
     assert np.max(np.abs(time.freq)) != 1
 
     assert np.max(np.abs(freq.time)) != 1
-    assert np.max(np.abs(freq.freq)) == 1
+    npt.assert_allclose(np.max(np.abs(freq.freq)), 1)
 
 
 @pytest.mark.parametrize('unit, limit1, limit2', (