diff --git a/bindsnet/network/topology_features.py b/bindsnet/network/topology_features.py index 7abcd636..46503a87 100644 --- a/bindsnet/network/topology_features.py +++ b/bindsnet/network/topology_features.py @@ -291,7 +291,7 @@ def degrade(self) -> None: be *subtracted* from the propagated spikes. """ - return self.degrade(self.value) + return self.degrade_function(self.value) def link(self, parent_feature) -> None: # language=rst diff --git a/test/network/test_connections.py b/test/network/test_connections.py index fec421da..10f5c3f1 100644 --- a/test/network/test_connections.py +++ b/test/network/test_connections.py @@ -341,6 +341,15 @@ def test_degradation_feature_output(self): ) assert torch.allclose(conn.compute(s), s @ w - (0.5 * deg).sum(0), atol=1e-6) + def test_degradation_feature_degrade_applies_degrade_function(self): + # degrade() must hand the value to degrade_function. It used to call + # itself with an argument, which is a TypeError on the first call. + deg = torch.tensor([[0.2, 0.4], [0.6, 0.8], [0.1, 0.3]]) + feature = tf.Degradation( + name="d", value=deg.clone(), degrade_function=lambda v: v * 0.5 + ) + assert torch.allclose(feature.degrade(), 0.5 * deg, atol=1e-6) + def test_probability_feature_deterministic_bounds(self): # bernoulli(1) == 1 (always passes); bernoulli(0) == 0 (always blocked). s = torch.tensor([[1.0, 0.0, 1.0], [1.0, 1.0, 1.0]])