def _get_delay_minimum(self, delays, n_connections, synapse_info): """ Get the minimum delay given a float, RandomDistribution or list of\ delays. :param delays: the delays :type delays: ~numpy.ndarray or ~pyNN.random.NumpyRNG or int or float or list(int) or list(float) :param int n_connections: how many connections """ if isinstance(delays, RandomDistribution): low_estimated_delay = utility_calls.get_minimum_probable_value( delays, n_connections) low = utility_calls.low(delays) if low is None: return low_estimated_delay # The minimum is the maximum of the possible maximums return max(low_estimated_delay, low, 1) elif isinstance(delays, str): d = self._get_distances(delays, synapse_info) return numpy.min(_expr_context.eval(delays, d=d)) elif numpy.isscalar(delays): return delays elif hasattr(delays, "__getitem__"): return numpy.min(delays) raise SpynnakerException("Unrecognised delay format: {:s}".format( type(delays)))
def _get_weight_maximum(self, weights, n_connections, synapse_info): """ Get the maximum of the weights. :param weights: :type weights: ~numpy.ndarray or ~pyNN.random.NumpyRNG or int or float or list(int) or list(float) :param int n_connections: :rtype: float """ if isinstance(weights, RandomDistribution): mean_weight = utility_calls.get_mean(weights) if mean_weight < 0: min_weight = utility_calls.get_minimum_probable_value( weights, n_connections) low = utility_calls.low(weights) if low is None: return abs(min_weight) return abs(max(min_weight, low)) else: max_weight = utility_calls.get_maximum_probable_value( weights, n_connections) high = utility_calls.high(weights) if high is None: return abs(max_weight) return abs(min(max_weight, high)) elif isinstance(weights, str): d = self._get_distances(weights, synapse_info) return numpy.max(_expr_context.eval(weights, d=d)) elif numpy.isscalar(weights): return abs(weights) elif hasattr(weights, "__getitem__"): return numpy.amax(numpy.abs(weights)) raise SpynnakerException("Unrecognised weight format")
def _get_weight_maximum(weights, n_connections, connection_slices): """ Get the maximum of the weights """ if globals_variables.get_simulator().is_a_pynn_random(weights): mean_weight = utility_calls.get_mean(weights) if mean_weight < 0: min_weight = utility_calls.get_minimum_probable_value( weights, n_connections) if weights.boundaries is not None: return abs(max(min_weight, min(weights.boundaries))) return abs(min_weight) else: max_weight = utility_calls.get_maximum_probable_value( weights, n_connections) if weights.boundaries is not None: return abs(min(max_weight, max(weights.boundaries))) return abs(max_weight) elif numpy.isscalar(weights): return abs(weights) elif hasattr(weights, "__getitem__"): return numpy.amax([ numpy.abs(weights[connection_slice]) for connection_slice in connection_slices ]) raise Exception("Unrecognised weight format")
def _get_weight_maximum(weights, n_connections, connection_slices): """ Get the maximum of the weights """ if isinstance(weights, RandomDistribution): mean_weight = utility_calls.get_mean(weights) if mean_weight < 0: min_weight = utility_calls.get_minimum_probable_value( weights, n_connections) if weights.boundaries is not None: return abs(max(min_weight, min(weights.boundaries))) return abs(min_weight) else: max_weight = utility_calls.get_maximum_probable_value( weights, n_connections) if weights.boundaries is not None: return abs(min(max_weight, max(weights.boundaries))) return abs(max_weight) elif numpy.isscalar(weights): return abs(weights) elif hasattr(weights, "__getitem__"): return numpy.amax([ numpy.abs(weights[connection_slice]) for connection_slice in connection_slices]) raise Exception("Unrecognised weight format")
def _get_weight_maximum(self, weights, n_connections): """ Get the maximum of the weights. """ if get_simulator().is_a_pynn_random(weights): mean_weight = utility_calls.get_mean(weights) if mean_weight < 0: min_weight = utility_calls.get_minimum_probable_value( weights, n_connections) low = utility_calls.low(weights) if low is None: return abs(min_weight) return abs(max(min_weight, low)) else: max_weight = utility_calls.get_maximum_probable_value( weights, n_connections) high = utility_calls.high(weights) if high is None: return abs(max_weight) return abs(min(max_weight, high)) elif numpy.isscalar(weights): return abs(weights) elif hasattr(weights, "__getitem__"): return numpy.amax(numpy.abs(weights)) raise Exception("Unrecognised weight format")
def _get_weight_maximum(weights, n_connections, connection_slices): """ Get the maximum of the weights """ if isinstance(weights, RandomDistribution): mean_weight = utility_calls.get_mean(weights) if mean_weight < 0: min_weight = utility_calls.get_minimum_probable_value( weights, n_connections) if weights.boundaries is not None: return abs(max(min_weight, min(weights.boundaries))) return abs(min_weight) else: max_weight = utility_calls.get_maximum_probable_value( weights, n_connections) if weights.boundaries is not None: return abs(min(max_weight, max(weights.boundaries))) return abs(max_weight) elif numpy.isscalar(weights): return weights elif hasattr(weights, "__getitem__"): return numpy.amax([ weights[connection_slice] for connection_slice in connection_slices ]) raise Exception("Unrecognised weight format")