Run D8 flow direction
557251
def d8flowdir(np, filleddem, flowdir, slope, workingdir=None, mpiexedir=None, exedir=None,
                  log_file=None, runtime_file=None, hostfile=None):
        """"""
        fname = TauDEM.func_name('d8flowdir')
        return TauDEM.run(FileClass.get_executable_fullpath(fname, exedir),
                          {'-fel': filleddem}, workingdir,
                          None,
                          {'-p': flowdir, '-sd8': slope},
                          {'mpipath': mpiexedir, 'hostfile': hostfile, 'n': np},
                          {'logfile': log_file, 'runtimefile': runtime_file})
892235
def pass_outflow_v1(self):
    """"""
    flu = self.sequences.fluxes.fastaccess
    out = self.sequences.outlets.fastaccess
    out.q[0] += flu.outflow
803458
function ( index, direction, router ) {
			var current = F.current;

			if (!current) {
				return;
			}

			index = getScalar(index);

			F.direction = direction || current.direction[ (index >= current.index ? 'next' : 'prev') ];
			F.router    = router || 'jumpto';

			if (current.loop) {
				if (index < 0) {
					index = current.group.length + (index % current.group.length);
				}

				index = index % current.group.length;
			}

			if (current.group[ index ] !== undefined) {
				F.cancel();

				F._start(index);
			}
		}
1334309
def dcpf(self):
        
        dae = self.system.dae

        self.system.Bus.init0(dae)
        self.system.dae.init_g()

        Va0 = self.system.Bus.angle
        for model, pflow, gcall in zip(self.system.devman.devices, self.system.call.pflow, self.system.call.gcall):
            if pflow and gcall:
                self.system.__dict__[model].gcall(dae)

        sw = self.system.SW.a
        sw.sort(reverse=True)
        no_sw = self.system.Bus.a[:]
        no_swv = self.system.Bus.v[:]

        for item in sw:
            no_sw.pop(item)
            no_swv.pop(item)

        Bp = self.system.Line.Bp[no_sw, no_sw]
        p = matrix(self.system.dae.g[no_sw], (no_sw.__len__(), 1))
        p = p-self.system.Line.Bp[no_sw, sw]*Va0[sw]

        Sp = self.solver.symbolic(Bp)
        N = self.solver.numeric(Bp, Sp)
        self.solver.solve(Bp, Sp, N, p)
        self.system.dae.y[no_sw] = p

        self.solved = True
        self.niter = 1

        return self.solved, self.niter
850598
private static final void divmod(byte[] q, byte[] r, int n, byte[] d, int t) {
		int rn = 0;
		int dt = ((d[t-1] & 0xFF) << 8);
		if (t>1) {
			dt |= (d[t-2] & 0xFF);
		}
		while (n-- >= t) {
			int z = (rn << 16) | ((r[n] & 0xFF) << 8);
			if (n>0) {
				z |= (r[n-1] & 0xFF);
			}
			z/=dt;
			rn += mula_small(r,r, n-t+1, d, t, -z);
			q[n-t+1] = (byte)((z + rn) & 0xFF); /* rn is 0 or -1 (underflow) */
			mula_small(r,r, n-t+1, d, t, -rn);
			rn = (r[n] & 0xFF);
			r[n] = 0;
		}
		r[t-1] = (byte)rn;
	}
734057
def dinf_downslope_direction(a):
        
        taud, d = DinfUtil.check_orthogonal(a)
        if d != -1:
            down = [d]
            return down
        else:
            if a < FlowModelConst.ne:  # 129 = 1+128
                down = [1, 2]
            elif a < FlowModelConst.n:  # 192 = 128+64
                down = [2, 3]
            elif a < FlowModelConst.nw:  # 96 = 64+32
                down = [3, 4]
            elif a < FlowModelConst.w:  # 48 = 32+16
                down = [4, 5]
            elif a < FlowModelConst.sw:  # 24 = 16+8
                down = [5, 6]
            elif a < FlowModelConst.s:  # 12 = 8+4
                down = [6, 7]
            elif a < FlowModelConst.se:  # 6 = 4+2
                down = [7, 8]
            else:  # 3 = 2+1
                down = [8, 1]
            return down
1340169
function divmod (q, r, n, d, t) {
        n = n | 0;
        t = t | 0;

        var rn = 0;
        var dt = (d[t - 1] & 0xFF) << 8;
        if (t > 1)
            dt |= (d[t - 2] & 0xFF);

        while (n-- >= t) {
            var z = (rn << 16) | ((r[n] & 0xFF) << 8);
            if (n > 0)
                z |= (r[n - 1] & 0xFF);

            var i = n - t + 1;
            z /= dt;
            rn += mula_small(r, r, i, d, t, -z);
            q[i] = (z + rn) & 0xFF;
            /* rn is 0 or -1 (underflow) */
            mula_small(r, r, i, d, t, -rn);
            rn = r[n] & 0xFF;
            r[n] = 0;
        }

        r[t-1] = rn & 0xFF;
    }
1167630
function(d) {
          var i = d3.interpolate(this._current, d);
          this._current = i(0);
          return function(t) {
            return 'translate(' + arc.centroid(i(t)) + ') rotate(' + labelAngle(d) + ')';
          };
        }
1080530
def _jitter(c, magnitude:uniform):
    ""
    c.flow.add_((torch.rand_like(c.flow)-0.5)*magnitude*2)
    return c
600470
def compute_flows(self):
        
        system = self.system
        config = self.config
        dae = system.dae

        if config.compute_flows:
            # compute and append series injections on buses

            exec(system.call.bus_injection)
            bus_inj = dae.g[:2 * system.Bus.n]

            exec(system.call.seriesflow)
            system.Area.seriesflow(system.dae)
            system.Area.interchange_varout()
            dae.y = matrix([
                dae.y, bus_inj, system.Line._line_flows, system.Area.inter_varout
            ])
385563
def run_all(self, direction):
        
        for key in sorted(migration_registry.keys):
            self.run(key, direction)
984397
def on_for_degrees(self, steering, speed, degrees, brake=True, block=True):
        
        (left_speed, right_speed) = self.get_speed_steering(steering, speed)
        MoveTank.on_for_degrees(self, SpeedNativeUnits(left_speed), SpeedNativeUnits(right_speed), degrees, brake, block)
1295116
protected void drawDashedLine(final Context2D context, double x, double y, final double x2, final double y2, final double[] da, final double plus)
    {
        final int dashCount = da.length;

        final double dx = (x2 - x);

        final double dy = (y2 - y);

        final boolean xbig = (Math.abs(dx) > Math.abs(dy));

        final double slope = (xbig) ? dy / dx : dx / dy;

        context.moveTo(x, y);

        double distRemaining = Math.sqrt((dx * dx) + (dy * dy)) + plus;

        int dashIndex = 0;

        while (distRemaining >= 0.1)
        {
            final double dashLength = Math.min(distRemaining, da[dashIndex % dashCount]);

            double step = Math.sqrt((dashLength * dashLength) / (1 + (slope * slope)));

            if (xbig)
            {
                if (dx < 0)
                {
                    step = -step;
                }
                x += step;

                y += slope * step;
            }
            else
            {
                if (dy < 0)
                {
                    step = -step;
                }
                x += slope * step;

                y += step;
            }
            if ((dashIndex % 2) == 0)
            {
                context.lineTo(x, y);
            }
            else
            {
                context.moveTo(x, y);
            }
            distRemaining -= dashLength;

            dashIndex++;
        }
    }
1294847
def run(self):
        """"""
        last_status = ''
        # lambda is used to avoid http://bugs.python.org/issue30473 in py36
        start_times = defaultdict(lambda: datetime.datetime.now())
        max_stage_id = -1

        status = self.sc.statusTracker()
        while True:
            with self.condition:
                if self.sc._jsc is None or not self.alive:
                    # End the thread
                    self.paused = True
                    break
                elif self.paused:
                    # Pause the thread
                    self.condition.wait()
            stage_ids = status.getActiveStageIds()
            progressbar_list = []
            # Only show first 3
            stage_counter = 0
            current_max_stage = max_stage_id
            for stage_id in stage_ids:
                stage_info = status.getStageInfo(stage_id)
                if stage_info and stage_info.numTasks > 0:
                    # Set state variables used for flushing later
                    current_max_stage = stage_id
                    stage_counter += 1
                    td = datetime.datetime.now() - start_times[stage_id]
                    s = _format_stage_info(self.bar_width, stage_info, td, self.timedelta_formatter)
                    progressbar_list.append(s)
                if stage_counter == 3:
                    break

            # Ensure that when we get a new maximum stage id we print a \n
            # to make the progress bar go on to the next line.
            if current_max_stage > max_stage_id:
                if last_status != '':
                    sys.stderr.write("\n")
                sys.stderr.flush()
                max_stage_id = current_max_stage

            new_status = ' '.join(progressbar_list)
            if new_status != last_status:
                sys.stderr.write("\r" + new_status)
                sys.stderr.flush()
                last_status = new_status
            time.sleep(self.sleep_time)
304668
def run(self, **options):
        """"""
        if not self.is_setup:
            self.setup()

        if self.twisted:
            self.run_with_twisted(**options)
        elif self.gunicorn:
            self.run_with_gunicorn(**options)
        else:
            self.run_with_werkzeug(**options)
1028120
function Flow(flowControlId) {
  Duplex.call(this, { objectMode: true });

  this._window = this._initialWindow = INITIAL_WINDOW_SIZE;
  this._flowControlId = flowControlId;
  this._queue = [];
  this._ended = false;
  this._received = 0;
  this._blocked = false;
}
1160943
def handleFlow(self):
        
        #TODO replace sorting loops with sorted function
        self.targets = {}
        self.api = []
        #flow = []
        
        addrs = []
        internals = []
        
        for instr in self.bb_insns:
            if isinstance(instr, CallInsn):
                if instr.is_api:
                    self.targets[instr.addr] = "API:" + instr.fcn_name
                    
                    self.api.append({"name": instr.fcn_name})
                else:
                    internals.append(instr.addr)
                    
            else:
                if instr.jumpout:
                    internals.append(instr.addr)
                else:
                    addrs.append(instr.addr)
                    addrs.append(instr.offset)
        
        addrs.sort()
        addrs_dict = {}
        for i in range(len(addrs)):
            addrs_dict[addrs[i]] = i
        
        internals_sorted = internals[:]
        internals_sorted.sort()
        calleds_dict = {}
        for i in range(len(internals_sorted)):
            calleds_dict[internals_sorted[i]] = str(i)
            
        flowhash = datasketch.MinHash(num_perm=32)
        
        for instr in self.bb_insns:
            if isinstance(instr, CallInsn):
                if instr.is_api:
                    #flow.append(hex(instr.offset)+"  API:" + instr.fcn_name)
                    flowhash.update("API:" + instr.fcn_name)
                else:
                    #flow.append(hex(instr.offset)+"  OUT:" + calleds_dict[instr.addr])
                    flowhash.update("OUT:" + calleds_dict[instr.addr])
                    self.targets[instr.addr] = "OUT:" + calleds_dict[instr.addr]
            else:
                if instr.jumpout:
                    #flow.append(hex(instr.offset)+"  OUT:" + calleds_dict[instr.addr])
                    flowhash.update("OUT:" + calleds_dict[instr.addr])
                    self.targets[instr.addr] = "OUT:" + calleds_dict[instr.addr]
                else:
                    off = addrs_dict[instr.offset]
                    tgt = addrs_dict[instr.addr]
                    #flow.append("%x (%d)   JMP:%s   - %x (%d)" % (instr.offset, off, str(tgt - off), instr.addr, tgt))
                    flowhash.update("JMP:" + str(tgt - off))
                    self.targets[instr.addr] = "JMP:" + str(tgt - off)
        
        lean_flowhash = datasketch.LeanMinHash(flowhash)
        flowhash_buf = bytearray(lean_flowhash.bytesize())
        lean_flowhash.serialize(flowhash_buf)
        
        self.flowhash = str(flowhash_buf)
        '''
        
        '''