pypet/parameter.py
def _store(self):
        """Creates a storage dictionary for the storage service.

        If the data is not a supported sparse matrix, the
        :func:`~pypet.parameter.ArrayParmater._store` method of the parent class is called.

        Otherwise the matrix is split into parts with
        :func:`~pypet.parameter.SparseParameter._serialize_matrix` and these are named
        'data__spsp__XXXX' where 'XXXX' is a particular property of the matrix.

        The exploration range is handled similar as in the parent class. Yet, the matrices
        are split into the relevant parts and each part is stored as
        'xspm__spsp__XXXX__spsp__XXXXXXXX` where the first 'XXXX' refer to the property and
        the latter 'XXXXXXX' to the sparse matrix index.

        The :class:`~pypet.parameter.ObjectTable` `explored_data__spsp__` stores the order
        of the matrices and whether the corresponding matrix is dia or not.

        """
        if not self._is_supported_matrix(self._data):
            return super(SparseParameter, self)._store()
        else:
            store_dict = {}
            data_list, name_list, hash_tuple = self._serialize_matrix(self._data)
            rename_list = ['data%s%s' % (SparseParameter.IDENTIFIER, name)
                           for name in name_list]

            is_dia = int(len(rename_list) == 4)
            store_dict['data%sis_dia' % SparseParameter.IDENTIFIER] = is_dia

            for idx, name in enumerate(rename_list):
                store_dict[name] = data_list[idx]

            if self.f_has_range():
                # # Supports smart storage by hashing
                smart_dict = {}

                store_dict['explored_data' + SparseParameter.IDENTIFIER] = \
                    ObjectTable(columns=['idx', 'is_dia'],
                                index=list(range(len(self))))

                count = 0
                for idx, elem in enumerate(self._explored_range):

                    data_list, name_list, hash_tuple = self._serialize_matrix(elem)

                    # Use the hash_tuple as a key for the smart_dict
                    if hash_tuple in smart_dict:
                        name_idx = smart_dict[hash_tuple]
                        add = False
                    else:
                        name_idx = count
                        add = True

                    is_dia = int(len(name_list) == 4)
                    rename_list = self._build_names(name_idx, is_dia)

                    store_dict['explored_data' + SparseParameter.IDENTIFIER]['idx'][idx] = name_idx

                    store_dict['explored_data' + SparseParameter.IDENTIFIER]['is_dia'][
                        idx] = is_dia

                    if add:

                        for irun, name in enumerate(rename_list):
                            store_dict[name] = data_list[irun]

                        smart_dict[hash_tuple] = name_idx
                        count += 1

            self._locked = True

            return store_dict
def _store(self):
        """Creates a storage dictionary for the storage service.

        If the data is not a supported sparse matrix, the
        :func:`~pypet.parameter.ArrayParmater._store` method of the parent class is called.

        Otherwise the matrix is split into parts with
        :func:`~pypet.parameter.SparseParameter._serialize_matrix` and these are named
        'data__spsp__XXXX' where 'XXXX' is a particular property of the matrix.

        The exploration range is handled similar as in the parent class. Yet, the matrices
        are split into the relevant parts and each part is stored as
        'xspm__spsp__XXXX__spsp__XXXXXXXX` where the first 'XXXX' refer to the property and
        the latter 'XXXXXXX' to the sparse matrix index.

        The :class:`~pypet.parameter.ObjectTable` `explored_data__spsp__` stores the order
        of the matrices and whether the corresponding matrix is dia or not.

        """
        if not self._is_supported_matrix(self._data):
            return super(SparseParameter, self)._store()
        else:
            store_dict = {}
            data_list, name_list, hash_tuple = self._serialize_matrix(self._data)
            rename_list = ['data%s%s' % (SparseParameter.IDENTIFIER, name)
                           for name in name_list]

            is_dia = int(len(rename_list) == 4)
            store_dict['data%sis_dia' % SparseParameter.IDENTIFIER] = is_dia

            for idx, name in enumerate(rename_list):
                store_dict[name] = data_list[idx]

            if self.f_has_range():
                # # Supports smart storage by hashing
                smart_dict = {}

                store_dict['explored_data' + SparseParameter.IDENTIFIER] = \
                    ObjectTable(columns=['idx', 'is_dia'],
                                index=list(range(len(self))))

                count = 0
                for idx, elem in enumerate(self._explored_range):

                    data_list, name_list, hash_tuple = self._serialize_matrix(elem)

                    # Use the hash_tuple as a key for the smart_dict
                    if hash_tuple in smart_dict:
                        name_idx = smart_dict[hash_tuple]
                        add = False
                    else:
                        name_idx = count
                        add = True

                    is_dia = int(len(name_list) == 4)
                    rename_list = self._build_names(name_idx, is_dia)

                    store_dict['explored_data' + SparseParameter.IDENTIFIER]['idx'][idx] = name_idx

                    store_dict['explored_data' + SparseParameter.IDENTIFIER]['is_dia'][
                        idx] = is_dia

                    if add:

                        for irun, name in enumerate(rename_list):
                            store_dict[name] = data_list[irun]

                        smart_dict[hash_tuple] = name_idx
                        count += 1

            self._locked = True

            return store_dict
def _store ( self ) : if not self . _is_supported_matrix ( self . _data ) : return super ( SparseParameter , self ) . _store ( ) else : store_dict = { } data_list , name_list , hash_tuple = self . _serialize_matrix ( self . _data ) rename_list = [ 'data%s%s' % ( SparseParameter . IDENTIFIER , name ) for name in name_list ] is_dia = int ( len ( rename_list ) == 4 ) store_dict [ 'data%sis_dia' % SparseParameter . IDENTIFIER ] = is_dia for idx , name in enumerate ( rename_list ) : store_dict [ name ] = data_list [ idx ] if self . f_has_range ( ) : # # Supports smart storage by hashing smart_dict = { } store_dict [ 'explored_data' + SparseParameter . IDENTIFIER ] = ObjectTable ( columns = [ 'idx' , 'is_dia' ] , index = list ( range ( len ( self ) ) ) ) count = 0 for idx , elem in enumerate ( self . _explored_range ) : data_list , name_list , hash_tuple = self . _serialize_matrix ( elem ) # Use the hash_tuple as a key for the smart_dict if hash_tuple in smart_dict : name_idx = smart_dict [ hash_tuple ] add = False else : name_idx = count add = True is_dia = int ( len ( name_list ) == 4 ) rename_list = self . _build_names ( name_idx , is_dia ) store_dict [ 'explored_data' + SparseParameter . IDENTIFIER ] [ 'idx' ] [ idx ] = name_idx store_dict [ 'explored_data' + SparseParameter . IDENTIFIER ] [ 'is_dia' ] [ idx ] = is_dia if add : for irun , name in enumerate ( rename_list ) : store_dict [ name ] = data_list [ irun ] smart_dict [ hash_tuple ] = name_idx count += 1 self . _locked = True return store_dict
Creates a storage dictionary for the storage service.

        If the data is not a supported sparse matrix, the
        :func:`~pypet.parameter.ArrayParmater._store` method of the parent class is called.

        Otherwise the matrix is split into parts with
        :func:`~pypet.parameter.SparseParameter._serialize_matrix` and these are named
        'data__spsp__XXXX' where 'XXXX' is a particular property of the matrix.

        The exploration range is handled similar as in the parent class. Yet, the matrices
        are split into the relevant parts and each part is stored as
        'xspm__spsp__XXXX__spsp__XXXXXXXX` where the first 'XXXX' refer to the property and
        the latter 'XXXXXXX' to the sparse matrix index.

        The :class:`~pypet.parameter.ObjectTable` `explored_data__spsp__` stores the order
        of the matrices and whether the corresponding matrix is dia or not.
Creates a storage dictionary for the storage service .