Exemple #1
0
    def featurize(self, structure):
        """Convert a pymatgen Structure to an immutable IStructure,

        Args:
            structure (`pymatgen.core.structure.Structure`): A structure.

        Returns:
            (`pymatgen.core.structure.IStructure`): An immutable IStructure
                object.
        """
        return [IStructure.from_sites(structure)]
Exemple #2
0
    def featurize(self, structure):
        """Convert a pymatgen Structure to an immutable IStructure,

        Args:
            structure (`pymatgen.core.structure.Structure`): A structure.

        Returns:
            (`pymatgen.core.structure.IStructure`): An immutable IStructure
                object.
        """
        return [IStructure.from_sites(structure)]
Exemple #3
0
def get_all_nearest_neighbors(method, structure):
    """Get the nearest neighbor list of a structure

    Args:
        method (NearNeighbor) - Method used to compute nearest neighbors
        structure (IStructure) - Structure to study
    Returns:
        Output of `method.get_all_nn_info(structure)`
    """

    # pymatgen does not hash Structure objects, so we need
    #  to convert from Structure to the immutatble IStructure method
    if isinstance(structure, Structure):
        structure = IStructure.from_sites(structure)
    return _get_all_nearest_neighbors(method, structure)
def structure_stats(X):
    """
    Transform the input X to immutable IStructure to use caching and call
    _structure_stats .
    Args:
        X: iterable structures, can be pymatgen Structure or IStructure objects

    Returns:
        _structure_stats
    """
    X_struct = list()
    for structure in X:
        if isinstance(structure, Structure):
            X_struct.append(IStructure.from_sites(structure))
        elif isinstance(structure, IStructure):
            X_struct.append(structure)
    return _structure_stats(tuple(X_struct))
Exemple #5
0
    def _get_all_nearest_neighbors(method, crystal):
        '''
        Get the nearest neighbor list of a structure

        Args:
            method: method used to compute nearest_neighbors
            crystal:  pymatgen structure

        Returns:
            nearest neighbors
        '''
        # check that the passed crystal is a pymatgen structure object
        if isinstance(crystal, Structure):
            # make the structure an immutable object
            crystal = IStructure.from_sites(crystal)

        # get the voronoi info of the crystal
        return method.get_all_nn_info(crystal)