From 95cf3da2792df12b79d46f51b1dc8fff66fd7fb3 Mon Sep 17 00:00:00 2001 From: Rui Coelho Date: Mon, 13 May 2024 18:38:32 +0100 Subject: [PATCH] Add more exceptions if the reduction fails --- piglot/utils/reductions.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/piglot/utils/reductions.py b/piglot/utils/reductions.py index f071108..5338076 100644 --- a/piglot/utils/reductions.py +++ b/piglot/utils/reductions.py @@ -67,7 +67,10 @@ def test_reduction(self) -> None: time = torch.arange(shape[-1]).repeat(shape[:-1] + (1,)) data = torch.randn(*shape) params = torch.randn(num_params).repeat(shape[:-1] + (1,)) - reduced = self.reduce_torch(time, data, params) + try: + reduced = self.reduce_torch(time, data, params) + except Exception as exc: + raise ValueError(f"Test failed for reduction {type(self)}.") from exc if reduced.shape != shape[:-1]: raise ValueError( f"Bad shape after reduction for {type(self)}. "