Saves a new label, index mapping to the cache.
        Raises a RuntimeError on a conflict.
512433
def write(self, label, index):
        
        if label in self.cache:
            if self.cache[label] != index:
                error_message = 'cache_conflict on label: {} with index: {}\ncache dump: {}'.format(label, index, self.cache)
                raise RuntimeError(error_message)
        else:
            self.cache[label] = index
801115
def add_label(self, doc, label, update_index=True):
        
        label = copy.copy(label)
        assert(label in self.labels.values())
        doc.add_label(label)
        if update_index:
            self.upd_doc(doc)
            self.commit()
1355853
def add(self, label):
        
        self._labels[label.id] = label
        self._dirty = True
169602
def _sync_labels(self, labels_json):
        """""""
        for label_json in labels_json:
            label_id = label_json['id']
            self.labels[label_id] = Label(label_json, self)
658492
def remap_label_indexers(data_obj, indexers, method=None, tolerance=None):
    
    if method is not None and not isinstance(method, str):
        raise TypeError('``method`` must be a string')

    pos_indexers = {}
    new_indexes = {}

    dim_indexers = get_dim_indexers(data_obj, indexers)
    for dim, label in dim_indexers.items():
        try:
            index = data_obj.indexes[dim]
        except KeyError:
            # no index for this dimension: reuse the provided labels
            if method is not None or tolerance is not None:
                raise ValueError('cannot supply ``method`` or ``tolerance`` '
                                 'when the indexed dimension does not have '
                                 'an associated coordinate.')
            pos_indexers[dim] = label
        else:
            idxr, new_idx = convert_label_indexer(index, label,
                                                  dim, method, tolerance)
            pos_indexers[dim] = idxr
            if new_idx is not None:
                new_indexes[dim] = new_idx

    return pos_indexers, new_indexes
113410
async def save(self, db):
        
        kwargs = {}
        for col in self._auto_columns:
            if not self.has_real_data(col.name):
                kwargs[col.name] = await col.auto_generate(db, self)
        self.__dict__.update(kwargs)

        # we have to delete the old index key
        stale_object = await self.__class__.load(db, identifier=self.identifier())
        d = {
            k: (v.strftime(DATETIME_FORMAT) if isinstance(v, datetime) else v)
            for k, v in self.__dict__.items()
        }
        success = await db.hmset_dict(self.redis_key(), d)
        await self.save_index(db, stale_object=stale_object)
        return success
576473
def remove_label(self, doc, label, update_index=True):
        
        doc.remove_label(label)
        if update_index:
            self.upd_doc(doc)
            self.commit()
940660
def put(self, *labels):
        '''
        '''
        puts = []
        for label in labels:
            k1, k2 = self._keys_from_label(label)
            v = self._value_from_label(label)
            puts.append((k1, v))
            puts.append((k2, v))
        self.kvl.put(self.TABLE, *puts)
618439
def save(self, *args, **kwargs):
        """"""
        update = getattr(self, 'instance', None) is not None
        instance = super(
            WithDynamicSerializerMixin,
            self
        ).save(
            *args,
            **kwargs
        )
        view = self._context.get('view')
        if view and update:
            if int(DRF_VERSION[0]) <= 3 and int(DRF_VERSION[1]) < 5:
                # Reload the object on update
                # to get around prefetch cache issues
                # Fixed in DRF in 3.5.0
                instance = self.instance = view.get_object()
        return instance
1133933
def append(label, block)
      if store.key?(label.to_sym) && store[label.to_sym].respond_to?(:<<)
        store[label.to_sym] << block
      else
        store[label.to_sym] = []
        store[label.to_sym] << block
      end
    end
211784
def _update_labels(self, label, pad_box, height, width):
        """"""
        out = label.copy()
        out[:, (1, 3)] = (out[:, (1, 3)] * width + pad_box[0]) / pad_box[2]
        out[:, (2, 4)] = (out[:, (2, 4)] * height + pad_box[1]) / pad_box[3]
        return out
363349
def update_application_key_label(display_code, new_display_code, text)
      @repaint_required = true
      labels = key_labels()
      raise "labels are nil !!!" unless labels
      labels.each_index do |ix|
        lab = labels[ix]
        next if lab.nil?
        if lab[0] == display_code
          labels[ix] = [new_display_code , text]
          $log.debug("updated #{labels[ix]}")
          return true
        end
      end
      return false
    end
652006
def save(self, force_insert=False, force_update=False, using=None,
             update_fields=None):
        
        # Always create a new entry, instead of updating an existing model
        self.pk = None  # pylint: disable=invalid-name
        super(ConfigurationModel, self).save(
            force_insert,
            force_update,
            using,
            update_fields
        )
        cache.delete(self.cache_key_name(*[getattr(self, key) for key in self.KEY_FIELDS]))
        if self.KEY_FIELDS:
            cache.delete(self.key_values_cache_key_name())
821939
def save(self, *args, **kwargs):
        
        if self.created is None:
            self.created = tz_now()
        
        if self.modified is None:
            self.modified = self.created
            
        super(Thread, self).save(*args, **kwargs)
977283
def resp_set_label(self, resp, label=None):
        
        if label:
            self.label=label
        elif resp:
            self.label=resp.label.decode().replace("\x00", "")
321398
def save(self):
        

        api = Client.instance().api

        index_details = {
            'type': self.index_type_obj.type_name
        }

        extra_index_attributes = self.index_type_obj.get_extra_attributes()

        for extra_attribute_key in extra_index_attributes:
            extra_attribute_value = extra_index_attributes[extra_attribute_key]
            index_details[extra_attribute_key] = extra_attribute_value

        query_parameters = {
            'collection': self.collection.name,
        }

        result = api.index.post(data=index_details, **query_parameters)

        self.index_type_obj.is_new = result['isNewlyCreated']
        self.index_type_obj.id = result['id']
277747
def save_all(self):
        
        initial_index = self.currentIndex()
        for i in range(self.count()):
            try:
                self.setCurrentIndex(i)
                self.save_current()
            except AttributeError:
                pass
        self.setCurrentIndex(initial_index)