For interval PSM return values
336373
public static Result newPSMResult(int type, String label, Object value) {

        Result result = newResult(ResultConstants.VALUE);

        result.errorCode  = type;
        result.mainString = label;
        result.valueData  = value;

        return result;
    }
445948
def _memory_usage_ps():
    
    out = subprocess.Popen(
        ['ps', 'v', '-p', str(os.getpid())],
        stdout=subprocess.PIPE).communicate()[0].split(b'\n')
    vsz_index = out[0].split().index(b'RSS')
    mem = float(out[1].split()[vsz_index]) / 1024
    return mem
1048746
def _values(self):
        """"""
        return [
            val[1] for serie in self.series for val in
            (serie.interpolated if self.interpolate else serie.points)
            if val[1] is not None and (not self.logarithmic or val[1] > 0)
        ]
426302
public void getProbs(double[] ps) {
    for (int pi=0,pl=probs.size();pi<pl;pi++) {
      ps[pi] = ((Double) probs.get(pi)).doubleValue();
    }
  }
436971
def call_interval(freq, **kwargs):
    """"""
    def wrapper(f):
        return CallInterval(f, freq, **kwargs)

    return wrapper
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]) + ')';
  }
1049216
def interval_condition(value, inf, sup, dist):
    
    return (value > inf - dist and value < sup + dist)
52095
def pssm_array2pwm_array(arr, background_probs=DEFAULT_BASE_BACKGROUND):
    
    b = background_probs2array(background_probs)
    b = b.reshape([1, 4, 1])
    return (np.exp(arr) * b).astype(arr.dtype)
229475
def _Backward3_v_Ps(P, s):
    
    if s <= sc:
        return _Backward3a_v_Ps(P, s)
    else:
        return _Backward3b_v_Ps(P, s)
363563
def plot_Sn_timesamples(PSP):
    
    TT = pot.stackel_triax()
    f,a = plt.subplots(2,1,figsize=[3.32,3.6])
    plt.subplots_adjust(hspace=0.,top=0.8)

    LowestPeriod = 2.*np.pi/38.86564386
    Times = np.array([2.,4.,8.,12.])
    Sr = np.arange(2,14,2)

    # Loop over length of integration window
    for i,P,C in zip(Times,['.','s','D','^'],['k','r','b','g']):
        diffact = np.zeros((len(Sr),3))
        difffreq = np.zeros((len(Sr),3))
        MAXGAPS = np.array([])
        # Loop over N_max
        for k,j in enumerate(Sr):
            NT = choose_NT(j)
            timeseries=np.linspace(0.,i*LowestPeriod,NT)
            results = odeint(pot.orbit_derivs2,PSP,timeseries,args=(TT,),rtol=1e-13,atol=1e-13)
            act,ang,n_vec,toy_aa, pars = find_actions(results, timeseries,N_matrix=j,ifprint=False,use_box=True)
            # Check all modes
            checks,maxgap = ced(n_vec,ua(toy_aa.T[3:].T,np.ones(3)))
            if len(maxgap)>0:
                maxgap = np.max(maxgap)
            else:
                maxgap = 0
            diffact[k] = act[:3]/TT.action(results[0])
            MAXGAPS = np.append(MAXGAPS,maxgap)
            difffreq[k] = ang[3:6]/TT.freq(results[0])
        size = 15
        if(P=='.'):
            size = 30
        LW = np.array(map(lambda i: 0.5+i*0.5, MAXGAPS))
        a[0].scatter(Sr,np.log10(np.abs(diffact.T[2]-1)),marker=P,s=size, color=C,facecolors="none",lw=LW,label=r'$T =\,$'+str(i)+r'$\,T_F$')
        a[1].scatter(Sr,np.log10(np.abs(difffreq.T[2]-1)),marker=P,s=size, color=C,facecolors="none", lw=LW)
    a[1].get_yticklabels()[-1].set_visible(False)
    a[0].set_xticklabels([])
    a[0].set_xlim(1,13)
    a[0].set_ylabel(r"$\log_{10}|J_3^\prime/J_{3, \rm true}-1|$")
    leg = a[0].legend(loc='upper center',bbox_to_anchor=(0.5,1.4),ncol=2, scatterpoints = 1)
    leg.draw_frame(False)
    a[1].set_xlim(1,13)
    a[1].set_xlabel(r'$N_{\rm max}$')
    a[1].set_ylabel(r"$\log_{10}|\Omega_3^\prime/\Omega_{3,\rm true}-1|$")
    plt.savefig('Sn_T_box.pdf',bbox_inches='tight')
490477
def _delta_t_supconj_perpass(period, ecc, per0):
    
    ups_sc = np.pi/2-per0
    E_sc = 2*np.arctan( np.sqrt((1-ecc)/(1+ecc)) * np.tan(ups_sc/2) )
    M_sc = E_sc - ecc*np.sin(E_sc)
    return period*(M_sc/2./np.pi)
603282
def function(self,p):
        
        return np.around(
            0.5 +
            0.5*np.sin(pi*(p.duty_cycle-0.5)) +
            0.5*np.sin(p.frequency*2*pi*self.pattern_y + p.phase))
150441
def calculated_intervals(self, value):
        
        if not value:
            self._calculated_intervals = TimeIntervals()
            return

        if isinstance(value, TimeInterval):
            value = TimeIntervals([value])
        elif isinstance(value, TimeIntervals):
            pass
        elif isinstance(value, list):
            value = TimeIntervals(value)
        else:
            raise TypeError("Expected list/TimeInterval/TimeIntervals, got {}".format(type(value)))

        for interval in value:
            if interval.end > utcnow():
                raise ValueError("Calculated intervals should not be in the future")

        self._calculated_intervals = value
487204
def value_px(self):
        """"""
        step = self.w / (self.max - self.min)
        return self.x + step * (self.get() - self.min)
1087893
def _Backward3_T_Ps(P, s):
    
    sc = 4.41202148223476
    if s <= sc:
        T = _Backward3a_T_Ps(P, s)
    else:
        T = _Backward3b_T_Ps(P, s)
    return T
1172232
def millis_interval(start, end):
    """"""
    diff = end - start
    millis = diff.days * 24 * 60 * 60 * 1000
    millis += diff.seconds * 1000
    millis += diff.microseconds / 1000
    return millis
1038946
def calculate_check_interval( self,
			max_interval, ewma_factor, max_days=None,
			max_updates=None, ewma=0, ewma_ts=None,
			add_partial=None ):
		''''''
		if not add_partial:
			posts_base = self.posts.only('date_modified').order_by('date_modified')
			if ewma_ts: posts_base = posts_base.filter(date_modified__gt=ewma_ts)
			posts = posts_base
			if max_days:
				posts = posts.filter(date_modified__gt=timezone.now() - timedelta(max_days))
			if max_updates and max_updates > 0:
				posts = posts[:max_updates]
				if len(posts) < max_updates: posts = posts_base[:max_updates]
			timestamps = posts.values_list('date_modified', flat=True)
		else: timestamps = list()
		if add_partial:
			if not ewma_ts:
				try:
					ewma_ts = self.posts.only('date_modified')\
						.order_by('-date_modified')[0].date_modified
				except (ObjectDoesNotExist, IndexError): return 0 # no previous timestamp available
			timestamps.append(add_partial)
			if (add_partial - ewma_ts).total_seconds() < ewma:
				# It doesn't make sense to lower interval due to frequent check attempts.
				return ewma
		for ts in timestamps:
			if ewma_ts is None: # first post
				ewma_ts = ts
				continue
			ewma_ts, interval = ts, (ts - ewma_ts).total_seconds()
			ewma = ewma_factor * interval + (1 - ewma_factor) * ewma
		return min(timedelta(max_interval).total_seconds(), ewma)