From c7431755f878b513955603950aa314fc4a05c086 Mon Sep 17 00:00:00 2001 From: Sylvester Kaczmarek <16242628+sylvesterkaczmarek@users.noreply.github.com> Date: Sun, 30 Aug 2026 00:23:33 +0100 Subject: [PATCH] Fix Particles fuse negligible-weight status --- ssapy/particles.py | 2 +- tests/test_particles.py | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ssapy/particles.py b/ssapy/particles.py index 2d7ed42e..632b0e10 100644 --- a/ssapy/particles.py +++ b/ssapy/particles.py @@ -255,7 +255,7 @@ def fuse(self, epoch_particles, verbose=False): # Update the weight values by 'cross-pollinating' epoch likelihoods status = self.reweight(epoch_particles) # Check that we have at least some non-zero weights for particles - if status > 0 and verbose: + if not status and verbose: print("All weights are negligible in Particles class") print("\tlog-norm:",np.logaddexp.reduce(self.ln_wts)) # Resample the weights to maintain only significant particles diff --git a/tests/test_particles.py b/tests/test_particles.py index 2960ad4e..7ec6a32c 100644 --- a/tests/test_particles.py +++ b/tests/test_particles.py @@ -186,4 +186,8 @@ def shrink_resample(particles_arg, ln_weights_arg, pod=False): monkeypatch.setattr(particles, "reweight", lambda epoch_particles: True) monkeypatch.setattr(particles, "resample", lambda num_particles: None) particles.fuse(particles, verbose=True) + assert "All weights are negligible" not in capsys.readouterr().out + + monkeypatch.setattr(particles, "reweight", lambda epoch_particles: False) + particles.fuse(particles, verbose=True) assert "All weights are negligible" in capsys.readouterr().out