# Path: ANNarchy/core/Random.py
# class RandomDistribution(object):
#     """
#     BaseClass for random distributions.
#     """
# 
#     def get_values(self, shape):
#         """
#         Returns a np.ndarray with the given shape
#         """
#         Global._error('instantiated base class RandomDistribution is not allowed.')
#         return np.array([0.0])
# 
#     def get_list_values(self, size):
#         """
#         Returns a list of the given size.
#         """
#         return list(self.get_values(size))
# 
#     def get_value(self):
#         """
#         Returns a single float value.
#         """
#         return self.get_values(1)[0]
# 
#     def keywords(self):
#         return available_distributions
# 
#     def latex(self):
#         return '?'
#     
#     def get_cpp_args(self):
#         raise NotImplementedError


from ANNarchy.core import Global as Global
from .Random import RandomDistribution
        from ANNarchy.core.Neuron import IndividualNeuron
import numpy as np
            >>> subpop.set( {'tau' : 20, 'r'= np.random.rand(subpop.size) } )

        .. warning::

            If you modify the value of a global parameter, this will be the case for ALL neurons of the population, not only the subset.
        """
        def _set_single(name, rank, value):
            if not self.population.initialized:
                if not name in self.population.neuron_type.description['local']:
                    Global._error('can not set the value of a global attribute from a PopulationView.')
                    return

                if isinstance(self.population.init[name], np.ndarray):
                    if len(self.population.geometry) == 1:
                        self.population.init[name][rank] = value
                    else: # Need to access the coordinates
                        coords = self.population.coordinates_from_rank(rank)
                        self.population.init[name][coords] = value
                else:
                    val = self.population.init[name]
                    data = val * np.ones(self.population.size)
                    data[rank] = value
                    self.population.init[name] = data.reshape(self.population.geometry)
            else:
                ctype = self.population._get_attribute_cpp_type(name)
                self.population.cyInstance.set_local_attribute(name, rank, value, ctype)

        for val_key in value.keys():
            if hasattr(self.population, val_key):
                # Check the value

# Path: ANNarchy/core/Random.py
# class RandomDistribution(object):
#     """
#     BaseClass for random distributions.
#     """
# 
#     def get_values(self, shape):
#         """
#         Returns a np.ndarray with the given shape
#         """
#         Global._error('instantiated base class RandomDistribution is not allowed.')
#         return np.array([0.0])
# 
#     def get_list_values(self, size):
#         """
#         Returns a list of the given size.
#         """
#         return list(self.get_values(size))
# 
#     def get_value(self):
#         """
#         Returns a single float value.
#         """
#         return self.get_values(1)[0]
# 
#     def keywords(self):
#         return available_distributions
# 
#     def latex(self):
#         return '?'
#     
#     def get_cpp_args(self):
#         raise NotImplementedError


# Path: ANNarchy/core/PopulationView.py
from ANNarchy.core import Global as Global
from .Random import RandomDistribution
        from ANNarchy.core.Neuron import IndividualNeuron
import numpy as np

            >>> subpop.set( {'tau' : 20, 'r'= np.random.rand(subpop.size) } )

        .. warning::

            If you modify the value of a global parameter, this will be the case for ALL neurons of the population, not only the subset.
        """
        def _set_single(name, rank, value):
            if not self.population.initialized:
                if not name in self.population.neuron_type.description['local']:
                    Global._error('can not set the value of a global attribute from a PopulationView.')
                    return

                if isinstance(self.population.init[name], np.ndarray):
                    if len(self.population.geometry) == 1:
                        self.population.init[name][rank] = value
                    else: # Need to access the coordinates
                        coords = self.population.coordinates_from_rank(rank)
                        self.population.init[name][coords] = value
                else:
                    val = self.population.init[name]
                    data = val * np.ones(self.population.size)
                    data[rank] = value
                    self.population.init[name] = data.reshape(self.population.geometry)
            else:
                ctype = self.population._get_attribute_cpp_type(name)
                self.population.cyInstance.set_local_attribute(name, rank, value, ctype)

        for val_key in value.keys():
            if hasattr(self.population, val_key):
                # Check the value

                if isinstance(value[val_key], RandomDistribution): # Make sure it is generated only once