nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: pyfar/pyfar
Pull request #742 (2024-12-27 12:34:02)

hot: fix radius check in find_within


Patch:
diff --git a/pyfar/classes/coordinates.py b/pyfar/classes/coordinates.py
index e6ff15b3..27437215 100644
--- a/pyfar/classes/coordinates.py
+++ b/pyfar/classes/coordinates.py
@@ -1692,7 +1692,8 @@ class Coordinates():
 
         if distance_measure in ['spherical_radians', 'spherical_meter']:
             # determine validate radius
-            radius = np.concatenate((self.radius, find.radius))
+            radius = np.concatenate(
+                (self.radius.flatten(), find.radius.flatten()))
             delta_radius = np.max(radius) - np.min(radius)
             if delta_radius > radius_tol:
                 raise ValueError(
@@ -1853,11 +1854,12 @@ class Coordinates():
                 points, distance + atol, return_sorted=return_sorted)
         if distance_measure in ['spherical_radians', 'spherical_meter']:
             # determine validate radius
-            radius = self.radius
+            radius = np.concatenate(
+                (self.radius.flatten(), find.radius.flatten()))
             delta_radius = np.max(radius) - np.min(radius)
             if delta_radius > radius_tol:
                 raise ValueError(
-                    "find_nearest_sph only works if all points have the same "
+                    "find_within only works if all points have the same "
                     f"radius. Differences are larger than {radius_tol}")
             radius = np.max(radius)
 


Test patch:
diff --git a/tests/test_coordinates_find.py b/tests/test_coordinates_find.py
index 32cf37a8..9e357c3b 100644
--- a/tests/test_coordinates_find.py
+++ b/tests/test_coordinates_find.py
@@ -207,6 +207,14 @@ def test_find_within_error():
     with pytest.raises(ValueError, match=match):
         coords.find_within(find, 1, return_sorted=-1)
 
+    find.radius = .1
+    radius_tol = 0.1
+    match = ('find_within only works if all points have the same radius. '
+             f'Differences are larger than {radius_tol}')
+    with pytest.raises(ValueError, match=match):
+        coords.find_within(
+            find, distance_measure='spherical_radians', radius_tol=radius_tol)
+
 
 @pytest.mark.parametrize('distance_measure', [
      'spherical_radians', 'spherical_meter',
Repository: pyfar/pyfar
Pull request #764 (2025-02-03 15:20:24)

HOT: return int array for find_impulse_response_start() 
return int array for find_impulse_response_start() as highlighted in the docs

since they return index the type should be int.


Patch:
diff --git a/pyfar/dsp/dsp.py b/pyfar/dsp/dsp.py
index 09d1a0fa..0aabd899 100644
--- a/pyfar/dsp/dsp.py
+++ b/pyfar/dsp/dsp.py
@@ -1433,7 +1433,7 @@ def find_impulse_response_start(
 
     """
     modes = ['real', 'complex'] if impulse_response.complex else ['real']
-    ir_start = np.zeros(((len(modes), ) + impulse_response.cshape))
+    ir_start = np.zeros(((len(modes), ) + impulse_response.cshape), dtype=int)
     for idx, mode in enumerate(modes):
         ir = impulse_response.time
         ir_squared = np.real(ir)**2 if mode == 'real' else np.imag(ir)**2


Test patch:
diff --git a/tests/test_dsp.py b/tests/test_dsp.py
index ff16aa3f..e8a18f4d 100644
--- a/tests/test_dsp.py
+++ b/tests/test_dsp.py
@@ -834,6 +834,7 @@ def test_impulse_response_start():
     ir = pf.Signal(ir, 44100)
 
     start_sample_est = dsp.find_impulse_response_start(ir)
+    assert start_sample_est.dtype == int
     assert start_sample_est == start_sample - 1
 
     ir_awgn = ir + noise