Return the Reynolds Number for a rectangular channel.
971504
def re_rect(FlowRate, Width, DistCenter, Nu, openchannel):
    """"""
    #Checking input validity - inputs not checked here are checked by
    #functions this function calls.
    ut.check_range([FlowRate, ">0", "Flow rate"], [Nu, ">0", "Nu"])
    return (4 * FlowRate
            * radius_hydraulic(Width, DistCenter, openchannel).magnitude
            / (Width * DistCenter * Nu))
531345
private int getSwipeDuration(MotionEvent ev, int velocity) {
        int sx = getScrollX();
        int dx = (int)(ev.getX() - sx);
        final int width = mSwipeCurrentHorizontal.getMenuWidth();
        final int halfWidth = width / 2;
        final float distanceRatio = Math.min(1f, 1.0f * Math.abs(dx) / width);
        final float distance = halfWidth + halfWidth * distanceInfluenceForSnapDuration(distanceRatio);
        int duration;
        if (velocity > 0) {
            duration = 4 * Math.round(1000 * Math.abs(distance / velocity));
        } else {
            final float pageDelta = (float)Math.abs(dx) / width;
            duration = (int)((pageDelta + 1) * 100);
        }
        duration = Math.min(duration, mScrollerDuration);
        return duration;
    }
444702
def get_vec_lr(self):
        """"""

        return self.width * self.cos_a(), -self.width * self.sin_a()
449164
def get_dimension(self):
        """"""
        if self.strokes > 0:
            if self.pixel_env > 0:
                return (2 + (1 + 2*self.pixel_env)**2) \
                    * self.strokes * self.points_per_stroke
            else:
                return 2*self.strokes * self.points_per_stroke
        else:
            if self.pen_down:
                return 3*self.points_per_stroke
            else:
                return 2*self.points_per_stroke
1130189
def flow_hagen(Diam, HeadLossFric, Length, Nu):
    """"""
    #Checking input validity
    ut.check_range([Diam, ">0", "Diameter"], [Length, ">0", "Length"],
                   [HeadLossFric, ">=0", "Headloss due to friction"],
                   [Nu, ">0", "Nu"])
    return (np.pi*Diam**4) / (128*Nu) * gravity.magnitude * HeadLossFric / Length
1321067
def drain_D(self):
        
        tank_A = 2 * self.channel_L * self.channel_W
        drain_D = (np.sqrt(8 * tank_A / (np.pi * self.drain_t) * np.sqrt(
           self.downstream_H * self.drain_K / (2 * u.standard_gravity)))).to_base_units()
        return drain_D
57972
def advect(f, vx, vy):
    """"""
    rows, cols = f.shape
    cell_xs, cell_ys = np.meshgrid(np.arange(cols), np.arange(rows))
    center_xs = (cell_xs - vx).ravel()
    center_ys = (cell_ys - vy).ravel()

    # Compute indices of source cells.
    left_ix = np.floor(center_ys).astype(int)
    top_ix  = np.floor(center_xs).astype(int)
    rw = center_ys - left_ix              # Relative weight of right-hand cells.
    bw = center_xs - top_ix               # Relative weight of bottom cells.
    left_ix  = np.mod(left_ix,     rows)  # Wrap around edges of simulation.
    right_ix = np.mod(left_ix + 1, rows)
    top_ix   = np.mod(top_ix,      cols)
    bot_ix   = np.mod(top_ix  + 1, cols)

    # A linearly-weighted sum of the 4 surrounding cells.
    flat_f = (1 - rw) * ((1 - bw)*f[left_ix,  top_ix] + bw*f[left_ix,  bot_ix]) \
                 + rw * ((1 - bw)*f[right_ix, top_ix] + bw*f[right_ix, bot_ix])
    return np.reshape(flat_f, (rows, cols))
1291390
def stout_w_per_flow(self, z):
        
        w_per_flow = 2 / ((2 * pc.gravity * z) ** (1 / 2) *
                          con.VC_ORIFICE_RATIO * np.pi * self.hl)
        return w_per_flow.to_base_units()
1296307
def shape(self):
        ""
        num = len(self)
        if num <= self._max_cols:
            return (1, num)
        nrows = num // self._max_cols
        last_row_cols = num % self._max_cols
        return nrows+(1 if last_row_cols else 0), min(num, self._max_cols)
279046
def X(self) -> Optional[Union[np.ndarray, sparse.spmatrix, ArrayView]]:
        """"""
        if self.isbacked:
            if not self.file.isopen: self.file.open()
            X = self.file['X']
            if self.isview:
                X = X[self._oidx, self._vidx]
            return X
        else:
            if self.n_obs == 1 and self.n_vars == 1:
                return self._X[0, 0]
            elif self.n_obs == 1 or self.n_vars == 1:
                X = self._X
                if issparse(self._X): X = self._X.toarray()
                return X.flatten()
            else:
                return self._X
1225571
def smooth_angle_channels(self, channels):
        """"""
        for vertex in self.vertices:
            for col in vertex.meta['rot_ind']:
                if col:
                    for k in range(1, channels.shape[0]):
                        diff=channels[k, col]-channels[k-1, col]
                    if abs(diff+360.)<abs(diff):
                        channels[k:, col]=channels[k:, col]+360.
                    elif abs(diff-360.)<abs(diff):
                        channels[k:, col]=channels[k:, col]-360.
939303
def fric_rect(FlowRate, Width, DistCenter, Nu, PipeRough, openchannel):
    """"""
    #Checking input validity - inputs not checked here are checked by
    #functions this function calls.
    ut.check_range([PipeRough, "0-1", "Pipe roughness"])
    if re_rect(FlowRate,Width,DistCenter,Nu,openchannel) >= RE_TRANSITION_PIPE:
        #Swamee-Jain friction factor adapted for rectangular channel.
        #Diam = 4*R_h in this case.
        return (0.25
                / (np.log10((PipeRough
                             / (3.7 * 4
                                * radius_hydraulic(Width, DistCenter,
                                                   openchannel).magnitude
                                )
                             )
                            + (5.74 / (re_rect(FlowRate, Width, DistCenter,
                                               Nu, openchannel) ** 0.9)
                               )
                            )
                    ) ** 2
                )
    else:
        return 64 / re_rect(FlowRate, Width, DistCenter, Nu, openchannel)
1307321
def channel_view(x:Tensor)->Tensor:
    ""
    return x.transpose(0,1).contiguous().view(x.shape[1],-1)
115440
def sd(self):
        ''''''
        v = self.var()
        if len(v):
            return np.sqrt(v)
        else:
            return None
68948
def baffle_S(self):
        
        return ((self.BAFFLE_K /
                ((2 * self.expansion_H * (self.vel_grad_avg ** 2) *
                 pc.viscosity_kinematic(self.temp))).to_base_units()) ** (1/3) *
               self.Q / self.channel_W).to(u.cm)
1336151
def getRect(self):
		
		return (self.x, self.y, self.w, self.h)
389658
def nbytes(self):
        """"""
        try:
            N, L, I = get_shape([self])
        except AllEmptyProbabilityMaps:
            return 0
        return BYTES_PER_FLOAT * N * L * I