Equivalent numpy's nonzero but returns a tuple of Varibles.
435369
def _nonzero(self):
        
        # TODO we should replace dask's native nonzero
        # after https://github.com/dask/dask/issues/1076 is implemented.
        nonzeros = np.nonzero(self.data)
        return tuple(Variable((dim), nz) for nz, dim
                     in zip(nonzeros, self.dims))
482918
def Any(a, axis, keep_dims):
    
    return np.any(a, axis=axis if not isinstance(axis, np.ndarray) else tuple(axis),
                  keepdims=keep_dims),
17997
def get_bin_indices(self, values):
        """"""
        return tuple([self.get_axis_bin_index(values[ax_i], ax_i)
                      for ax_i in range(self.dimensions)])
589441
private Collection<Tuple> getUncombinedTuples( List<VarDef> uncombinedVars, int defaultTupleSize)
    {
    Collection<Tuple> tuples = TupleCombiner.getTuples( uncombinedVars, defaultTupleSize);
    if( defaultTupleSize == 1)
      {
      for( Tuple tuple : tuples)
        {
        VarValueDef value = tuple.getBindings().next().getValueDef();
        tuple.setOnce( value.getType() == VarValueDef.Type.ONCE);
        }
      }
    return tuples;
    }
1320130
def fn_var(self, a, axis=None):
        

        return numpy.nanvar(self._to_ndarray(a), axis=axis)
65030
public static Collection<Tuple> getTuples( List<VarDef> varDefs, int tupleSize)
    {
    if( tupleSize < 1)
      {
      tupleSize = varDefs.size();
      }
    int varEnd = varDefs.size() - tupleSize + 1;
    if( varEnd <= 0)
      {
      throw new IllegalArgumentException( "Can't create " + tupleSize + "-tuples for " + varDefs.size() + " combined variables");
      }
    return getTuples( varDefs, 0, varEnd, tupleSize);
    }
80376
def _safe_squeeze(arr, *args, **kwargs):
    
    out = np.squeeze(arr, *args, **kwargs)
    if np.ndim(out) == 0:
        out = out.reshape((1,))
    return out
493572
def variable_absolute(self, a: float) -> mm.ModelMapper:
        
        return self.previous_variable.mapper_from_gaussian_tuples(self.gaussian_tuples, a=a)
555311
def canorth(S):
    ""
    E,U = np.linalg.eigh(S)
    for i in range(len(E)):
        U[:,i] = U[:,i] / np.sqrt(E[i])
    return U
389658
def nbytes(self):
        """"""
        try:
            N, L, I = get_shape([self])
        except AllEmptyProbabilityMaps:
            return 0
        return BYTES_PER_FLOAT * N * L * I
398912
def val_to_bin_bounded(edges, x):
    """"""
    nbins = len(edges) - 1
    ibin = val_to_bin(edges, x)
    ibin[ibin < 0] = 0
    ibin[ibin > nbins - 1] = nbins - 1
    return ibin
883500
def _to_args(x):
    """"""
    if not isinstance(x, (list, tuple, np.ndarray)):
        x = [x]
    return x
264758
def as_tuple(self):
        
        ptr = self._pointer
        return (ptr.xx, ptr.yx, ptr.xy, ptr.yy, ptr.x0, ptr.y0)
242446
def _scalar2array(d):
    """"""
    da = {}
    for k, v in d.items():
        if '_' not in k:
            da[k] = v
        else:
            name = ''.join(k.split('_')[:-1])
            ind = k.split('_')[-1]
            dim = len(ind)
            if name not in da:
                shape = tuple(3 for i in range(dim))
                da[name] = np.empty(shape, dtype=complex)
                da[name][:] = np.nan
            da[name][tuple(int(i) - 1 for i in ind)] = v
    return da
216438
def asfloat(vari, limit=None):
    
    if limit is None:
        limit = 10**300
    if isinstance(vari, Poly):
        core = vari.A.copy()
        for key in vari.keys:
            core[key] = core[key]*1.
        return Poly(core, vari.dim, vari.shape, float)

    return numpy.asfarray(vari)
272158
def normalise(v):
    

    vn = np.sqrt(np.sum(v**2, 0))
    vn[vn == 0] = 1.0
    return np.asarray(v / vn, dtype=v.dtype)
207355
def paramsarraybounds(self):
        """"""
        bounds = []
        for (i, param) in self._index_to_param.items():
            if isinstance(param, str):
                bounds.append(self.model.PARAMLIMITS[param])
            elif isinstance(param, tuple):
                bounds.append(self.model.PARAMLIMITS[param[0]])
            else:
                raise ValueError("Invalid param type")
        bounds = [(tup[0] + ALMOST_ZERO, tup[1] - ALMOST_ZERO) for tup in bounds]
        assert len(bounds) == len(self._index_to_param)
        return tuple(bounds)