pypet/storageservice.py
def _prm_write_into_other_array(self, key, data, group, fullname,
                                    flag, **kwargs):
        """Stores data as carray, earray or vlarray depending on `flag`.

        :param key:

            Name of data item to store

        :param data:

            Data to store

        :param group:

            Group node where to store data in hdf5 file

        :param fullname:

            Full name of the `data_to_store`s original container, only needed for throwing errors.

        :param recall:

            If container type and data type for perfect recall should be stored

        :param flag:

            How to store:
                CARRAY, EARRAY, VLARRAY

        """
        try:

            if flag == HDF5StorageService.CARRAY:
                factory = self._hdf5file.create_carray
            elif flag == HDF5StorageService.EARRAY:
                factory = self._hdf5file.create_earray
            elif flag == HDF5StorageService.VLARRAY:
                factory = self._hdf5file.create_vlarray
            else:
                raise RuntimeError('You shall not pass!')

            if key in group:
                raise ValueError(
                    'CArray `%s` already exists in `%s`. Appending is not supported (yet).')

            if 'filters' in kwargs:
                filters = kwargs.pop('filters')
            else:
                filters = self._all_get_filters(kwargs)

            try:
                other_array = factory(where=group, name=key, obj=data,
                                                filters=filters, **kwargs)
            except (ValueError, TypeError) as exc:
                try:
                    conv_data = data[:]
                    conv_data = np.core.defchararray.encode(conv_data, self.encoding)
                    other_array = factory(where=group, name=key,
                                                obj=conv_data,
                                                filters=filters, **kwargs)
                except Exception:
                    # Re-raise original Error
                    raise exc

            if data is not None:
                # Remember the types of the original data to recall them on loading
                self._all_set_attributes_to_recall_natives(data, other_array,
                                                       HDF5StorageService.DATA_PREFIX)
            setattr(other_array._v_attrs, HDF5StorageService.STORAGE_TYPE, flag)
            self._hdf5file.flush()
        except:
            self._logger.error('Failed storing %s `%s` of `%s`.' % (flag, key, fullname))
            raise
def _prm_write_into_other_array(self, key, data, group, fullname,
                                    flag, **kwargs):
        try:

            if flag == HDF5StorageService.CARRAY:
                factory = self._hdf5file.create_carray
            elif flag == HDF5StorageService.EARRAY:
                factory = self._hdf5file.create_earray
            elif flag == HDF5StorageService.VLARRAY:
                factory = self._hdf5file.create_vlarray
            else:
                raise RuntimeError('You shall not pass!')

            if key in group:
                raise ValueError(
                    'CArray `%s` already exists in `%s`. Appending is not supported (yet).')

            if 'filters' in kwargs:
                filters = kwargs.pop('filters')
            else:
                filters = self._all_get_filters(kwargs)

            try:
                other_array = factory(where=group, name=key, obj=data,
                                                filters=filters, **kwargs)
            except (ValueError, TypeError) as exc:
                try:
                    conv_data = data[:]
                    conv_data = np.core.defchararray.encode(conv_data, self.encoding)
                    other_array = factory(where=group, name=key,
                                                obj=conv_data,
                                                filters=filters, **kwargs)
                except Exception:
                    # Re-raise original Error
                    raise exc

            if data is not None:
                # Remember the types of the original data to recall them on loading
                self._all_set_attributes_to_recall_natives(data, other_array,
                                                       HDF5StorageService.DATA_PREFIX)
            setattr(other_array._v_attrs, HDF5StorageService.STORAGE_TYPE, flag)
            self._hdf5file.flush()
        except:
            self._logger.error('Failed storing %s `%s` of `%s`.' % (flag, key, fullname))
            raise
def _prm_write_into_other_array ( self , key , data , group , fullname , flag , * * kwargs ) : try : if flag == HDF5StorageService . CARRAY : factory = self . _hdf5file . create_carray elif flag == HDF5StorageService . EARRAY : factory = self . _hdf5file . create_earray elif flag == HDF5StorageService . VLARRAY : factory = self . _hdf5file . create_vlarray else : raise RuntimeError ( 'You shall not pass!' ) if key in group : raise ValueError ( 'CArray `%s` already exists in `%s`. Appending is not supported (yet).' ) if 'filters' in kwargs : filters = kwargs . pop ( 'filters' ) else : filters = self . _all_get_filters ( kwargs ) try : other_array = factory ( where = group , name = key , obj = data , filters = filters , * * kwargs ) except ( ValueError , TypeError ) as exc : try : conv_data = data [ : ] conv_data = np . core . defchararray . encode ( conv_data , self . encoding ) other_array = factory ( where = group , name = key , obj = conv_data , filters = filters , * * kwargs ) except Exception : # Re-raise original Error raise exc if data is not None : # Remember the types of the original data to recall them on loading self . _all_set_attributes_to_recall_natives ( data , other_array , HDF5StorageService . DATA_PREFIX ) setattr ( other_array . _v_attrs , HDF5StorageService . STORAGE_TYPE , flag ) self . _hdf5file . flush ( ) except : self . _logger . error ( 'Failed storing %s `%s` of `%s`.' % ( flag , key , fullname ) ) raise
Stores data as carray, earray or vlarray depending on `flag`.

        :param key:

            Name of data item to store

        :param data:

            Data to store

        :param group:

            Group node where to store data in hdf5 file

        :param fullname:

            Full name of the `data_to_store`s original container, only needed for throwing errors.

        :param recall:

            If container type and data type for perfect recall should be stored

        :param flag:

            How to store:
                CARRAY, EARRAY, VLARRAY
Stores data as carray earray or vlarray depending on flag .