Parameters
    ----------
    systematic_utilities : 1D ndarray.
        Should contain the systematic utilities for each each available
        alternative for each observation.

    Returns
    -------
    `systematic_utilities[:, None]`
552324
def _mnl_utility_transform(systematic_utilities, *args, **kwargs):
    
    # Be sure to return a 2D array since other functions will be expecting this
    if len(systematic_utilities.shape) == 1:
        systematic_utilities = systematic_utilities[:, np.newaxis]

    return systematic_utilities
838795
def propose(self):
        

        # Locally store size of matrix
        dims = self.stochastic.value.shape

        # Add normal deviate to value and symmetrize
        dev = rnormal(
            0,
            self.adaptive_scale_factor *
            self.proposal_sd,
            size=dims)
        symmetrize(dev)

        # Replace
        self.stochastic.value = dev + self.stochastic.value
1084676
def p_sysargs(self, p):
        ''
        p[0] = p[1] + (p[3],)
        p.set_lineno(0, p.lineno(1))
1180136
def visibilities(self):
        
        if self._visibilities is not None:
            return self._visibilities
        else:
            return np.ones(self.Ntriangles)
890824
def defUtilityFuncs(self):
        '''
        
        '''
        self.u   = lambda c : utility(c,gam=self.CRRA)  # utility function
        self.uP  = lambda c : utilityP(c,gam=self.CRRA) # marginal utility function
        self.uPP = lambda c : utilityPP(c,gam=self.CRRA)
792243
def ensure_ndarray_or_None(A, shape=None, uniform=None, ndim=None, size=None, dtype=None, kind=None):
     """
    if A is not None:
        return ensure_ndarray(A, shape=shape, uniform=uniform, ndim=ndim, size=size, dtype=dtype, kind=kind)
    else:
        return None
345370
def convert_to_oqhazardlib(
            self, tom, simple_mesh_spacing=1.0,
            complex_mesh_spacing=2.0, area_discretisation=10.0,
            use_defaults=False):
        
        oq_source_model = []
        for source in self.sources:
            if isinstance(source, mtkAreaSource):
                oq_source_model.append(source.create_oqhazardlib_source(
                    tom,
                    simple_mesh_spacing,
                    area_discretisation,
                    use_defaults))
            elif isinstance(source, mtkPointSource):
                oq_source_model.append(source.create_oqhazardlib_source(
                    tom,
                    simple_mesh_spacing,
                    use_defaults))
            elif isinstance(source, mtkSimpleFaultSource):
                oq_source_model.append(source.create_oqhazardlib_source(
                    tom,
                    simple_mesh_spacing,
                    use_defaults))
            elif isinstance(source, mtkComplexFaultSource):
                oq_source_model.append(source.create_oqhazardlib_source(
                    tom,
                    complex_mesh_spacing,
                    use_defaults))
            else:
                raise ValueError('Source type not recognised!')
        return oq_source_model
1233241
def _hotellings_fourier(self):
        
        sigma_2 = self._catalog_object.sigma**2
        # compute residual
        df = self._df #degrees of freedom
        R = self._A - np.dot(self._X, self._Bhat)
        R = np.matrix(R)
        # residual covariance matrix
        Sigma_R = (R.H*R) * (1./df)
        # noise covariance matrix
        #raise TypeError("fourier domain hypothesis tests not implemented yet")
        Zft = np.matrix(self._basis_object._Z)
        Sigma_S = Zft.H*np.matrix(np.diag(sigma_2))*Zft
        # add covariances (sum of multivariate normals is normal)
        Sigma_Z = np.array(Sigma_R + Sigma_S)

        T_2_list = []
        p_value_list = []
        for i in np.arange(0,self._Bhat.shape[0]):

            Bstar       = self._Bhat[i,np.arange(0,np.shape(self._A)[1])]
            lstar       = float(np.shape(Bstar)[0])
            cx          = self._Cx[i,i]
            Einv        = np.linalg.pinv(Sigma_Z)
            Zs          = Bstar/np.sqrt(cx)
            last_part   = np.array(np.matrix(Zs)*np.matrix(Einv)*np.matrix(Zs).H).real
            T_2         = ((df - lstar + 1.)/(df*lstar))*last_part
            p_value     = 1. - stats.f.cdf(T_2, 2.*lstar, 2.*(df - lstar + 1.))
            p_value_list.append(p_value)
            T_2_list.append(T_2)
        # save pvalue results in a table
        results = [['Comparison','Hotellings T^2', "p-value"]]
        for i in np.arange(0,len(self._col_names)):
            results.append([self._col_names[i], T_2_list[i], p_value_list[i]])
        self._results = results
325432
def get_free_dims(model, visible_dims, fixed_dims):
    
    if visible_dims is None:
        visible_dims = np.arange(model.input_dim)
    dims = np.asanyarray(visible_dims)
    if fixed_dims is not None:
        dims = [dim for dim in dims if dim not in fixed_dims]
    return np.asanyarray([dim for dim in dims if dim is not None])
273209
def values(self):
        
        return [
            (
                np.array(dim.numeric_values)
                if (dim.numeric_values and any(~np.isnan(dim.numeric_values)))
                else None
            )
            for dim in self._slice.dimensions
        ]
1226796
def _values_for_argsort(self) -> np.ndarray:
        
        data = self._data.copy()
        data[self._mask] = data.min() - 1
        return data
220141
def multidispatch(*, nargs=None, nouts=None):
    
    def wrapper(f):
        return wraps(f)(MultiDispatchFunction(f, nargs=nargs, nouts=nouts))

    return wrapper
931290
def as_list(self):
        
        if self._dims is None:
            raise ValueError("as_list() is not defined on an unknown TensorShape.")
        return [dim.value for dim in self._dims]
427830
def alternate(*iterables):
    
    items = []
    for tup in zip(*iterables):
        items.extend([item for item in tup])
    return items
1251521
def findbestparams_iso(xsamples):
    
    p = 0.5*np.sum(xsamples.T[3:]**2,axis=0)
    r = np.sum(xsamples.T[:3]**2,axis=0)
    return np.abs(leastsq(deltaH_iso,np.array([10.,10.]), Dfun = None , col_deriv=1,args=(p,r,))[0])
672801
def _candidates_from_grid(self, n=1000):
        """"""
        used_vectors = set(tuple(v) for v in self.X)

        # if every point has been used before, gridding is done.
        grid_size = self.grid_width ** len(self.tunables)
        if len(used_vectors) == grid_size:
            return None

        all_vectors = set(itertools.product(*self._grid_axes))
        remaining_vectors = all_vectors - used_vectors
        candidates = np.array(list(map(np.array, remaining_vectors)))

        np.random.shuffle(candidates)
        return candidates[0:n]
458638
def as_int_array(self):
        
        return self.view(
            type=ndarray,
            dtype=unsigned_int_dtype_with_size_in_bytes(self.itemsize),
        )