Converts magnitude field to a float value, or ``None`` if GCVS does
        not list the magnitude.

        Returns a tuple (magnitude, symbol), where symbol can be either an
        empty string or a single character - one of '<', '>', '('.
553735
def parse_magnitude(self, magnitude_str):
        
        symbol = magnitude_str[0].strip()
        magnitude = magnitude_str[1:6].strip()
        return float(magnitude) if magnitude else None, symbol
749030
def float_range(value):
    
    try:
        value = float(value)
    except Exception:
        raise argparse.ArgumentTypeError('Invalid float value: \'{}\''.format(value))
    if value < 0.0 or value > 1.0:
        raise argparse.ArgumentTypeError('Invalid float value: \'{}\''.format(value))
    return value
1172188
def encode(cls, value):
        
        try:
            if float(value) + 0 == value:
                return repr(value)
        except (TypeError, ValueError):
            pass

        raise InvalidValue('not a float')
460220
def scalar(magnitude = value)
      if special?
        unit.scalar(magnitude)
      else
        Number.rationalize(value) * Number.rationalize(unit.scalar)
      end
    end
52608
def get_float(self, key, default=None):
        
        value = self.get(key, default)
        return None if value is None else float(value)
562112
function _String_toFloat(s)
{
	// check if it is a hex, octal, or binary number
	if (s.length === 0 || /[\sxbo]/.test(s))
	{
		return __Maybe_Nothing;
	}
	var n = +s;
	// faster isNaN check
	return n === n ? __Maybe_Just(n) : __Maybe_Nothing;
}
512081
def _parse_float(value, default=None):
    
    if value is None:
        return default
    try:
        return float(value)
    except ValueError:
        print "Couldn't cast value to `float`."
        return default
1047482
def parse_value(val):
    
    val = val.replace("%", " ")\
        .replace(" ","")\
        .replace(",", ".")\
        .replace("st","").strip()

    missing = ["Ejdeltagit", "N/A"]
    if val in missing:
        return val
    elif val == "":
        return None

    return float(val)
588313
def binary_float_to_decimal_float(number: Union[float, str]) -> float:
    
    if isinstance(number, str):
        if number[0] == '-':
            n_sign = -1
        else:
            n_sign = 1
    elif isinstance(number, float):
        n_sign = np.sign(number)
        number = str(number)

    deci = 0
    for ndx, val in enumerate(number.split('.')[-1]):
        deci += float(val) / 2**(ndx+1)
    deci *= n_sign

    return deci
1232554
def cast_float(x):
    
    try:
        x = float(x)
    except ValueError:
        try:
            x = x.strip()
        except AttributeError as e:
            logger_misc.warn("parse_str: AttributeError: String not number or word, {}, {}".format(x, e))
    return x
203348
def parse_value(proto):
    
    if proto.HasField('floatValue'):
        return proto.floatValue
    elif proto.HasField('doubleValue'):
        return proto.doubleValue
    elif proto.HasField('sint32Value'):
        return proto.sint32Value
    elif proto.HasField('uint32Value'):
        return proto.uint32Value
    elif proto.HasField('binaryValue'):
        return proto.binaryValue
    elif proto.HasField('timestampValue'):
        # Don't use the actual 'timestampValue' field, it contains a number
        # that is difficult to interpret on the client. Instead parse from
        # the ISO String also set by Yamcs.
        return parse_isostring(proto.stringValue)
    elif proto.HasField('stringValue'):
        return proto.stringValue
    elif proto.HasField('uint64Value'):
        return proto.uint64Value
    elif proto.HasField('sint64Value'):
        return proto.sint64Value
    elif proto.HasField('booleanValue'):
        return proto.booleanValue
    elif proto.HasField('arrayValue'):
        return [parse_value(v) for v in proto.arrayValue]
    elif proto.HasField('aggregateValue'):
        return OrderedDict(zip(proto.aggregateValue.name, proto.aggregateValue.value))
    else:
        logging.warn('Unrecognized value type for update %s', proto)
        return None
1119042
def _latex_float(f, format=".3g"):
    
    float_str = "{{0:{0}}}".format(format).format(f)
    if "e" in float_str:
        base, exponent = float_str.split("e")
        return r"{0}\times 10^{{{1}}}".format(base, int(exponent))
    else:
        return float_str
833031
def _FloatDecoder():
  

  local_unpack = struct.unpack

  def InnerDecode(buffer, pos):
    # We expect a 32-bit value in little-endian byte order.  Bit 1 is the sign
    # bit, bits 2-9 represent the exponent, and bits 10-32 are the significand.
    new_pos = pos + 4
    float_bytes = buffer[pos:new_pos]

    # If this value has all its exponent bits set, then it's non-finite.
    # In Python 2.4, struct.unpack will convert it to a finite 64-bit value.
    # To avoid that, we parse it specially.
    if (float_bytes[3:4] in b'\x7F\xFF' and float_bytes[2:3] >= b'\x80'):
      # If at least one significand bit is set...
      if float_bytes[0:3] != b'\x00\x00\x80':
        return (_NAN, new_pos)
      # If sign bit is set...
      if float_bytes[3:4] == b'\xFF':
        return (_NEG_INF, new_pos)
      return (_POS_INF, new_pos)

    # Note that we expect someone up-stack to catch struct.error and convert
    # it to _DecodeError -- this way we don't have to set up exception-
    # handling blocks every time we parse one value.
    result = local_unpack('<f', float_bytes)[0]
    return (result, new_pos)
  return _SimpleDecoder(wire_format.WIRETYPE_FIXED32, InnerDecode)
826630
def toFloat(value):
    
    if isinstance(value, str):
        return strFloat(value)
    elif isinstance(value, list):
        return slistFloat(value)
    else:
        return value
27958
def _convert_value(vtype, value):
        
        # Normalize value
        value = value.strip()

        if vtype == TYPE_STRING:
            # Nothing to do
            return value
        elif vtype in TYPES_INT:
            return int(value)
        elif vtype in TYPES_FLOAT:
            return float(value)
        elif vtype in TYPES_BOOLEAN:
            # Compare lower-case value
            return value.lower() not in ("false", "0")
        elif vtype in TYPES_CHAR:
            return value[0]

        # No luck
        raise ValueError("Unknown value type: {0}".format(vtype))
1333396
def _float(value):
    
    if "[" in value:
        # There is a unit field
        value, sep, unit = value.partition("[")
        unit = sep + unit

        # As defined in the CCSDS Orbital Data Message Blue Book, the unit should
        # be the same as defined in table 3-3 which are for km and km/s for position and
        # velocity respectively. Thus, there should be no other conversion to make
        if unit in ("[km]", "[km/s]"):
            multiplier = 1000
        elif unit == "[s]":
            multiplier = 1
        else:
            raise ValueError("Unknown unit for this field", unit)
    else:
        # if no unit is provided, the default is km, and km/s
        multiplier = 1000

    return float(value) * multiplier
178082
def to_decimal(value, ctx):
    
    if isinstance(value, bool):
        return Decimal(1) if value else Decimal(0)
    elif isinstance(value, int):
        return Decimal(value)
    elif isinstance(value, Decimal):
        return value
    elif isinstance(value, str):
        try:
            return Decimal(value)
        except Exception:
            pass

    raise EvaluationError("Can't convert '%s' to a decimal" % str(value))