From 67732d7ba3f5928bebf8f630f5190d9a84bc0baa Mon Sep 17 00:00:00 2001 From: feltroidprime Date: Tue, 6 Aug 2024 01:22:38 +0200 Subject: [PATCH] fix random sparsity test --- tests/hydra/test_extension_field_modulo_circuit.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/hydra/test_extension_field_modulo_circuit.py b/tests/hydra/test_extension_field_modulo_circuit.py index b9571df6..cc6e3603 100644 --- a/tests/hydra/test_extension_field_modulo_circuit.py +++ b/tests/hydra/test_extension_field_modulo_circuit.py @@ -47,10 +47,15 @@ def test_eval(circuit: tuple[ExtensionFieldModuloCircuit, list[ModuloCircuitElem def generate_random_sparsity( extension_degree: int, num_cases: int = 32 ) -> list[list[int]]: - return [ + sparsities = [ [random.choice([0, 1, 2]) for _ in range(extension_degree)] for _ in range(num_cases) ] + for sparsity in sparsities: + if all(x == 0 for x in sparsity): + # Make sure there is at least one non-zero element somewhere + sparsity[random.randint(0, extension_degree - 1)] = random.choice([1, 2]) + return sparsities def test_eval_sparse(