Return a string representation of the pressure, using the given units.
760204
def string(self, units: typing.Optional[str] = None) -> str:
        """"""
        if not units:
            _units: str = self._units
        else:
            if not units.upper() in CustomPressure.legal_units:
                raise UnitsError("unrecognized pressure unit: '" + units + "'")
            _units = units.upper()
        val = self.value(units)
        if _units == "MB":
            return "%.0f mb" % val
        if _units == "HPA":
            return "%.0f hPa" % val
        if _units == "IN":
            return "%.2f inches" % val
        if _units == "MM":
            return "%.0f mmHg" % val

        raise ValueError(_units)
735220
public static String toFloatUnit(long size) {
		if (size < BYTE_UNIT_KILO) {
			return String.format("%5d", size);
		}

		if (size < BYTE_UNIT_MEGA) {
			return String.format("%5.1fk", size / (1d * BYTE_UNIT_KILO));
		}

		if (size < BYTE_UNIT_GIGA) {
			return String.format("%5.1fm", size / (1d * BYTE_UNIT_MEGA));
		}

		if (size < BYTE_UNIT_TERA) {
			return String.format("%5.1fg", size / (1d * BYTE_UNIT_GIGA));
		}

		return String.format("%5.1ft", size / (1d * BYTE_UNIT_TERA));
	}
1038519
String formatUnits(int units) {
		switch (unitType) {
			case ENGLISH:
				return NumberFormat.getDecimalFormat().format(units) + (widthInUnitsIsMiles ? " mi" : " yd");
			case ENGLISH_FOOT:
				return NumberFormat.getDecimalFormat().format(units) + (widthInUnitsIsMiles ? " mi" : " ft");
			case METRIC:
				if (units < 10000) {
					return NumberFormat.getDecimalFormat().format(units) + " m";
				} else {
					return NumberFormat.getDecimalFormat().format((double) units / 1000) + " km";
				}

			case CRS:
				return NumberFormat.getDecimalFormat().format(units) + " u";

			default:
				throw new IllegalStateException("Unknown unit type " + unitType);
		}
	}
349417
def pad_z(pts, value=0.0):
    """"""
    pts = np.asarray(pts)
    if pts.shape[-1] < 3:
        if len(pts.shape) < 2:
            return np.asarray((pts[0], pts[1], value), dtype=pts.dtype)
        pad_col = np.full(len(pts), value, dtype=pts.dtype)
        pts = np.asarray((pts.T[0], pts.T[1], pad_col)).T
    return pts
1111140
def unit(self):
        """"""
        return Vector(
            (self.x / self.magnitude()),
            (self.y / self.magnitude()),
            (self.z / self.magnitude())
        )
842840
def format_metric_values(self, metric_values):
    """"""

    # Early in training, metric_values may actually be None.
    loss_str = 'N/A'
    accuracy_str = 'N/A'
    try:
      loss_str = 'loss: %.3f' % metric_values[0]
      accuracy_str = 'accuracy: %.3f' % metric_values[1]
    except (TypeError, IndexError):
      pass

    return '%s, %s' % (loss_str, accuracy_str)
802418
def proj_units_to_meters(proj_str):
    """"""
    proj_parts = proj_str.split()
    new_parts = []
    for itm in proj_parts:
        key, val = itm.split('=')
        key = key.strip('+')
        if key in ['a', 'b', 'h']:
            val = float(val)
            if val < 6e6:
                val *= 1000.
                val = '%.3f' % val

        if key == 'units' and val == 'km':
            continue

        new_parts.append('+%s=%s' % (key, val))

    return ' '.join(new_parts)
69405
def filesize(value):
    ''''''
    suffix = 'o'
    for unit in '', 'K', 'M', 'G', 'T', 'P', 'E', 'Z':
        if abs(value) < 1024.0:
            return "%3.1f%s%s" % (value, unit, suffix)
        value /= 1024.0
    return "%.1f%s%s" % (value, 'Y', suffix)
1324660
def byte_str(nBytes, unit='bytes', precision=2):
    
    #return (nBytes * ureg.byte).to(unit.upper())
    if unit.lower().startswith('b'):
        nUnit = nBytes
    elif unit.lower().startswith('k'):
        nUnit =  nBytes / (2.0 ** 10)
    elif unit.lower().startswith('m'):
        nUnit =  nBytes / (2.0 ** 20)
    elif unit.lower().startswith('g'):
        nUnit = nBytes / (2.0 ** 30)
    elif unit.lower().startswith('t'):
        nUnit = nBytes / (2.0 ** 40)
    else:
        raise NotImplementedError('unknown nBytes=%r unit=%r' % (nBytes, unit))
    return repr2(nUnit, precision=precision) + ' ' + unit
334254
def units(self):
        
        self._units, value = self.get_attr_string(self._units, 'units')
        return value
959952
def get_unit(item, text):
    """"""
    group_units = [1, 4, 6, 8, 10]
    group_operators = [3, 5, 7, 9]

    item_units = [item.group(i) for i in group_units if item.group(i)]

    if len(item_units) == 0:
        unit = l.NAMES['dimensionless']
    else:
        dimensions, slash = [], False
        for group in sorted(group_units + group_operators):
            if not item.group(group):
                continue
            if group in group_units:
                surface, power = parse_unit(item, group, slash)
                if clf.USE_CLF:
                    base = clf.disambiguate_unit(surface, text).name
                else:
                    base = l.UNITS[surface][0].name
                dimensions += [{'base': base, 'power': power}]
            elif not slash:
                slash = any(i in item.group(group) for i in [u'/', u' per '])

        unit = get_unit_from_dimensions(dimensions, text)

    logging.debug(u'\tUnit: %s', unit)
    logging.debug(u'\tEntity: %s', unit.entity)

    return unit
40226
def units(cls, scale=1):
        '''
        

        '''
        return [cls(x=scale), cls(y=scale), cls(z=scale)]
1169932
def to_str(delta, extended=False):
    """"""

    total_seconds = delta.total_seconds()
    sign = "-" if total_seconds < 0 else ""
    nanoseconds = abs(total_seconds * _second_size)

    if total_seconds < 1:
        result_str = _to_str_small(nanoseconds, extended)
    else:
        result_str = _to_str_large(nanoseconds, extended)

    return "{}{}".format(sign, result_str)
503815
def unit_vector(self):
        """"""
        return Point2D( self.x / self.magnitude, self.y / self.magnitude )
918083
def interpret(self):
        """"""
        strn = self.lineEdit().text()
        suf = self.opts['suffix']
        if len(suf) > 0:
            if strn[-len(suf):] != suf:
                return False
            #raise Exception("Units are invalid.")
            strn = strn[:-len(suf)]
        try:
            val = fn.siEval(strn)
        except:
            #sys.excepthook(*sys.exc_info())
            #print "invalid"
            return False
        #print val
        return val
1297249
def unit(self, unit):
        
        allowed_values = ["cm", "inch", "foot"]  # noqa: E501
        if unit is not None and unit not in allowed_values:
            raise ValueError(
                "Invalid value for `unit` ({0}), must be one of {1}"  # noqa: E501
                .format(unit, allowed_values)
            )

        self._unit = unit
949071
def format_units(v, step=None, system="si", units=None):
    
    if v is None:
        return 0, ''

    for prefix, size in UnitSystems[system]:
        if condition(v, size, step):
            v2 = v / size
            if v2 - math.floor(v2) < 0.00000000001 and v > 1:
                v2 = float(math.floor(v2))
            if units:
                prefix = "%s%s" % (prefix, units)
            return v2, prefix

    if v - math.floor(v) < 0.00000000001 and v > 1:
        v = float(math.floor(v))
    if units:
        prefix = units
    else:
        prefix = ''
    return v, prefix