From 204430e4f6cfcf4a08fd084d5c4e64c019f6f1b2 Mon Sep 17 00:00:00 2001
From: Jean-Baptiste Bayle <j2b.bayle@gmail.com>
Date: Wed, 30 Mar 2022 12:53:52 +0200
Subject: [PATCH] Fix a bug in `test_run_no_upsampling()`

---
 lisainstrument/instrument.py | 6 ++++--
 tests/test_instrument.py     | 1 -
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/lisainstrument/instrument.py b/lisainstrument/instrument.py
index 762149b..1062db0 100644
--- a/lisainstrument/instrument.py
+++ b/lisainstrument/instrument.py
@@ -1547,9 +1547,11 @@ class Instrument:
         logger.debug("Solving iteratively (tolerance=%s s, maxiter=%s)",
             self.clockinv_tolerance, self.clockinv_maxiter)
 
-        niter = 0
+        # Drop samples at the edges to compute error
+        edge = min(100, len(timer_deviations) // 2 - 1)
         error = 0
-        edge = 100 # drop samples at the edges to check convergence
+
+        niter = 0
         next_inverse = timer_deviations
         while not niter or error > self.clockinv_tolerance:
             if niter >= self.clockinv_maxiter:
diff --git a/tests/test_instrument.py b/tests/test_instrument.py
index 7b2d08b..54adb73 100644
--- a/tests/test_instrument.py
+++ b/tests/test_instrument.py
@@ -16,7 +16,6 @@ def test_run_no_aafilter():
     instru = Instrument(size=100, aafilter=None)
     instru.simulate()
 
-@pytest.mark.skip(reason="do not know why this fails")
 def test_run_no_upsampling():
     """Test that simulations can run with no filter."""
     instru = Instrument(size=100, physics_upsampling=1, aafilter=None)
-- 
GitLab