Return basis vector lengths

    Parameters
    ----------
    lattice : array_like
        Basis vectors given as column vectors
        shape=(3, 3), dtype='double'

    Returns
    -------
    ndarray, shape=(3,), dtype='double'
199037
def _get_lattice_parameters(lattice):
    

    return np.array(np.sqrt(np.dot(lattice.T, lattice).diagonal()),
                    dtype='double')
424521
def gtlike_spectrum_to_vectors(spectrum):
    


    parameters = pyLike.ParameterVector()
    spectrum.getParams(parameters)

    npar = max(parameters.size(), 10)
    o = {'param_names': np.zeros(npar, dtype='S32'),
         'param_values': np.empty(npar, dtype=float) * np.nan,
         'param_errors': np.empty(npar, dtype=float) * np.nan,
         }

    for i, p in enumerate(parameters):
        o['param_names'][i] = p.getName()
        o['param_values'][i] = p.getTrueValue()
        perr = abs(p.error() * p.getScale()) if p.isFree() else np.nan
        o['param_errors'][i] = perr

    return o
883959
def make2d(array, cols=None, dtype=None):
    '''
    

    '''
    if not len(array):
        if cols is None or dtype is None:
            raise RuntimeError(
                "cols and dtype must be specified for empty array"
            )
        return _np.empty((0, cols), dtype=dtype)
    return _np.vstack(array)
341356
def _compute_cols_width(self):
        

        if hasattr(self, "_width"):
            return
        maxi = []
        if self._header:
            maxi = [ self._len_cell(x) for x in self._header ]
        for row in self._rows:
            for cell,i in zip(row, range(len(row))):
                try:
                    maxi[i] = max(maxi[i], self._len_cell(cell))
                except (TypeError, IndexError):
                    maxi.append(self._len_cell(cell))
        items = len(maxi)
        length = reduce(lambda x,y: x+y, maxi)
        if self._max_width and length + items*3 + 1 > self._max_width:
            maxi = [(self._max_width - items*3 -1) / items \
                for n in range(items)]
        self._width = maxi
163164
def vectors(self, array):
        
        if array.ndim != 2:
            raise AssertionError('vector array must be a 2-dimensional array')
        elif array.shape[1] != 3:
            raise RuntimeError('vector array must be 3D')
        elif array.shape[0] != self.n_points:
            raise RuntimeError('Number of vectors be the same as the number of points')

        self.point_arrays[DEFAULT_VECTOR_KEY] = array
        self.active_vectors_name = DEFAULT_VECTOR_KEY
30541
def _embedding_classical_mds(matrix, dimensions=3, additive_correct=False):
    
    if additive_correct:
        dbc = double_centre(_additive_correct(matrix))
    else:
        dbc = double_centre(matrix)
    decomp = eigen(dbc)
    lambda_ = np.diag(np.sqrt(np.abs(decomp.vals[:dimensions])))
    evecs = decomp.vecs[:, :dimensions]
    coords = evecs.dot(lambda_)
    return coords
883931
def get_matrix(self):
        
        # Init matrix (remember, a matrix, not an array)
        a = np.zeros((4, 4), dtype=np.float32)
        w, x, y, z = self.w, self.x, self.y, self.z
        # First row
        a[0, 0] = - 2.0 * (y * y + z * z) + 1.0
        a[1, 0] = + 2.0 * (x * y + z * w)
        a[2, 0] = + 2.0 * (x * z - y * w)
        a[3, 0] = 0.0
        # Second row
        a[0, 1] = + 2.0 * (x * y - z * w)
        a[1, 1] = - 2.0 * (x * x + z * z) + 1.0
        a[2, 1] = + 2.0 * (z * y + x * w)
        a[3, 1] = 0.0
        # Third row
        a[0, 2] = + 2.0 * (x * z + y * w)
        a[1, 2] = + 2.0 * (y * z - x * w)
        a[2, 2] = - 2.0 * (x * x + y * y) + 1.0
        a[3, 2] = 0.0
        # Fourth row
        a[0, 3] = 0.0
        a[1, 3] = 0.0
        a[2, 3] = 0.0
        a[3, 3] = 1.0
        return a
209907
def A(self):
        """"""
        wishart = self._wishart_cdf

        base = np.zeros([wishart.size, wishart.size])
        if wishart.n_min % 2:
            # If matrix has odd number of elements, we need to append a
            # row and a col, in order for the pfaffian algorithm to work
            base = self._make_size_even(base)
        return base
34430
def unit_cell_to_lattice_array(cryst):
    """"""
    a_, b_, c_, alpha, beta, gamma = cryst
    # Convert angles from degrees to radians.
    r_alpha = np.deg2rad(alpha)
    r_beta = np.deg2rad(beta)
    r_gamma = np.deg2rad(gamma)
    # Calculate unit cell volume that is neccessary.
    volume = a_ * b_ * c_ * (
        1 - np.cos(r_alpha)**2 - np.cos(r_beta)**2 - np.cos(r_gamma)**2 + 2 *
        np.cos(r_alpha) * np.cos(r_beta) * np.cos(r_gamma))**0.5
    # Create the orthogonalisation Matrix (M^-1) - lattice matrix
    a_x = a_
    a_y = b_ * np.cos(r_gamma)
    a_z = c_ * np.cos(r_beta)
    b_x = 0
    b_y = b_ * np.sin(r_gamma)
    b_z = c_ * (
        np.cos(r_alpha) - np.cos(r_beta) * np.cos(r_gamma)) / np.sin(r_gamma)
    c_x = 0
    c_y = 0
    c_z = volume / (a_ * b_ * np.sin(r_gamma))
    lattice_array = np.array(
        [[a_x, a_y, a_z], [b_x, b_y, b_z], [c_x, c_y, c_z]])
    return lattice_array
1301097
def lattice_array_to_unit_cell(lattice_array):
    """"""
    cell_lengths = np.sqrt(np.sum(lattice_array**2, axis=0))
    gamma_r = np.arccos(lattice_array[0][1] / cell_lengths[1])
    beta_r = np.arccos(lattice_array[0][2] / cell_lengths[2])
    alpha_r = np.arccos(
        lattice_array[1][2] * np.sin(gamma_r) / cell_lengths[2]
        + np.cos(beta_r) * np.cos(gamma_r)
        )
    cell_angles = [
        np.rad2deg(alpha_r), np.rad2deg(beta_r), np.rad2deg(gamma_r)
        ]
    return np.append(cell_lengths, cell_angles)
901757
def block_lengths(self):
        
        if self._lengths_cache is None:
            try:
                # The first column will have the correct lengths. We have an
                # invariant that requires that all blocks be the same length in a
                # row of blocks.
                self._lengths_cache = np.array(
                    ray.get([obj.length().oid for obj in self._partitions_cache.T[0]])
                    if len(self._partitions_cache.T) > 0
                    else []
                )
            except RayTaskError as e:
                handle_ray_task_error(e)
        return self._lengths_cache
1012089
def getvector(d,s):
    '''
    
    '''
    return np.array([d[s+"x"],d[s+"y"],d[s+"z"]]);
310228
def array(self):
        
        if self._intervals_len:
            if self._array_len != self._intervals_len:
                if not self._array_len:
                    self._array = np.array(self.intervals) \
                        if hasattr(np, 'array') else self.intervals
                else:
                    self._array = np.concatenate((
                        self._array, self.intervals), axis=0) \
                        if hasattr(np, 'concatenate') else \
                        (self._array + self.intervals)
                self._array_len += len(self.intervals)
                self.intervals = []
            return self._array
        return []
1305453
def col_widths(self):
        # type: () -> defaultdict
        
        _widths = defaultdict(int)

        all_rows = [self.headers]
        all_rows.extend(self._rows)

        for row in all_rows:
            for idx, col in enumerate(row):
                _col_l = len(col)
                if _col_l > _widths[idx]:
                    _widths[idx] = _col_l

        return _widths
772752
def block_structure(self):
        
        n, m = self.shape
        if n != m:
            raise AttributeError("block_structure only defined for square "
                                 "matrices")
        for k in range(1, n):
            if ((self.matrix[:k, k:] == 0).all() and
                    (self.matrix[k:, :k] == 0).all()):
                return (k,) + self[k:, k:].block_structure
        return n,
116696
def surface_area(self):
        
        m = self.lattice.matrix
        return np.linalg.norm(np.cross(m[0], m[1]))
76944
def parameter_vector(self):
        """"""
        return np.array([getattr(self, k) for k in self.parameter_names])