From dfc9ba8ab2bb771632420dba3697dd8a7a47ed64 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 20 Feb 2026 15:13:01 +0000 Subject: [PATCH 1/2] Initial plan From bb02ba32c355933350ff6fabd05bfe1cdf0b28bb Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 20 Feb 2026 15:18:04 +0000 Subject: [PATCH 2/2] Simplify and fix random_activation_in_scope in ActivationRegistry Co-authored-by: HyperCodec <72839119+HyperCodec@users.noreply.github.com> --- src/activation.rs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/activation.rs b/src/activation.rs index 3ea25b6..dadb9d2 100644 --- a/src/activation.rs +++ b/src/activation.rs @@ -93,24 +93,24 @@ impl ActivationRegistry { } /// Fetches a random activation fn that applies to the provided scope. + /// + /// # Panics + /// + /// Panics if there are no activation functions registered for the given scope. pub fn random_activation_in_scope( &self, scope: NeuronScope, rng: &mut impl rand::Rng, ) -> ActivationFn { - let mut iter = self.fns.values().cycle(); - let num_iterations = rng.random_range(0..self.fns.len() - 1); + let activations = self.activations_in_scope(scope); - for _ in 0..num_iterations { - iter.next().unwrap(); - } - - let mut val = iter.next().unwrap(); - while !val.scope.contains(scope) { - val = iter.next().unwrap(); - } + assert!( + !activations.is_empty(), + "no activation functions registered for scope {:?}", + scope + ); - val.clone() + activations[rng.random_range(0..activations.len())].clone() } }