Skip to content

Commit

Permalink
Fixed an issue with negative weights being dealt with incorrectly
Browse files Browse the repository at this point in the history
  • Loading branch information
rowleya committed May 5, 2016
1 parent 57c13c6 commit a49b9f8
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,12 @@ def _get_weight_mean(weights, connection_slices):
""" Get the mean of the weights
"""
if isinstance(weights, RandomDistribution):
return utility_calls.get_mean(weights)
return abs(utility_calls.get_mean(weights))
elif numpy.isscalar(weights):
return weights
return abs(weights)
elif hasattr(weights, "__getitem__"):
return numpy.mean([
weights[connection_slice]
numpy.abs(weights[connection_slice])
for connection_slice in connection_slices])
raise Exception("Unrecognised weight format")

Expand Down Expand Up @@ -180,10 +180,10 @@ def _get_weight_maximum(weights, n_connections, connection_slices):
return abs(max_weight)

elif numpy.isscalar(weights):
return weights
return abs(weights)
elif hasattr(weights, "__getitem__"):
return numpy.amax([
weights[connection_slice]
numpy.abs(weights[connection_slice])
for connection_slice in connection_slices])
raise Exception("Unrecognised weight format")

Expand All @@ -204,7 +204,7 @@ def _get_weight_variance(weights, connection_slices):
return 0.0
elif hasattr(weights, "__getitem__"):
return numpy.var([
weights[connection_slice]
numpy.abs(weights[connection_slice])
for connection_slice in connection_slices])
raise Exception("Unrecognised weight format")

Expand Down Expand Up @@ -269,7 +269,7 @@ def _generate_weights(self, values, n_connections, connection_slices):
" in projection {}->{}".format(
self._pre_population.label,
self._post_population.label))
return weights
return numpy.abs(weights)

def _clip_delays(self, delays):
""" Clip delay values, keeping track of how many have been clipped
Expand Down

0 comments on commit a49b9f8

Please sign in to comment.