def connect_from_file(self, filename): """ Builds a connection pattern using data saved using the Projection.save_connectivity() method (not save()!). *Parameters*: * **filename**: file where the data was saved. .. note:: Only the ranks, weights and delays are loaded, not the other variables. """ # Create an empty CSR object csr = Connector.CSR() # Load the data from ANNarchy.core.IO import _load_data try: data = _load_data(filename) except Exception as e: Global._print(e) Global._error('connect_from_file(): Unable to load the data', filename, 'into the projection.') exit(0) # Load the CSR object try: csr.post_rank = data['post_ranks'] csr.pre_rank = data['pre_ranks'] if isinstance(data['w'], (int, float)): self._single_constant_weight = True csr.w = [[data['w']]] else: csr.w = data['w'] csr.size = data['size'] csr.nb_synapses = data['nb_synapses'] if data['delay']: csr.delay = data['delay'] csr.max_delay = data['max_delay'] csr.uniform_delay = data['uniform_delay'] except Exception as e: Global._print(e) Global._error('Unable to load the data', filename, 'into the projection.') exit(0) # Store the synapses self.connector_name = "From File" self.connector_description = "From File" self._store_connectivity( self._load_from_csr, (csr, ), csr.max_delay if csr.uniform_delay > -1 else csr.delay) return self
def connect_from_file(self, filename): """ Builds a connection pattern using data saved using the Projection.save_connectivity() method (not save()!). *Parameters*: * **filename**: file where the data was saved. .. note:: Only the ranks, weights and delays are loaded, not the other variables. """ # Create an empty CSR object csr = Connector.CSR() # Load the data from ANNarchy.core.IO import _load_data try: data = _load_data(filename) except Exception as e: Global._print(e) Global._error('connect_from_file(): Unable to load the data', filename, 'into the projection.') exit(0) # Load the CSR object try: csr.post_rank = data['post_ranks'] csr.pre_rank = data['pre_ranks'] if isinstance(data['w'], (int, float)): self._single_constant_weight = True csr.w = [[data['w']]] else: csr.w = data['w'] csr.size = data['size'] csr.nb_synapses = data['nb_synapses'] if data['delay']: csr.delay = data['delay'] csr.max_delay = data['max_delay'] csr.uniform_delay = data['uniform_delay'] except Exception as e: Global._print(e) Global._error('Unable to load the data', filename, 'into the projection.') exit(0) # Store the synapses self.connector_name = "From File" self.connector_description = "From File" self._store_connectivity(self._load_from_csr, (csr,), csr.max_delay if csr.uniform_delay > -1 else csr.delay) return self
def load(self, filename): """ Loads the saved state of the projection. Warning: Matlab data can not be loaded. *Parameters*: * **filename**: the filename with relative or absolute path. Example:: proj.load('pop1.txt') """ from ANNarchy.core.IO import _load_data, _load_proj_data _load_proj_data(self, _load_data(filename))
def load(self, filename): """ Load the saved state of the population. Warning: Matlab data can not be loaded. *Parameters*: * **filename**: the filename with relative or absolute path. Example:: pop.load('pop1.txt') """ from ANNarchy.core.IO import _load_data, _load_pop_data _load_pop_data(self, _load_data(filename))
def load(self, filename): """ Load the saved state of the population by `Population.save()`. Warning: Matlab data can not be loaded. Example: ```python pop.load('pop1.npz') pop.load('pop1.txt') pop.load('pop1.txt.gz') ``` :param filename: the filename with relative or absolute path. """ from ANNarchy.core.IO import _load_data self._load_pop_data(_load_data(filename))
def load(self, filename): """ Loads the saved state of the projection by `Projection.save()`. Warning: Matlab data can not be loaded. *Parameters*: * **filename**: the file name with relative or absolute path. Example:: proj.load('proj1.npz') proj.load('proj1.txt') proj.load('proj1.txt.gz') """ from ANNarchy.core.IO import _load_data self._load_proj_data(_load_data(filename))
def connect_from_file(self, filename): """ Builds the connectivity matrix using data saved using the Projection.save_connectivity() method (not save()!). Admissible file formats are compressed Numpy files (.npz), gunzipped binary text files (.gz) or binary text files. *Parameters*: * **filename**: file where the connections were saved. .. note:: Only the ranks, weights and delays are loaded, not the other variables. """ # Create an empty LIL object lil = LILConnectivity() # Load the data from ANNarchy.core.IO import _load_data try: data = _load_data(filename) except Exception as e: Global._print(e) Global._error('connect_from_file(): Unable to load the data', filename, 'into the projection.') # Load the LIL object try: # Size lil.size = data['size'] lil.nb_synapses = data['nb_synapses'] # Ranks lil.post_rank = list(data['post_ranks']) lil.pre_rank = list(data['pre_ranks']) # Weights if isinstance(data['w'], (int, float)): self._single_constant_weight = True lil.w = [[float(data['w'])]] elif isinstance(data['w'], (np.ndarray,)) and data['w'].size == 1: self._single_constant_weight = True lil.w = [[float(data['w'])]] else: lil.w = data['w'] # Delays if data['delay']: lil.delay = data['delay'] lil.max_delay = data['max_delay'] lil.uniform_delay = data['uniform_delay'] except Exception as e: Global._print(e) Global._error('Unable to load the data', filename, 'into the projection.') # Store the synapses self.connector_name = "From File" self.connector_description = "From File" self._store_connectivity(self._load_from_lil, (lil,), lil.max_delay if lil.uniform_delay > 0 else lil.delay) return self