Get the possible downscale type based on the specified analysis
437236
function getDownscaleType( n_type, analysis ) {
	switch (n_type) {

		// Not possible to downscale from 1-byte
		case NUMTYPE.UINT8:
		case NUMTYPE.INT8:
			return NUMTYPE.UNKNOWN;

		case NUMTYPE.UINT16:
			switch (analysis.type) {

				// UINT16 -> (U)INT8 = UINT8
				case NUMTYPE.INT8: // Unsigned, so always positive
				case NUMTYPE.UINT8:
					return NUMTYPE.UINT8;

				// Anything else is equal to or bigger than 2 bytes
				default:
					return NUMTYPE.UNKNOWN;					
			}

		case NUMTYPE.INT16:
			switch (analysis.type) {

				// INT16 -> UINT8 = INT8 (if v < INT8_MAX)
				case NUMTYPE.UINT8:
					if (analysis.max < INT8_MAX) {
						return NUMTYPE.INT8;
					} else {
						return NUMTYPE.UNKNOWN;
					}

				// INT16 -> INT8
				case NUMTYPE.INT8:
					return NUMTYPE.INT8;

				// Anything else is equal to or bigger than 2 bytes
				default:
					return NUMTYPE.UNKNOWN;					
			}

		case NUMTYPE.UINT32:
			switch (analysis.type) {

				// UINT32 -> (U)INT8 [= UINT8]
				case NUMTYPE.INT8:
				case NUMTYPE.UINT8:
					return NUMTYPE.UINT8;

				// UINT32 -> (U)INT16 = UINT16
				case NUMTYPE.INT16:
				case NUMTYPE.UINT16:
					return NUMTYPE.UINT16;

				// Anything else is equal to or bigger than 4 bytes
				default:
					return NUMTYPE.UNKNOWN;					

			}

		case NUMTYPE.INT32:
			switch (analysis.type) {

				// INT32 -> UINT8 = INT8/INT16 (if v < INT8_MAX)
				case NUMTYPE.UINT8:
					if (analysis.max < INT8_MAX) {
						return NUMTYPE.INT8;
					} else {
						return NUMTYPE.INT16;
					}

				// INT32 -> INT8
				case NUMTYPE.INT8:
					return NUMTYPE.INT8;

				// INT32 -> UINT16 = INT16 (if v < INT16_MAX)
				case NUMTYPE.UINT16:
					if (analysis.max < INT16_MAX) {
						return NUMTYPE.INT16;
					} else {
						return NUMTYPE.UNKNOWN;
					}

				// INT32 -> INT16
				case NUMTYPE.INT16:
					return NUMTYPE.INT16;

				// Anything else is equal to or bigger than 4 bytes
				default:
					return NUMTYPE.UNKNOWN;					

			}

		case NUMTYPE.FLOAT32:
			switch (analysis.type) {

				// FLOAT32 -> Anything 1-2 bytes
				case NUMTYPE.UINT8:
					return NUMTYPE.UINT8;
				case NUMTYPE.INT8:
					return NUMTYPE.INT8;
				case NUMTYPE.UINT16:
					return NUMTYPE.UINT16
				case NUMTYPE.INT16:
					return NUMTYPE.INT16

				// Everything else is discarded
				default:
					return NUMTYPE.UNKNOWN;
			}

		case NUMTYPE.FLOAT64:
			switch (analysis.type) {

				// FLOAT64 -> Anything 1-2 bytes
				case NUMTYPE.UINT8:
					return NUMTYPE.UINT8;
				case NUMTYPE.INT8:
					return NUMTYPE.INT8;
				case NUMTYPE.UINT16:
					return NUMTYPE.UINT16
				case NUMTYPE.INT16:
					return NUMTYPE.INT16

				// FLOAT64 -> FLOAT32
				case NUMTYPE.FLOAT32:
					return NUMTYPE.FLOAT32

				// Everything else is discarded
				default:
					return NUMTYPE.UNKNOWN;
			}

	}
}
760909
function getFormatter(oType) {
		var oFormatOptions;

		if (!oType.oFormat) {
			oFormatOptions = jQuery.extend({groupingEnabled : true}, oType.oFormatOptions);
			oType.oFormat = NumberFormat.getFloatInstance(oFormatOptions);
		}
		return oType.oFormat;
	}
1357131
def _get_atomic_dtype(data_type):
    """"""
    atomic_type = getattr(data_type, 'type', None)
    if atomic_type is not None:
        return atomic_type

    return _PREDEFINED_ATOMIC_NUMPY_TYPES[_find_base_type(data_type)]
130659
def guess(cls, sample):
        
        if isinstance(sample, TypeEngine):
            return sample
        if isinstance(sample, bool):
            return cls.boolean
        elif isinstance(sample, int):
            return cls.integer
        elif isinstance(sample, float):
            return cls.float
        elif isinstance(sample, datetime):
            return cls.datetime
        elif isinstance(sample, date):
            return cls.date
        return cls.text
403708
def get_estimator(self):
        """"""

        mav_type = self._ulog.initial_parameters.get('MAV_TYPE', None)
        if mav_type == 1: # fixed wing always uses EKF2
            return 'EKF2'

        mc_est_group = self._ulog.initial_parameters.get('SYS_MC_EST_GROUP', None)
        return {0: 'INAV',
                1: 'LPE',
                2: 'EKF2',
                3: 'IEKF'}.get(mc_est_group, 'unknown ({})'.format(mc_est_group))
490148
def downsample(self, df=None, ds_type='kmeans', axis='row', num_samples=100, random_state=1000):
    '''
    
    '''

    return downsample_fun.main(self, df, ds_type, axis, num_samples, random_state)
136758
def find_types(observatory, match=None, trend=None,
               connection=None, **connection_kw):
    
    return sorted(connection.find_types(observatory, match=match),
                  key=lambda x: _type_priority(observatory, x, trend=trend))
633246
def determine_types(self):
        
        from nefertari.elasticsearch import ES
        collections = self.get_collections()
        resources = self.get_resources(collections)
        models = set([res.view.Model for res in resources])
        es_models = [mdl for mdl in models if mdl
                     and getattr(mdl, '_index_enabled', False)]
        types = [ES.src2type(mdl.__name__) for mdl in es_models]
        return types
363181
def result_type(self):
        """"""
        if not hasattr(self, '_result_type'):
            self._result_type = conf.lib.clang_getResultType(self.type)

        return self._result_type
908838
private void determineGlobalExtremumType() {
    final double f = function(alphaExtremum);

    // create random alpha values
    double[] alpha_1 = new double[alphaExtremum.length];
    double[] alpha_2 = new double[alphaExtremum.length];
    for(int i = 0; i < alphaExtremum.length; i++) {
      alpha_1[i] = Math.random() * Math.PI;
      alpha_2[i] = Math.random() * Math.PI;
    }

    // look if f1 and f2 are less, greater or equal to f
    double f1 = function(alpha_1);
    double f2 = function(alpha_2);

    if(f1 < f && f2 < f) {
      extremumType = ExtremumType.MAXIMUM;
    }
    else if(f1 > f && f2 > f) {
      extremumType = ExtremumType.MINIMUM;
    }
    else if(Math.abs(f1 - f) < DELTA && Math.abs(f2 - f) < DELTA) {
      extremumType = ExtremumType.CONSTANT;
    }
    else {
      throw new IllegalStateException("Houston, we have a problem:" + "\n" + this + "\nextremum at " + FormatUtil.format(alphaExtremum) + "\nf  " + f + "\nf1 " + f1 + "\nf2 " + f2);
    }
  }
1034118
def get_downsample_pct(in_bam, target_counts, data):
    
    total = sum(x.aligned for x in idxstats(in_bam, data))
    with pysam.Samfile(in_bam, "rb") as work_bam:
        n_rgs = max(1, len(work_bam.header.get("RG", [])))
    rg_target = n_rgs * target_counts
    if total > rg_target:
        pct = float(rg_target) / float(total)
        if pct < 0.9:
            return pct
165087
def get_type(var):
    
    if HAVE_NUMPY and isinstance(var, np.ndarray):
        if _WIN32:
            # This is a weird system specific error
            # https://github.com/numpy/numpy/issues/3667
            type_ = var.dtype
        else:
            type_ = var.dtype.type
    elif HAVE_PANDAS and isinstance(var, pd.Index):
        if _WIN32:
            type_ = var.dtype
        else:
            type_ = var.dtype.type
    else:
        type_ = type(var)
    return type_
317837
function deltaEncTypeInt( fromType, toType ) {
	// Lookup conversion on the downscale table
	for (var i=0; i<NUMTYPE_DELTA_INT.FROM.length; ++i) {
		if ( (NUMTYPE_DELTA_INT.FROM[i] === fromType) && 
			 (NUMTYPE_DELTA_INT.TO[i] === toType) )
			return i;
	}
	// Nothing found
	return undefined;
}
556170
def _analyze_case(model_dir, bench_dir, config):
    
    model_timings = set(glob.glob(os.path.join(model_dir, "*" + config["timing_ext"])))
    if bench_dir is not None:
        bench_timings = set(glob.glob(os.path.join(bench_dir, "*" + config["timing_ext"])))
    else:
        bench_timings = set()
    if not len(model_timings):
        return dict()
    model_stats = generate_timing_stats(model_timings, config['timing_vars'])
    bench_stats = generate_timing_stats(bench_timings, config['timing_vars'])
    return dict(model=model_stats, bench=bench_stats)
1187755
function determineActualTypesLoose(env, values) {
    return Z.reject (function(t) { return t.type === INCONSISTENT; },
                     _determineActualTypes (env, [], values));
  }
111812
def guess_type(s):
    
    sc = s.replace(',', '') # remove comma from potential numbers

    try:
        return int(sc)
    except ValueError:
        pass

    try:
        return float(sc)
    except ValueError:
        pass

    return s
840231
def compute_two_dimensional_near_isotropic_downsampling_scales(
        size,
        voxel_size,
        max_scales=float('inf'),
        max_downsampling=DEFAULT_MAX_DOWNSAMPLING,
        max_downsampled_size=DEFAULT_MAX_DOWNSAMPLED_SIZE):
    """"""

    max_scales = min(max_scales, 10)

    # First compute a set of 2-d downsamplings for XY, XZ, and YZ with a high
    # number of max_scales, and ignoring other criteria.
    scales_transpose = [
        compute_near_isotropic_downsampling_scales(
            size=size,
            voxel_size=voxel_size,
            dimensions_to_downsample=dimensions_to_downsample,
            max_scales=max_scales,
            max_downsampling=float('inf'),
            max_downsampled_size=0, ) for dimensions_to_downsample in [[0, 1], [0, 2], [1, 2]]
    ]

    # Truncate all list of scales to the same length, once the stopping criteria
    # is reached for all values of dimensions_to_downsample.
    scales = [((1, ) * 3, ) * 3]
    size = np.array(size)

    def scale_satisfies_criteria(scale):
        return np.prod(scale) < max_downsampling and (size / scale).max() > max_downsampled_size

    for i in range(1, max_scales):
        cur_scales = tuple(scales_transpose[d][i] for d in range(3))
        if all(not scale_satisfies_criteria(scale) for scale in cur_scales):
            break
        scales.append(cur_scales)
    return scales