Exponential formatting class-method.

        - x parameter is ignored. Instead kw-argument f being x float-converted
          will be used.

        - precision will be taken from `n` kw-argument.
423458
def _fmt_exp(cls, x, **kw):
        
        n = kw.get('n')
        return '%.*e' % (n, cls._to_float(x))
1225720
def atan(x, context=None):
    
    return _apply_function_in_current_context(
        BigFloat,
        mpfr.mpfr_atan,
        (BigFloat._implicit_convert(x),),
        context,
    )
189515
def logpdf(self, x):
        
        if self.transform is not None:
            x = self.transform(x)       
        return (-self.alpha-1)*np.log(x) - (self.beta/float(x))
1073145
def json_encoder_with_precision(precision, JSONEncoderClass):
    
    needs_class_hack = not hasattr(json.encoder, 'FLOAT_REPR')
    try:
        if precision is not None:
            def float_repr(o):
                return format(o, '.%sf' % precision)
            if not needs_class_hack:
                # python is not 3.5
                original_float_repr = json.encoder.FLOAT_REPR
                json.encoder.FLOAT_REPR = float_repr
            else:
                # HACK to allow usage of float precision in python 3.5
                # Needed because python 3.5 removes the global FLOAT_REPR hack

                class JSONEncoderClass(JSONEncoderClass):
                    FLOAT_REPR = float.__repr__

                    # Follows code copied from cPython Lib/json/encoder.py
                    # The only change is that in floatstr _repr=float.__repr__ is replaced

                    def iterencode(self, o, _one_shot=False):
                        """Encode the given object and yield each string
                        representation as available.

                        For example::

                            for chunk in JSONEncoder().iterencode(bigobject):
                                mysocket.write(chunk)

                        """
                        if self.check_circular:
                            markers = {}
                        else:
                            markers = None
                        if self.ensure_ascii:
                            _encoder = json.encoder.encode_basestring_ascii
                        else:
                            _encoder = json.encoder.encode_basestring

                        def floatstr(o, allow_nan=self.allow_nan, _repr=float_repr, _inf=json.encoder.INFINITY, _neginf=-json.encoder.INFINITY):
                            # Check for specials.  Note that this type of test is processor
                            # and/or platform-specific, so do tests which don't depend on the
                            # internals.

                            if o != o:
                                text = 'NaN'
                            elif o == _inf:
                                text = 'Infinity'
                            elif o == _neginf:
                                text = '-Infinity'
                            else:
                                return _repr(o)

                            if not allow_nan:
                                raise ValueError(
                                    "Out of range float values are not JSON compliant: " +
                                    repr(o))

                            return text

                        if (_one_shot and json.encoder.c_make_encoder is not None and self.indent is None):
                            _iterencode = json.encoder.c_make_encoder(
                                markers, self.default, _encoder, self.indent,
                                self.key_separator, self.item_separator, self.sort_keys,
                                self.skipkeys, self.allow_nan)
                        else:
                            _iterencode = json.encoder._make_iterencode(
                                markers, self.default, _encoder, self.indent, floatstr,
                                self.key_separator, self.item_separator, self.sort_keys,
                                self.skipkeys, _one_shot)
                        return _iterencode(o, 0)
        yield JSONEncoderClass
    finally:
        if precision is not None:
            if not needs_class_hack:
                # restore FLOAT_REPR
                json.encoder.FLOAT_REPR = original_float_repr
1136370
public void precisionRecall()
	{
		PrintfFormat fmt1 = new PrintfFormat("%9s %9s %9s");
		PrintfFormat fmt2 = new PrintfFormat(" %5.2f");
		PrintfFormat hfmt2 = new PrintfFormat(" r%4.2f");
		// print header
		System.out.print(fmt1.sprintf( new Object[] { "block","dist","data"} ));
		double[] rec = MatchExpt.interpolated11PointRecallLevels();
		for (int m=0; m<rec.length; m++) System.out.print(hfmt2.sprintf(rec[m])); 
		System.out.println("   avgPrec\n");
		// print values
		for (int i=0; i<blockerNames.size(); i++) {
			String blocker = (String)blockerNames.get(i);
			if (blocker.length()>7) blocker = blocker.substring(0,7);
			for (int j=0; j<learnerNames.size(); j++) {
				String distance = (String)learnerNames.get(j);
				if (distance.length()>7) distance = distance.substring(0,7);
				double[] average = new double[11+1]; 
				for (int k=0; k<datasetNames.size(); k++) {
					String dataset = (String)datasetNames.get(k);
					// shorten this name
					dataset = new File(dataset).getName();
					int dotPos = dataset.indexOf('.');
					if (dotPos>=0) dataset = dataset.substring(0,dotPos);
					if (dataset.length()>9) dataset = dataset.substring(0,9);
					System.out.print(fmt1.sprintf( new Object[] { blocker, distance, dataset } ));
					double[] prec = expt[i][j][k].interpolated11PointPrecision();
					for (int m=0; m<prec.length; m++) {
						System.out.print(fmt2.sprintf( prec[m] ));
						average[m] += prec[m];
					}
					double a = ((Double)expt[i][j][k].averagePrecision()).doubleValue();
					System.out.print("   "+fmt2.sprintf( a ));
					average[11] += a;
					System.out.print("\n");
				}
				// show average over all datasets
				System.out.print(fmt1.sprintf( new Object[] { blocker, distance, "avg" }));
				for (int m=0; m<average.length-1; m++) {
					System.out.print(fmt2.sprintf( average[m]/datasetNames.size() ));
				}
				System.out.println("   "+fmt2.sprintf( average[11]/datasetNames.size()) + "\n");
			}
		}
	}
139880
def _cost_method(self, *args, **kwargs):
        

        if 'verbose' in kwargs and kwargs['verbose']:
            print(' - Min (X):', np.min(args[0]))

        return 0.0
667034
def npinterpn(*args, **kw):
	
	method = kw.pop('method', 'cubic')
	if kw:
		raise ValueError("Unknown arguments: " % kw.keys())
	nd = (len(args)-1)//2
	if len(args) != 2*nd+1:
		raise ValueError("Wrong number of arguments")
	q = args[:nd]
	qi = args[nd+1:]
	a = args[nd]
	for j in range(nd):
		#print q[j].shape, a.shape
		a = interp(q[j], a, axis=j, kind=method)(qi[j])
	return a
1223513
def pdf(self, x):
        
        if self.transform is not None:
            x = self.transform(x)               
        return (x**(-self.alpha-1))*np.exp(-(self.beta/float(x)))
453051
def round_sig(x, n, scien_notation = False):
    if x < 0:
        x = x * -1
        symbol = '-'
    else:
        symbol = ''
    
    
    ''''''
    if type(n) is not types.IntType:
        raise TypeError, "n must be an integer"
    try:
        x = float(x)
    except:
        raise TypeError, "x must be a floating point object"
    form = "%0." + str(n-1) + "e"
    st = form % x
    num,expo = epat.findall(st)[0]
    expo = int(expo)
    fs = string.split(num,'.')
    if len(fs) < 2:
        fs = [fs[0],""]
    if expo == 0:
#         print 'One', num
        return symbol + num
    elif expo > 0:
        if len(fs[1]) < expo:
            fs[1] += "0"*(expo-len(fs[1]))
        st = fs[0]+fs[1][0:expo]
        if len(fs[1][expo:]) > 0:
            st += '.'+fs[1][expo:]
#         print 'Two', st
        return symbol + st
    else:
        expo = -expo
        if fs[0][0] == '-':
            fs[0] = fs[0][1:]
            sign = "-"
        else:
            sign = ""
            
        if scien_notation:
            coso = float(sign+"0."+"0"*(expo-1)+fs[0]+fs[1])
            scient_format = '{:.' + str(n) + 'e}'
            StrScientific = scient_format.format(coso)
#             print 'three', StrScientific
            return symbol + StrScientific
        
        else:
            formated = sign+"0."+"0"*(expo-1)+fs[0]+fs[1]
            if len(formated) > (n+5):
                formated = '0.' + '0' * n
#             print 'cuantro', formated
            return symbol + formated
1002888
def interpn(*args, **kw):
	
	method = kw.pop('method', 'cubic')
	if kw:
		raise ValueError("Unknown arguments: " % kw.keys())
	nd = (len(args)-1)//2
	if len(args) != 2*nd+1:
		raise ValueError("Wrong number of arguments")
	q = args[:nd]
	qi = args[nd+1:]
	a = args[nd]
	for j in range(nd):
		#print q[j].shape, a.shape
		a = interp1d(q[j], a, axis=j, kind=method)(qi[j])
	return a
1174775
def _value_formatter(self, float_format=None, threshold=None):
        

        # the float_format parameter supersedes self.float_format
        if float_format is None:
            float_format = self.float_format

        # we are going to compose different functions, to first convert to
        # a string, then replace the decimal symbol, and finally chop according
        # to the threshold

        # when there is no float_format, we use str instead of '%g'
        # because str(0.0) = '0.0' while '%g' % 0.0 = '0'
        if float_format:
            def base_formatter(v):
                return float_format(value=v) if notna(v) else self.na_rep
        else:
            def base_formatter(v):
                return str(v) if notna(v) else self.na_rep

        if self.decimal != '.':
            def decimal_formatter(v):
                return base_formatter(v).replace('.', self.decimal, 1)
        else:
            decimal_formatter = base_formatter

        if threshold is None:
            return decimal_formatter

        def formatter(value):
            if notna(value):
                if abs(value) > threshold:
                    return decimal_formatter(value)
                else:
                    return decimal_formatter(0.0)
            else:
                return self.na_rep

        return formatter
937192
def operator_numeric_type(method):
    
    def wrapper(self, other):
        if not isinstance(other, _NUMERIC_TYPES):
            raise TypeError(
                'unsupported operand types: \'{0}\' and \'{1}\''.format(
                    self.__class__.__name__, other.__class__.__name__))
        return method(self, other)
    return wrapper
807890
def format_exp_floats(decimals):
    
    threshold = 10 ** 5
    return (
        lambda n: "{:.{prec}e}".format(n, prec=decimals) if n > threshold else "{:4.{prec}f}".format(n, prec=decimals)
    )
102563
def set_fft_params(func):
    
    @wraps(func)
    def wrapped_func(series, method_func, *args, **kwargs):
        """Wrap function to normalize FFT params before execution
        """
        if isinstance(series, tuple):
            data = series[0]
        else:
            data = series

        # normalise FFT parmeters for all libraries
        normalize_fft_params(data, kwargs=kwargs, func=method_func)

        return func(series, method_func, *args, **kwargs)

    return wrapped_func
1171265
def indent(func):
    
    def wrapper(self, *args, **kwds):
        func(self, *args, **kwds)
        return Indent(self)
    return wrapper
1269238
def floating_point(
        element_name,  # type: Text
        attribute=None,  # type: Optional[Text]
        required=True,  # type: bool
        alias=None,  # type: Optional[Text]
        default=0.0,  # type: Optional[float]
        omit_empty=False,  # type: bool
        hooks=None  # type: Optional[Hooks]
):
    # type: (...) -> Processor
    
    value_parser = _number_parser(float)
    return _PrimitiveValue(
        element_name,
        value_parser,
        attribute,
        required,
        alias,
        default,
        omit_empty,
        hooks
    )
778891
def _format_bf(bf, precision=3, trim='0'):
    
    if bf >= 1e4 or bf <= 1e-4:
        out = np.format_float_scientific(bf, precision=precision, trim=trim)
    else:
        out = np.format_float_positional(bf, precision=precision, trim=trim)
    return out