Circular mean phase
481438
def circmean(ts, axis=2):
    """"""
    return np.exp(1.0j * ts).mean(axis=axis).angle()
204153
def _keplerian_to_keplerian_mean(cls, coord, center):
        

        a, e, i, Ω, ω, ν = coord
        if e < 1:
            # Elliptic case
            cos_E = (e + cos(ν)) / (1 + e * cos(ν))
            sin_E = (sin(ν) * sqrt(1 - e ** 2)) / (1 + e * cos(ν))
            E = arctan2(sin_E, cos_E) % (2 * np.pi)
            M = E - e * sin(E)  # Mean anomaly
        else:
            # Hyperbolic case
            H = arccosh((e + cos(ν)) / (1 + e * cos(ν)))
            M = e * sinh(H) - H

        return np.array([a, e, i, Ω, ω, M], dtype=float)
816928
def _compute_mean(self, C, mag, rjb):
        
        d1 = np.sqrt(50. ** 2 + 6. ** 2)
        d = np.sqrt(rjb ** 2 + 6 ** 2)

        mean = np.zeros_like(rjb)

        mean += (
            C['a1'] + C['a2'] * (mag - 6.4) +
            C['a7'] * (8.5 - mag) ** 2
        )

        idx = rjb < 50.
        mean[idx] += (
            C['a3'] * np.log(d[idx]) +
            C['a4'] * (mag - 6.4) * np.log(d[idx]) +
            C['a5'] * rjb[idx]
        )

        idx = rjb >=50.
        mean[idx] += (
            C['a3'] * np.log(d1) +
            C['a4'] * (mag - 6.4) * np.log(d[idx]) +
            C['a5'] * rjb[idx] + C['a6'] * (np.log(d[idx]) - np.log(d1))
        )

        return mean
1045506
def _compute_mean(self, C, mag, dists, rake):
        
        mean = (
            self._compute_magnitude_scaling_term(C, mag) +
            self._compute_geometric_decay_term(C, mag, dists) +
            self._compute_faulting_style_term(C, rake) +
            self._compute_anelestic_attenuation_term(C, dists)
        )

        return mean
1340618
def ccmodmd_ystep():
    

    mAXU = np.mean(mp_D_X + mp_D_U0, axis=0)
    mp_D_Y0[:] = mp_dprox(mAXU)
    AXU1 = mp_DX - mp_S + mp_D_U1
    mp_D_Y1[:] = mp_drho*AXU1 / (mp_W**2 + mp_drho)
137140
def cbpdnmd_ustep(k):
    

    mp_Z_U0[k] += mp_DX[k] - mp_Z_Y0[k] - mp_S[k]
    mp_Z_U1[k] += mp_Z_X[k] - mp_Z_Y1[k]
1138867
def _model(self, t, theta, period, tmpid):
        """"""
        template = self.templates[tmpid]
        phase = (t / period - theta[2]) % 1
        return theta[0] + theta[1] * template(phase)
762529
def calculate_wave(i, lst_bin, wpm=WPM, frequency=FREQUENCY, framerate=FRAMERATE, amplitude=AMPLITUDE, seconds_per_dot=SECONDS_PER_DOT):
    
    bit = morse_bin(i=i, lst_bin=lst_bin, wpm=wpm, framerate=framerate,
                    default_value=0.0, seconds_per_dot=seconds_per_dot)
    sine = sine_wave(i=i, frequency=frequency, framerate=framerate, amplitude=amplitude)
    return bit * sine
77739
def circstd(dts, axis=2):
    """"""
    R = np.abs(np.exp(1.0j * dts).mean(axis=axis))
    return np.sqrt(-2.0 * np.log(R))
607393
def _compute_mean(self, C, mag, rhypo, hypo_depth, mean, idx):
        
        mean[idx] = (C['C1'] + C['C2'] * mag + C['C3'] * np.log(rhypo[idx] +
                     C['C4'] * np.exp(C['C5'] * mag)) + C['C6'] * hypo_depth)
465494
def harmonic_mean(data):
    

    if not data:
        raise StatisticsError('harmonic_mean requires at least one data point')

    divisor = sum(map(lambda x: 1.0 / x if x else 0.0, data))
    return len(data) / divisor if divisor else 0.0
970336
def initial_step(self, phase, x, y):
        
        self.x[0] = x
        self.y[0] = y
        self.phase[0] = phase
        if self.MODE == CordicMode.ROTATION:
            if phase > 0.5:
                # > np.pi/2
                self.x[0] = -x
                self.phase[0] = phase - 1.0
            elif phase < -0.5:
                # < -np.pi/2
                self.x[0] = -x
                self.phase[0] = phase + 1.0

        elif self.MODE == CordicMode.VECTORING:
            if x < 0.0 and y > 0.0:
                # vector in II quadrant -> initial shift by PI to IV quadrant (mirror)
                self.x[0] = -x
                self.y[0] = -y
                self.phase[0] = 1.0
                # self.phase[0] = 0.0
            elif x < 0.0 and y < 0.0:
                # vector in III quadrant -> initial shift by -PI to I quadrant (mirror)
                self.x[0] = -x
                self.y[0] = -y
                self.phase[0] = -1.0
987080
def get_data():
    

    # pretend we're measuring a noisy resonance at zero
    y = 1.0 / (1.0 + 1j*(n_x.get_value()-0.002)*1000) + _n.random.rand()*0.1

    # and that it takes time to do so
    _t.sleep(0.1)

    # return mag phase
    return abs(y), _n.angle(y, True)
1037201
def main(self, c):
        
        phase = Sfix(0.0, 0, -17)

        abs, _, angle = self.core.main(c.real, c.imag, phase)

        # get rid of CORDIC gain and extra bits
        self.y_abs = abs * (1.0 / 1.646760)
        self.y_angle = angle
        return self.y_abs, self.y_angle
740889
function modHasCircularDependency( source, target, visited ) {
        if ( !modIsAnalyzed( target ) ) {
            return CIRCULAR_DEP_UNREADY;
        }

        visited = visited || {};
        visited[ target ] = 1;

        var module = modModules[ target ];

        if ( target === source ) {
            return CIRCULAR_DEP_YES;
        }

        var deps = module && module.depMs;
        if ( deps ) {
            var len = deps.length;

            while ( len-- ) {
                var depId = deps[ len ].absId;
                if ( visited[ depId ] ) {
                    continue;
                }

                var state = modHasCircularDependency( source, depId, visited );
                switch ( state ) {
                    case CIRCULAR_DEP_YES:
                    case CIRCULAR_DEP_UNREADY:
                        return state;
                }
            }
        }

        return CIRCULAR_DEP_NO;
    }
1119282
def _compute_mean_on_rock(self, C, mag, rrup, F, HW):
        
        f1 = self._compute_f1(C, mag, rrup)
        f3 = self._compute_f3(C, mag)
        f4 = self._compute_f4(C, mag, rrup)

        return f1 + F * f3 + HW * f4
152796
function pm(m) {
    if (m[4] === 0 && m[5] === 0) {
      if (m[1] === 0 && m[2] === 0) {
        if (m[0] === 1 && m[3] === 1) {
          return '';
        }
        return 'scale(' + pf(m[0]) + ' ' + pf(m[3]) + ')';
      }
      if (m[0] === m[3] && m[1] === -m[2]) {
        var a = Math.acos(m[0]) * 180 / Math.PI;
        return 'rotate(' + pf(a) + ')';
      }
    } else {
      if (m[0] === 1 && m[1] === 0 && m[2] === 0 && m[3] === 1) {
        return 'translate(' + pf(m[4]) + ' ' + pf(m[5]) + ')';
      }
    }
    return 'matrix(' + pf(m[0]) + ' ' + pf(m[1]) + ' ' + pf(m[2]) + ' ' +
      pf(m[3]) + ' ' + pf(m[4]) + ' ' + pf(m[5]) + ')';
  }