Return a formatted string representing a number value that should be
 printed as a label.
774816
def label(value, increment)
      label = if increment
                if increment >= 10 || (increment * 1) == (increment * 1).to_i.to_f
                  sprintf('%0i', value)
                elsif increment >= 1.0 || (increment * 10) == (increment * 10).to_i.to_f
                  sprintf('%0.1f', value)
                elsif increment >= 0.1 || (increment * 100) == (increment * 100).to_i.to_f
                  sprintf('%0.2f', value)
                elsif increment >= 0.01 || (increment * 1000) == (increment * 1000).to_i.to_f
                  sprintf('%0.3f', value)
                elsif increment >= 0.001 || (increment * 10000) == (increment * 10000).to_i.to_f
                  sprintf('%0.4f', value)
                else
                  value.to_s
                end
              elsif (@spread.to_f % (@marker_count.to_f==0 ? 1 : @marker_count.to_f) == 0) || !@y_axis_increment.nil?
                value.to_i.to_s
              elsif @spread > 10.0
                sprintf('%0i', value)
              elsif @spread >= 3.0
                sprintf('%0.2f', value)
              else
                value.to_s
              end

      parts = label.split('.')
      parts[0].gsub!(/(\d)(?=(\d\d\d)+(?!\d))/, "\\1#{THOUSAND_SEPARATOR}")
      parts.join('.')
    end
1168615
def as_colr(self, label_args=None, value_args=None):
        
        label_args = label_args or {'fore': 'red'}
        value_args = value_args or {'fore': 'blue', 'style': 'bright'}
        return Colr(self.default_format.format(
            label=Colr(self.label, **label_args),
            value=Colr(repr(self.value), **value_args),
        ))
1271018
def printable(data):
        
        result = ''
        for c in data:
            if 32 < ord(c) < 128:
                result += c
            else:
                result += '.'
        return result
91936
def type(self):
        """"""
        if isinstance(self.value, numbers.Number):
            return "number"
        if isinstance(self.value, basestring):
            return "string"
        return "unknown"
498489
def label(self,x,y,label,offset=[0,0]):
        """"""
        (xc,yc)=self.p2c([x,y])
        return self.create_text(xc-offset[0],yc-offset[1],text=label)
1338370
def get_random_label():
    
    return ''.join(random.choice(string.ascii_uppercase + string.digits) \
                   for _ in range(15))
1227218
def nice_number_string(number, decimal_places=2):
        """"""
        if number == np.round(number):
            return str(int(number))
        elif number < 1 and number > 0:
            inverse = 1 / number
            if int(inverse) == np.round(inverse):
                return r'\frac{{1}}{{{}}}'.format(int(inverse))
        else:
            template = '{{:.{0}}}'.format(decimal_places)
            return template.format(number)
288106
def make_label(loss, key):
    ''''''
    algo, rate, mu, half, reg = key
    slots, args = ['{:.3f}', '{}', 'm={:.3f}'], [loss, algo, mu]
    if algo in 'SGD NAG RMSProp Adam ESGD'.split():
        slots.append('lr={:.2e}')
        args.append(rate)
    if algo in 'RMSProp ADADELTA ESGD'.split():
        slots.append('rmsh={}')
        args.append(half)
        slots.append('rmsr={:.2e}')
        args.append(reg)
    return ' '.join(slots).format(*args)
927814
def label(self) -> str:
        """"""
        label = self.expression.replace("_", "\\;")
        if self.units_kind:
            symbol = wt_units.get_symbol(self.units)
            for v in self.variables:
                vl = "%s_{%s}" % (symbol, v.label)
                vl = vl.replace("_{}", "")  # label can be empty, no empty subscripts
                label = label.replace(v.natural_name, vl)
            units_dictionary = getattr(wt_units, self.units_kind)
            label += r"\,"
            label += r"\left("
            label += units_dictionary[self.units][2]
            label += r"\right)"
        label = r"$\mathsf{%s}$" % label
        return label
112530
def apnumber(value):
    """"""
    try:
        value = int(value)
    except (TypeError, ValueError):
        return value
    if not 0 < value < 10:
        return str(value)
    return (_('one'), _('two'), _('three'), _('four'), _('five'), _('six'),
            _('seven'), _('eight'), _('nine'))[value - 1]
1227363
def AddLabel(self, label):
    
    if not isinstance(label, py2to3.STRING_TYPES):
      raise TypeError('label is not a string type. Is {0:s}'.format(
          type(label)))
    if not self._VALID_LABEL_REGEX.match(label):
      raise ValueError((
          'Unsupported label: "{0:s}". A label must only consist of '
          'alphanumeric characters or underscores.').format(label))

    if label not in self.labels:
      self.labels.append(label)
33320
def _pprint(self, element, dim_label, vals):
        

        if vals.dtype.kind not in 'SU':
            dim = element.gridded.get_dimension(dim_label)
            return [dim.pprint_value(v) for v in vals]

        return vals
1066581
def to_str(number):
    
    states = globals()
    for name, value in states.items():
        if number == value and name.isalpha() and name.isupper():
            return name
    return '(unknown state %d)' % number
205085
def time_label(intvl, return_val=True):
    """"""
    # Monthly labels are 2 digit integers: '01' for jan, '02' for feb, etc.
    if type(intvl) in [list, tuple, np.ndarray] and len(intvl) == 1:
        label = '{:02}'.format(intvl[0])
        value = np.array(intvl)
    elif type(intvl) == int and intvl in range(1, 13):
        label = '{:02}'.format(intvl)
        value = np.array([intvl])
    # Seasonal and annual time labels are short strings.
    else:
        labels = {'jfm': (1, 2, 3),
                  'fma': (2, 3, 4),
                  'mam': (3, 4, 5),
                  'amj': (4, 5, 6),
                  'mjj': (5, 6, 7),
                  'jja': (6,  7,  8),
                  'jas': (7, 8, 9),
                  'aso': (8, 9, 10),
                  'son': (9, 10, 11),
                  'ond': (10, 11, 12),
                  'ndj': (11, 12, 1),
                  'djf': (1, 2, 12),
                  'jjas': (6, 7, 8, 9),
                  'djfm': (12, 1, 2, 3),
                  'ann': range(1, 13)}
        for lbl, vals in labels.items():
            if intvl == lbl or set(intvl) == set(vals):
                label = lbl
                value = np.array(vals)
                break
    if return_val:
        return label, value
    else:
        return label
820305
def format_column(self, label, column):
        """"""
        if len(column) == 0:
            val_width = 0
        else:
            val_width = max(len(self.format_value(v)) for v in column)
        val_width = min(val_width, self.max_width)
        width = max(val_width, len(str(label)), self.min_width, len(self.etc))
        def pad(value, label=False):
            if label:
                raw = value
            else:
                raw = self.format_value(value)
            if len(raw) > width:
                prefix = raw[:width-len(self.etc)] + self.etc
            else:
                prefix = raw
            return prefix.ljust(width)
        return pad
249350
def label(self):
        
        value = self._element_dict.get("value")
        type_name = type(value).__name__

        if type_name == "NoneType":
            return ""

        if type_name == "list":
            # ---like '10-15' or 'A-F'---
            return "-".join([str(item) for item in value])

        if type_name in ("float", "int"):
            return str(value)

        if type_name in ("str", "unicode"):
            return value

        # ---For CA and MR subvar dimensions---
        name = value.get("references", {}).get("name")
        return name if name else ""
1083749
def as_colr(
            self, label_args=None, type_args=None, value_args=None):
        
        label_args = label_args or {'fore': 'red'}
        type_args = type_args or {'fore': 'yellow'}
        value_args = value_args or {'fore': 'blue', 'style': 'bright'}

        return Colr(self.default_format.format(
            label=Colr(':\n    ').join(
                Colr('Expecting style value', **label_args),
                Colr(',\n    ').join(
                    Colr(', ').join(
                        Colr(v, **type_args)
                        for v in t[1]
                    )
                    for t in _stylemap
                )
            ),
            value=Colr(repr(self.value), **value_args)
        ))