return binx, biny, binz corresponding to the global bin number
547212
def xyz(self, idx):
        
        # Not implemented for Python 3:
        # GetBinXYZ(i, x, y, z)
        nx  = self.GetNbinsX() + 2
        ny  = self.GetNbinsY() + 2
        ndim = self.GetDimension()
        if ndim < 2:
            binx = idx % nx
            biny = 0
            binz = 0
        elif ndim < 3:
            binx = idx % nx
            biny = ((idx - binx) // nx) % ny
            binz = 0
        elif ndim < 4:
            binx = idx % nx
            biny = ((idx - binx) // nx) % ny
            binz = ((idx - binx) // nx - biny) // ny
        else:
            raise NotImplementedError
        return binx, biny, binz
113413
def which(bin_name):
    

    with open(os.devnull) as devnull:
        # rc = SP.call(['which', bin_name], stdout=devnull, stderr=devnull)
        rc = SP.call(['which', bin_name])

    return rc
545188
def bins(self) -> List[np.ndarray]:
        """"""
        return [binning.bins for binning in self._binnings]
821434
def bin_number(datapoint, intervals):
  
  index = numpy.searchsorted(intervals, datapoint)
  return [0 if index != i else 1 for i in range(len(intervals) + 1)]
1221276
def int_to_bin(i):
    
    # devide in two parts (bytes)
    i1 = i % 256
    i2 = int(i / 256)
    # make string (little endian)
    return chr(i1) + chr(i2)
909998
def _get_bin_width(stdev, count):
    

    w = int(round((3.5 * stdev) / (count ** (1.0 / 3))))
    if w:
        return w
    else:
        return 1
1120632
def bin_path(self, release=None):
        """"""
        if release:
            for r in self.releases:
                if release in r:
                    return self.releases[r]
            raise MongoOrchestrationError("No such release '%s' in %r"
                                          % (release, self.releases))
        if self.default_release:
            return self.releases[self.default_release]
        if self.releases:
            return list(self.releases.values())[0]
        return ''
810326
def get_missing_bins(original, trimmed):
    

    original_diag = np.diag(original)
    trimmed_diag = np.diag(trimmed)
    index = []
    m = min(original.shape)
    for j in range(min(trimmed.shape)):
        k = 0
        while original_diag[j + k] != trimmed_diag[j] and k < 2 * m:
            k += 1
        index.append(k + j)
    return np.array(index)
720589
def find_binary(self, binary):
        
        if os.path.exists(binary):
            return binary

        # Extract out the filename if we were given a full path
        binary_name = os.path.basename(binary)

        # Gather $PATH
        search_paths = os.environ['PATH'].split(':')

        # Extra paths to scan...
        default_paths = [
            '/usr/bin',
            '/bin'
            '/usr/local/bin',
            '/usr/sbin',
            '/sbin'
            '/usr/local/sbin',
        ]

        for path in default_paths:
            if path not in search_paths:
                search_paths.append(path)

        for path in search_paths:
            if os.path.isdir(path):
                filename = os.path.join(path, binary_name)
                if os.path.exists(filename):
                    return filename

        return binary
257249
def bin_priority(op,left,right):
  ""
  # note: recursion limits protect this from infinite looping. I'm serious. (i.e. it will crash rather than hanging)
  if isinstance(left,BinX) and left.op < op: return bin_priority(left.op,left.left,bin_priority(op,left.right,right))
  elif isinstance(left,UnX) and left.op < op: return un_priority(left.op,BinX(op,left.val,right)) # note: obviously, no need to do this when right is a UnX
  elif isinstance(right,BinX) and right.op < op: return bin_priority(right.op,bin_priority(op,left,right.left),right.right)
  else: return BinX(op,left,right)
1110463
def get_bin(self, *args, **kwargs):
        """"""
        # Implemented from kitosid template for -
        # osid.resource.BinLookupSession.get_bin
        return Bin(
            self._provider_manager,
            self._get_provider_session('bin_lookup_session').get_bin(*args, **kwargs),
            self._runtime,
            self._proxy)
800080
def bin(self, s):
        
        return str(s) if s<=1 else bin(s>>1) + str(s&1)
30992
def info(self):
        
        b = self.bin()
        for i in range(len(b), 0, -1):
            if b[:i] in self._range[self.v]:
                return self._range[self.v][b[:i]]
        return 'UNKNOWN'
339886
def binOp(op, indx, amap, bmap, fill_vec):
    '''
    
    '''
    def op_or_missing(id):
        va = amap.get(id, None)
        vb = bmap.get(id, None)
        if va is None or vb is None:
            # This should create as many elements as the number of columns!?
            result = fill_vec
        else:
            try:
                result = op(va, vb)
            except Exception:
                result = None
            if result is None:
                result = fill_vec
            return result
    seq_arys = map(op_or_missing, indx)
    data = np.vstack(seq_arys)
    return data
527085
def get_possible_splits(n):
    
    get_bin = lambda x, n: x >= 0 and str(bin(x))[2:].zfill(n) or "-" + str(bin(x))[3:].zfill(n)
    possible_splits = []
    for i in range(2**(n - 1)):
        possible_splits.append(get_bin(i, n - 1))
    return possible_splits
1309205
def _bin_zfill(num, width=None):
    
    s = bin(num)[2:]
    return s if width is None else s.zfill(width)
515344
def as_bin(self, *args, **kwargs):
        
        f = io.BytesIO()
        self.stream(f, *args, **kwargs)
        return f.getvalue()