Adapt this binning so that it contains all bins of another binning.

        Parameters
        ----------
        other: BinningBase
501568
def adapt(self, other: 'BinningBase'):
        
        # TODO: in-place arg
        if np.array_equal(self.bins, other.bins):
            return None, None
        elif not self.is_adaptive():
            raise RuntimeError("Cannot adapt non-adaptive binning.")
        else:
            return self._adapt(other)
1255639
def update(self, other):
        
        if isinstance(other, NdMapping):
            dims = [d for d in other.kdims if d not in self.kdims]
            if len(dims) == other.ndims:
                raise KeyError("Cannot update with NdMapping that has"
                               " a different set of key dimensions.")
            elif dims:
                other = other.drop_dimension(dims)
            other = other.data
        for key, data in other.items():
            self._add_item(key, data, sort=False)
        if self.sort:
            self._resort()
486363
def bins(start, end):
        
        if end - start < 536870912:
            offsets = [585, 73, 9, 1]
        else:
            raise BigException
            offsets = [4681, 585, 73, 9, 1]
        binFirstShift = 17
        binNextShift = 3

        start = start >> binFirstShift
        end = (end - 1)  >> binFirstShift

        bins = [1]
        for offset in offsets:
            bins.extend(range(offset + start, offset + end + 1))
            start >>= binNextShift
            end >>= binNextShift
        return frozenset(bins)
1096400
def _iand(self, other):
		
		# TODO do we have to create a bag from the other first?
		if not isinstance(other, _basebag):
			other = self._from_iterable(other)
		for elem, old_count in set(self.counts()):
			other_count = other.count(elem)
			new_count = min(other_count, old_count)
			self._set_count(elem, new_count)
		return self
315340
def intersection(self,other):
        
        if self.everything:
            if other.everything:
                return DiscreteSet()
            else:
                return DiscreteSet(other.elements)
        else:
            if other.everything:
                return DiscreteSet(self.elements)
            else:
                return DiscreteSet(self.elements.intersection(other.elements))
531681
def symmetric_difference_update(self, other):
        # type: (Iterable[Any]) -> _BaseSet
        
        intersect = self.intersection(other)
        self.remove(*intersect)
        for elem in set(other).difference(intersect):
            self.add(elem)
        return self
605208
def _other_to_dict(self, other):
    
    if isinstance(other, ModelBase):
      return other.to_dict()
    elif isinstance(other, list):
      # TODO: what if it's not a list?
      return [self._other_to_dict(i) for i in other]
    else:
      return other
1009287
def setBins(self, bins):
        
        self._bins = bins
        self._counts = np.zeros_like(self._bins)
        bar_width = bins[0]*1.5
        self.histo.setOpts(x=bins, height=self._counts, width=bar_width)
        self.setXlim((0, bins[-1]))
1118652
def zip(self, other):
        
        return self.__class__(p1 % p2 for p1, p2 in zip(self, other))
444529
def sinter(self, *other_sets):
        
        return self.db.sinter([self.key] + [s.key for s in other_sets])
154198
def _isub(self, other):
		
		if isinstance(other, _basebag):
			for elem, other_count in other.counts():
				try:
					self._increment_count(elem, -other_count)
				except ValueError:
					self._set_count(elem, 0)
		else:
			for elem in other:
				try:
					self._increment_count(elem, -1)
				except ValueError:
					pass
		return self
944822
def numpy_bins(self) -> List[np.ndarray]:
        """"""
        return [binning.numpy_bins for binning in self._binnings]
92453
public boolean intersect(Envelope2D other) {
		if (isEmpty() || other.isEmpty()) {
			setEmpty();
			return false;
		}

		if (other.xmin > xmin)
			xmin = other.xmin;

		if (other.xmax < xmax)
			xmax = other.xmax;

		if (other.ymin > ymin)
			ymin = other.ymin;

		if (other.ymax < ymax)
			ymax = other.ymax;

		boolean bIntersecting = xmin <= xmax && ymin <= ymax;

		if (!bIntersecting)
			setEmpty();

		return bIntersecting;
	}
606390
def union(other)
      if other.is_a?(AbsoluteSet) and other.universe.eql?(@universe)
        copy(:mask => @mask | other.mask)
      elsif other.is_a?(AbstractSet) and other.infinite?
        other.union(self)
      else
        copy(:mask => @mask | as_mask(other, true))
      end
    end
843422
def add(self, histogram: Histogram1D):
        """"""
        if self.binning and not self.binning == histogram.binning:
            raise ValueError("Cannot add histogram with different binning.")
        self.histograms.append(histogram)
491245
function binadd(bin1, bin2){
  var i1 = bin1.length;
  var i2 = bin2.length;
  var i3 = (i1 > i2) ? (i1 + 1) : (i2 + 1);
  var result = new Array(i3);
  var c = 0;
  // Add the two arrays as long as there exist elements in the arrays
  while((i1 > 0) && (i2 > 0)){
    i1--;
    i2--;
    i3--;
    if(bin1[i1]){c++;}
    if(bin2[i2]){c++;}
    result[i3] = (c%2) ? true : false;
    c >>= 1;
  }
  // copy the remaining elements
  if(i1){
    for(var i=0; i<i1; i++){result[i+1] = bin1[i];}
  }else{
    for(var i=0; i<i2; i++){result[i+1] = bin2[i];}
  }
  // add the remaining carry
  var carry = c ? true : false;
  while(c && (i3 > 1)){
    i3--;
    result[i3] = !result[i3];
    c = !result[i3];
  }
  // Return result with carry if necessary
  if (c==1){
    result[0] = true;
    return result;
  }else{
    return result.slice(1);
  }
}
313238
def _swap(self, other):
        
        self.__dict__, other.__dict__ = other.__dict__, self.__dict__