def _initialize(self, funs_to_tally, length):
        """
        Create a group named ``Chain#`` to store all data for this chain.
        The group contains one pyTables Table, and at least one subgroup
        called ``group#``. This subgroup holds ObjectAtoms, which can hold
        pymc objects whose value is not a numerical array.

        There is too much stuff in here. ObjectAtoms should get initialized
        """
        i = self.chains
        self._chains.append(
            self._h5file.create_group(
                "/",
                'chain%d' %
                i,
                'Chain #%d' %
                i))
        current_object_group = self._h5file.create_group(
            self._chains[-1],
            'group0',
            'Group storing objects.')
        group_counter = 0
        object_counter = 0

        # Create the Table in the chain# group, and ObjectAtoms in
        # chain#/group#.
        table_descr = {}
        for name, fun in six.iteritems(funs_to_tally):

            arr = asarray(fun())

            if arr.dtype is np.dtype('object'):

                self._traces[name]._vlarrays.append(self._h5file.create_vlarray(
                    current_object_group,
                    name,
                    tables.ObjectAtom(),
                    title=name + ' samples.',
                    filters=self.filter))

                object_counter += 1
                if object_counter % 4096 == 0:
                    group_counter += 1
                    current_object_group = self._h5file.create_group(
                        self._chains[-1],
                        'group%d' % group_counter, 'Group storing objects.')

            else:
                table_descr[name] = tables.Col.from_dtype(
                    dtype((arr.dtype, arr.shape)))

        table = self._h5file.create_table(self._chains[-1],
                                         'PyMCsamples',
                                         table_descr,
                                         title='PyMC samples',
                                         filters=self.filter,
                                         expectedrows=length)

        self._tables.append(table)
        self._rows.append(self._tables[-1].row)

        # Store data objects
        for object in self.model.observed_stochastics:
            if object.keep_trace is True:
                setattr(table.attrs, object.__name__, object.value)

       # Make sure the variables have a corresponding Trace instance.
        for name, fun in six.iteritems(funs_to_tally):
            if name not in self._traces:
                if np.array(fun()).dtype is np.dtype('object'):
                    self._traces[
                        name] = TraceObject(
                            name,
                            getfunc=fun,
                            db=self)
                else:
                    self._traces[name] = Trace(name, getfunc=fun, db=self)

            self._traces[name]._initialize(self.chains, length)

        self.trace_names.append(list(funs_to_tally.keys()))
        self.chains += 1
def _initialize ( self , funs_to_tally , length ) : i = self . chains self . _chains . append ( self . _h5file . create_group ( "/" , 'chain%d' % i , 'Chain #%d' % i ) ) current_object_group = self . _h5file . create_group ( self . _chains [ - 1 ] , 'group0' , 'Group storing objects.' ) group_counter = 0 object_counter = 0 table_descr = { } for name , fun in six . iteritems ( funs_to_tally ) : arr = asarray ( fun ( ) ) if arr . dtype is np . dtype ( 'object' ) : self . _traces [ name ] . _vlarrays . append ( self . _h5file . create_vlarray ( current_object_group , name , tables . ObjectAtom ( ) , title = name + ' samples.' , filters = self . filter ) ) object_counter += 1 if object_counter % 4096 == 0 : group_counter += 1 current_object_group = self . _h5file . create_group ( self . _chains [ - 1 ] , 'group%d' % group_counter , 'Group storing objects.' ) else : table_descr [ name ] = tables . Col . from_dtype ( dtype ( ( arr . dtype , arr . shape ) ) ) table = self . _h5file . create_table ( self . _chains [ - 1 ] , 'PyMCsamples' , table_descr , title = 'PyMC samples' , filters = self . filter , expectedrows = length ) self . _tables . append ( table ) self . _rows . append ( self . _tables [ - 1 ] . row ) for object in self . model . observed_stochastics : if object . keep_trace is True : setattr ( table . attrs , object . __name__ , object . value ) for name , fun in six . iteritems ( funs_to_tally ) : if name not in self . _traces : if np . array ( fun ( ) ) . dtype is np . dtype ( 'object' ) : self . _traces [ name ] = TraceObject ( name , getfunc = fun , db = self ) else : self . _traces [ name ] = Trace ( name , getfunc = fun , db = self ) self . _traces [ name ] . _initialize ( self . chains , length ) self . trace_names . append ( list ( funs_to_tally . keys ( ) ) ) self . chains += 1
Create a group named ``Chain#`` to store all data for this chain.
        The group contains one pyTables Table, and at least one subgroup
        called ``group#``. This subgroup holds ObjectAtoms, which can hold
        pymc objects whose value is not a numerical array.

        There is too much stuff in here. ObjectAtoms should get initialized