Ask user for display format for floats and use it.

        This function also checks whether the format is valid and emits
        `sig_option_changed`.
542063
def change_format(self):
        
        format, valid = QInputDialog.getText(self, _('Format'),
                                             _("Float formatting"),
                                             QLineEdit.Normal,
                                             self.dataModel.get_format())
        if valid:
            format = str(format)
            try:
                format % 1.1
            except:
                msg = _("Format ({}) is incorrect").format(format)
                QMessageBox.critical(self, _("Error"), msg)
                return
            if not format.startswith('%'):
                msg = _("Format ({}) should start with '%'").format(format)
                QMessageBox.critical(self, _("Error"), msg)
                return
            self.dataModel.set_format(format)
            self.sig_option_changed.emit('dataframe_format', format)
541799
def convert_float(value, parameter):
    '''
    
    '''
    value = _check_default(value, parameter, ( '', '-', None ))
    if value is None or isinstance(value, float):
        return value
    try:
        return float(value)
    except Exception as e:
        raise ValueError(str(e))
1333620
def get_value_display(self):
        """"""
        if self.display_as == 'percentage':
            return '{0}%'.format(self.latest_value)
        if self.display_as == 'boolean':
            return bool(self.latest_value)
        if self.display_as == 'byte':
            return defaultfilters.filesizeformat(self.latest_value)
        if self.display_as == 'second':
            return time.strftime('%H:%M:%S', time.gmtime(self.latest_value))
        return self.latest_value
372643
function validate( opts, options ) {
	if ( !isObject( options ) ) {
		return new TypeError( 'invalid argument. Options argument must be an object. Value: `' + options + '`.' );
	}
	if ( options.hasOwnProperty( 'radix' ) ) {
		opts.radix = options.radix;
		if ( !isInteger( opts.radix ) ) {
			return new TypeError( 'invalid option. Radix must be an integer. Option: `' + opts.radix + '`.' );
		}
		if ( opts.radix < 2 || opts.radix > 36 ) {
			return new RangeError( 'invalid option. Radix must be an integer on the interval [2,36]. Option: `' + opts.radix + '`.' );
		}
	}
	return null;
}
670582
def _format_number_si(num, n_signif_figures):
    """"""
    if math.isnan(num) or math.isinf(num):
        return str(num)
    leading, exp = '{:E}'.format(num).split('E')
    leading = round(float(leading), n_signif_figures - 1)
    exp = exp[:1] + exp[2:] if exp[1] == '0' else exp
    formatted = '{}e{}'.format(leading, exp.lstrip('+'))
    return formatted
142428
def format_float(x, max_width):
    '''
    '''
    # width of (whole part + 1 (to avoid zero)) + 1 because int floors, not ceils
    whole_width = int(math.log10(abs(x) + 1)) + 1
    # for +/- sign
    sign_width = 1 if x < 0 else 0
    # for . if we show it
    decimal_point_width = 1 if max_width >= whole_width else 0
    return '%.*f' % (max_width - whole_width - sign_width - decimal_point_width, x)
461588
def format_float_field(__, prec, number, locale):
    """"""
    format_ = u'0.'
    if prec is None:
        format_ += u'#' * NUMBER_DECIMAL_DIGITS
    else:
        format_ += u'0' * int(prec)
    pattern = parse_pattern(format_)
    return pattern.apply(number, locale)
15381
def set_float(self, option, value):
        
        if not isinstance(value, float):
            raise TypeError("Value must be a float")
        self.options[option] = value
942619
def normalizeGlyphFormatVersion(value):
    
    if not isinstance(value, (int, float)):
        raise TypeError("Glyph Format Version must be an "
                        ":ref:`type-int-float`, not %s."
                        % type(value).__name__)
    value = int(value)
    if value not in (1, 2):
        raise ValueError("Glyph Format Version must be either 1 or 2, not %s."
                         % value)
    return value
1251549
def cfitsio_version(asfloat=False):
    
    # use string version to avoid roundoffs
    ver = '%0.3f' % _fitsio_wrap.cfitsio_version()
    if asfloat:
        return float(ver)
    else:
        return ver
393709
def ok(self):
        
        try:
            v = float(self._value)
            if v < self.fmin or v > self.fmax:
                return False
            else:
                return True
        except:
            return False
208896
def display_value(self, value):
        

        if not (isinstance(value, bool) or value == 'all'):
            raise InvalidUsage("Display value can be of type bool or value 'all'")

        self._sysparms['sysparm_display_value'] = value
1257200
def displayformat(codes=[], fg=None, bg=None):
        """"""
        if isinstance(codes, basestring):
            codes = [codes]
        else:
            codes = list(codes)
        for code in codes:
            if code not in Magic.DISPLAY.keys():
                raise ValueError("'%s' not a valid display value" % code)
        for color in (fg, bg):
            if color != None:
                if color not in Magic.COLORS.keys():
                    raise ValueError("'%s' not a valid color" % color)
        return [codes, fg, bg]
654077
function isFloating(item) {
            return (
              /left|right/.test(item.css('float')) ||
              /inline|table-cell/.test(item.css('display'))
            );
          }
1008631
def check_resize(resize):
    """"""
    if resize is None:
        return

    resize = resize.lower().strip()

    if 'x' in resize:
        tmp = resize.lower().split('x')
        tmp = [x.strip() for x in resize.split('x')]
        if len(tmp) == 2 and tmp[0].isdigit() and tmp[1].isdigit():
            return
    elif '%' in resize:
        tmp = resize.split('%')[0]
        if tmp.isnumeric():
            tmp = int(tmp)
            if 1 <= tmp <= 1000:
                return
            else:
                raise PercentageOutOfRange("percentage must be between 1 and 1000")

    raise MallformedResize('Resize value "%s" is mallformed. '
                           'Desired format is: {width}x{height} or {percentage}%%' % resize)
1326630
def form(value):
    
    if isinstance(value, FLOAT + INT):
        if value <= 0:
            return str(value)
        elif value < .001:
            return '%.3E' % value
        elif value < 10 and isinstance(value, FLOAT):
            return '%.5f' % value
        elif value > 1000:
            return '{:,d}'.format(int(round(value)))
        elif numpy.isnan(value):
            return 'NaN'
        else:  # in the range 10-1000
            return str(int(value))
    elif isinstance(value, bytes):
        return decode(value)
    elif isinstance(value, str):
        return value
    elif isinstance(value, numpy.object_):
        return str(value)
    elif hasattr(value, '__len__') and len(value) > 1:
        return ' '.join(map(form, value))
    return str(value)
558798
def format_value(value):
    
    value = decimal.Decimal(str(value))
    if int(value) == value:
        return int(value)

    # On Python 3, an explicit cast to float is required
    return float(round(value, 1))