Integrate the snapshot using a direct force summation method \
        written entirely in python
185038
def _integrate_direct_python(self,t,pot,**kwargs):
        """"""
        #Prepare input for direct_nbody
        q= []
        p= []
        nq= len(self.orbits)
        dim= self.orbits[0].dim()
        if pot is None:
            thispot= None
        elif dim == 2:
            thispot= RZToplanarPotential(pot)
        else:
            thispot= pot
        for ii in range(nq):
            #Transform to rectangular frame
            if dim == 1:
                thisq= nu.array([self.orbits[ii].x()]).flatten()
                thisp= nu.array([self.orbits[ii].vx()]).flatten()
            elif dim == 2:
                thisq= nu.array([self.orbits[ii].x(),
                                 self.orbits[ii].y()]).flatten()
                thisp= nu.array([self.orbits[ii].vx(),
                                 self.orbits[ii].vy()]).flatten()
            elif dim == 3:
                thisq= nu.array([self.orbits[ii].x(),
                                 self.orbits[ii].y(),
                                 self.orbits[ii].z()]).flatten()
                thisp= nu.array([self.orbits[ii].vx(),
                                 self.orbits[ii].vy(),
                                 self.orbits[ii].vz()]).flatten()
            q.append(thisq)
            p.append(thisp)
        #Run simulation
        nbody_out= direct_nbody(q,p,self.masses,t,pot=thispot,**kwargs)
        #Post-process output
        nt= len(nbody_out)
        out= []
        for ii in range(nt):
            snap_orbits= []
            for jj in range(nq):
                if dim == 3:
                    #go back to the cylindrical frame
                    R= nu.sqrt(nbody_out[ii][0][jj][0]**2.
                               +nbody_out[ii][0][jj][1]**2.)
                    phi= nu.arccos(nbody_out[ii][0][jj][0]/R)
                    if nbody_out[ii][0][jj][1] < 0.: phi= 2.*nu.pi-phi
                    vR= nbody_out[ii][1][jj][0]*nu.cos(phi)\
                        +nbody_out[ii][1][jj][1]*nu.sin(phi)
                    vT= nbody_out[ii][1][jj][1]*nu.cos(phi)\
                        -nbody_out[ii][1][jj][0]*nu.sin(phi)
                    vxvv= nu.zeros(dim*2)
                    vxvv[3]= nbody_out[ii][0][jj][2]
                    vxvv[4]= nbody_out[ii][1][jj][2]
                    vxvv[0]= R
                    vxvv[1]= vR
                    vxvv[2]= vT
                    vxvv[5]= phi
                if dim == 2:
                    #go back to the cylindrical frame
                    R= nu.sqrt(nbody_out[ii][0][jj][0]**2.
                               +nbody_out[ii][0][jj][1]**2.)
                    phi= nu.arccos(nbody_out[ii][0][jj][0]/R)
                    if nbody_out[ii][0][jj][1] < 0.: phi= 2.*nu.pi-phi
                    vR= nbody_out[ii][1][jj][0]*nu.cos(phi)\
                        +nbody_out[ii][1][jj][1]*nu.sin(phi)
                    vT= nbody_out[ii][1][jj][1]*nu.cos(phi)\
                        -nbody_out[ii][1][jj][0]*nu.sin(phi)
                    vxvv= nu.zeros(dim*2)
                    vxvv[0]= R
                    vxvv[1]= vR
                    vxvv[2]= vT
                    vxvv[3]= phi
                if dim == 1:
                    vxvv= [nbody_out[ii][0][jj],nbody_out[ii][1][jj]]
                snap_orbits.append(Orbit(vxvv))
            out.append(Snapshot(snap_orbits,self.masses))
        return out
1129129
def par_y0bstep(i):
    
    """

    global mp_Y0
    mp_Y0[i] = 1/mp_rho*mp_S + mp_DX[i] + mp_U0[i] + mp_b
592285
def subvol_snapshot(self, source, destination, read_only=False):
        

        args = {
            "source": source,
            "destination": destination,
            "read_only": read_only,
        }

        self._subvol_snapshot_chk.check(args)
        self._client.sync('btrfs.subvol_snapshot', args)
222471
private Map<File, File> getDataMap(int vcode, String[] dataDirs, String snapshotName) {
		Map<File, File> map = new HashMap<File, File>();

		Map<File, File[]> src = vcode==0 ? getDataMap_1_0(dataDirs) : getDataMap_1_1(dataDirs);
		for (File ks : src.keySet()) {
			File[] sn = src.get(ks);

			if (sn != null) {
				for (int i = 0; i < sn.length; i++) {
					if (snapshotName.equals(sn[i].getName())) {
						map.put(ks, sn[i]);
						break;
					}
				}
			}
		}

		return map;
	}
628336
def run_with_snapshots(self, tsnapstart=0., tsnapint=432000.):
        

        tsnapints = np.ceil(tsnapint/self.dt)

        while(self.t < self.tmax):
            self._step_forward()
            if self.t>=tsnapstart and (self.tc%tsnapints)==0:
                yield self.t
        return
851574
def update_sums(self, r, i, j, data1, data2, sum1, sum2, N=None, centers_sum=None):
        
        # the summation values for this (r,i,j)
        sum1_ij, sum2_ij = compute_sum_values(i, j, data1, data2)

        # digitize
        digr = self.digitize(r, i, j, data1, data2)

        if len(digr) == 3 and isinstance(digr[1], dict):
            dig, paircoords, weights = digr
        elif len(digr) == 2 and isinstance(digr[1], dict):
            dig, paircoords = digr
            weights = None
        else:
            dig = digr
            paircoords = None
            weights = None

        # sum 1
        def add_one_channel(sum1c, sum1_ijc):
            if numpy.isscalar(sum1_ijc) or sum1_ijc.ndim == 1:
                sum1c.flat[:] += utils.bincount(dig, sum1_ijc, minlength=sum1c.size)
            else:
                for d in range(sum1c.shape[0]):
                    sum1c[d].flat[:] += utils.bincount(dig, sum1_ijc[...,d], minlength=sum1c[d].size)

        if self.channels:
            if weights is None:
                raise RuntimeError("`digitize` of multi channel paircount did not return a weight array for the channels")

            sum1_ij = weights * sum1_ij
            # sum1_ij[ichannel, dig, dim]
            for ichannel in range(len(self.channels)):
                add_one_channel(sum1[ichannel], sum1_ij[ichannel])
        else:
            # sum1_ij[dig, dim]
            add_one_channel(sum1, sum1_ij)

        # sum 2, if both data are not points
        if not numpy.isscalar(sum2):
            sum2.flat[:] += utils.bincount(dig, sum2_ij, minlength=sum2.size)

        if N is not None:
            if not paircoords:
                raise RuntimeError("Bin center is requested but not returned by digitize")
            # update the mean coords
            self._update_mean_coords(dig, N, centers_sum, **paircoords)
277592
def snapshot_agents(self, force=False):
        ''''''
        for agent in self._agents:
            agent.check_if_should_snapshot(force)
893612
Map<SnapshotIdentifier, CdoSnapshot> calculate(List<CdoSnapshot> snapshots) {
        Map<SnapshotIdentifier, CdoSnapshot> previousSnapshots = new HashMap<>();
        populatePreviousSnapshotsWithSnapshots(previousSnapshots, snapshots);
        List<CdoSnapshot> missingPreviousSnapshots = getMissingPreviousSnapshots(snapshots, previousSnapshots);
        populatePreviousSnapshotsWithSnapshots(previousSnapshots, missingPreviousSnapshots);
        return previousSnapshots;
    }
795032
def execute(self, input_data):
        '''  '''

        # Aggregate the output from all the memory workers, clearly this could be kewler
        output = input_data['view_memory']
        output['tables'] = {}
        for data in [input_data[key] for key in ViewMemoryDeep.dependencies]:
            for name,table in data['tables'].iteritems():
                output['tables'].update({name: table})
        return output
91716
def _calc_obs_local(self,parensemble):
        '''
        
        '''
        self.logger.log("evaluating ensemble of size {0} locally with sweep".\
                        format(parensemble.shape[0]))
        parensemble.to_csv(self.sweep_in_csv)
        if self.num_slaves > 0:
            master_thread = self._get_master_thread()
            pyemu.utils.start_slaves(self.slave_dir,"pestpp-swp",self.pst.filename,
                                     self.num_slaves,slave_root='..',port=self.port)
            master_thread.join()
        else:
            os.system("pestpp-swp {0}".format(self.pst.filename))

        self.logger.log("evaluating ensemble of size {0} locally with sweep".\
                        format(parensemble.shape[0]))
1251811
def snapshot(name = nil, **kwords)
      # TODO: 1.0
      if name.nil? && !kwords.key?(:Name)
        # backwards compatible handling allows name to be passed though
        # kwords or the argument. Argument is preferred.
        raise ArgumentError, 'wrong number of arguments (given 0, expected 1)'
      end
      kwords[:Name] = name unless name.nil?
      response = connection.send(:post, "/repos/#{self.Name}/snapshots",
                                 body: JSON.generate(kwords))
      Aptly::Snapshot.new(::Aptly::Connection.new, JSON.parse(response.body))
    end
399871
def annotate_snapshot(self, snapshot):
        
        if hasattr(snapshot, 'classes'):
            return

        snapshot.classes = {}

        for classname in list(self.index.keys()):
            total = 0
            active = 0
            merged = Asized(0, 0)
            for tobj in self.index[classname]:
                _merge_objects(snapshot.timestamp, merged, tobj)
                total += tobj.get_size_at_time(snapshot.timestamp)
                if tobj.birth < snapshot.timestamp and \
                    (tobj.death is None or tobj.death > snapshot.timestamp):
                    active += 1

            try:
                pct = total * 100.0 / snapshot.total
            except ZeroDivisionError: # pragma: no cover
                pct = 0
            try:
                avg = total / active
            except ZeroDivisionError:
                avg = 0

            snapshot.classes[classname] = dict(sum=total,
                                               avg=avg,
                                               pct=pct,
                                               active=active)
            snapshot.classes[classname]['merged'] = merged
1004098
function(a, b, total) {
      if (a == 0) return b > 0 ? [b] : [];
      return $R(1, total).inject([], function(memo, i) {
        if (0 == (i - b) % a && (i - b) / a >= 0) memo.push(i);
        return memo;
      });
    }
1166694
def integrate(arr, ddim, dim=False, is_pressure=False):
    """"""
    if is_pressure:
        dim = vert_coord_name(ddim)
    return (arr*ddim).sum(dim=dim)
61450
def create_snapshot_chart(self, filename=''):
        
        try:
            from pylab import figure, title, xlabel, ylabel, plot, fill, legend, savefig
            import matplotlib.mlab as mlab
        except ImportError:
            return self.nopylab_msg % ("memory allocation")

        classlist = self.tracked_classes

        times = [snapshot.timestamp for snapshot in self.snapshots]
        base = [0] * len(self.snapshots)
        poly_labels = []
        polys = []
        for cn in classlist:
            pct = [snapshot.classes[cn]['pct'] for snapshot in self.snapshots]
            if max(pct) > 3.0:
                sz = [float(fp.classes[cn]['sum'])/(1024*1024) for fp in self.snapshots]
                sz = [sx+sy for sx, sy in zip(base, sz)]
                xp, yp = mlab.poly_between(times, base, sz)
                polys.append( ((xp, yp), {'label': cn}) )
                poly_labels.append(cn)
                base = sz

        figure()
        title("Snapshot Memory")
        xlabel("Execution Time [s]")
        ylabel("Virtual Memory [MiB]")

        sizes = [float(fp.asizeof_total)/(1024*1024) for fp in self.snapshots]
        plot(times, sizes, 'r--', label='Total')
        sizes = [float(fp.tracked_total)/(1024*1024) for fp in self.snapshots]
        plot(times, sizes, 'b--', label='Tracked total')

        for (args, kwds) in polys:
            fill(*args, **kwds)
        legend(loc=2)
        savefig(filename)

        return self.chart_tag % (self.relative_path(filename))
1155333
def create_snapshot(self, name, *args, **kwargs):
        
        return self.provider.create_snapshot(name, *args, **kwargs)
513502
def main(dbfile, pidfile, mode):
    '''
    
    '''
    Inspector(dbfile, pidfile).reuse_snapshot().snapshot(mode)