graph2mat.core.data.table

Storage of global basis information for a group of configurations.

In a dataset, different point types are represented by an integer that is the type index. However, there are moments in which information of what that type means is required. E.g. to know what’s the size of the basis for that point or what are its irreps.

All the data for the types that a model might see is stored in an object that we call a “Table”.

In a typical matrix, there will be elements that belong to connections between different points. Therefore, these tables also need to keep track of edge types.

Classes

AtomicTableWithEdges(atoms)

Variant of BasisTableWithEdges for the case in which points are atoms.

BasisTableWithEdges(basis[, get_point_matrix])

Stores the unique types of points in the system, with their basis and the possible edges.

class graph2mat.core.data.table.AtomicTableWithEdges(atoms: Sequence[Atom])[source]

Bases: BasisTableWithEdges

Variant of BasisTableWithEdges for the case in which points are atoms.

This class mostly just adds a few aliases to the methods of BasisTableWithEdges by replacing “point” to “atom” in the method names. It also provides some methods to create a table from atomic basis.

See also

BasisTableWithEdges

The class that actually does the work.

R: ndarray
__init__(atoms: Sequence[Atom])[source]
atom_block_pointer(atom_types: Sequence[int])[source]
property atom_block_shape
property atom_block_size
atom_type_to_edge_type(atom_type: ndarray)[source]
property atomic_DM
atoms: List[Atom]
basis: List[PointBasis]
basis_convention: Literal['cartesian', 'spherical', 'siesta_spherical']
basis_size: ndarray
change_of_basis: ndarray
change_of_basis_inv: ndarray
edge_block_shape: ndarray
edge_block_size: ndarray
edge_type: ndarray
edge_type_to_point_types: ndarray
file_contents: List[str] | None
file_names: List[str] | None
classmethod from_basis_dir(basis_dir: str, basis_ext: str = 'ion.xml', no_basis_atoms: dict | None = None) AtomicTableWithEdges[source]

Generates a table from a directory containing basis files.

Parameters:
  • basis_dir – The directory containing the basis files.

  • basis_ext – The extension of the basis files.

classmethod from_basis_glob(basis_glob: str | Generator, no_basis_atoms: dict | None = None) AtomicTableWithEdges[source]

Generates a table from basis files that match a glob pattern.

Parameters:

basis_glob – The glob pattern to match the basis files.

point_block_shape: ndarray
point_block_size: ndarray
point_matrix: List[ndarray] | None
types: List[str | int]
property zs
class graph2mat.core.data.table.BasisTableWithEdges(basis: Sequence[PointBasis], get_point_matrix: Callable | None = None)[source]

Bases: object

Stores the unique types of points in the system, with their basis and the possible edges.

It also knows the size of the blocks, and other type dependent variables.

Its function is to assist in pre and post processing data by providing a centralized source of truth for the basis that a model should be able to deal with.

Parameters:
  • basis (List[graph2mat.core.data.basis.PointBasis]) – List of PointBasis objects for types that are (possibly) present in the systems of interest.

  • get_point_matrix

    A function that takes a PointBasis object and returns the matrix that is a constant for that type of point.

    The constant matrix can be substracted from the training examples so that the models only need to learn the part that is different.

    A sensible choice for this constant matrix would be the matrix of the point if it was isolated in the system, because then what the models learn is the result of the interaction with other points.

    However, this might not make any sense for your particular problem. In that case just don’t use this argument.

basis

List of PointBasis objects that this table knows about.

Type:

List[graph2mat.core.data.basis.PointBasis]

basis_convention

The spherical harmonics convention used for the basis.

Type:

Literal[‘cartesian’, ‘spherical’, ‘siesta_spherical’]

types

Type identifier for each point basis.

Type:

List[str | int]

point_matrix

The matrix that is constant for each type of point.

See the get_point_matrix argument for more details.

Type:

List[numpy.ndarray] | None

edge_type

Shape (n_point_types, n_point_types). The edge type for each pair of point types.

Type:

numpy.ndarray

R

Shape (n_point_types,). The reach of each point type.

Type:

numpy.ndarray

basis_size

Shape (n_point_types,). The number of basis functions for each point type.

Type:

numpy.ndarray

point_block_shape

Shape (n_point_types, 2). The shape of self-interacting matrix blocks of each point type.

Type:

numpy.ndarray

point_block_size

Shape (n_point_types,). The number of elements for self-interacting matrix blocks of each point type.

Type:

numpy.ndarray

edge_block_shape

Shape (n_edge_types, 2). The shape of interaction matrix blocks of each edge type.

Type:

numpy.ndarray

edge_block_size

Shape (n_edge_types,). The number of elements for interaction matrix blocks of each edge type.

Type:

numpy.ndarray

change_of_basis

Shape (3, 3). The change of basis matrix from cartesian to the convention of the basis.

Type:

numpy.ndarray

change_of_basis_inv

Shape (3, 3). The change of basis matrix from the convention of the basis to cartesian.

Type:

numpy.ndarray

file_names

If the basis was read from files, this might store the names of the files.

For saving/loading purposes.

Type:

List[str] | None

file_contents

If the basis was read from files, this might store the contents of the files.

For saving/loading purposes.

Type:

List[str] | None

edge_type_to_point_types

Shape (n_edge_types, 2).

For each (positive) edge index, returns the pair of point types that make it.

Type:

numpy.ndarray

R: ndarray
__init__(basis: Sequence[PointBasis], get_point_matrix: Callable | None = None)[source]
basis: List[PointBasis]
basis_convention: Literal['cartesian', 'spherical', 'siesta_spherical']
basis_size: ndarray
change_of_basis: ndarray
change_of_basis_inv: ndarray
edge_block_pointer(edge_types: Sequence[int])[source]

Pointers to the beggining of edge blocks in a flattened matrix.

Given a flat array that contains all the elements of the matrix corresponing to matrix blocks of interactions between two different points, the indices returned here point to the beggining of the values for each block.

These pointers are useful to recreate the full matrix, for example.

Parameters:

edge_types – The type indices for the edges in the system, in the order in which they appear in the flattened matrix.

edge_block_shape: ndarray
edge_block_size: ndarray
edge_type: ndarray
edge_type_to_point_types: ndarray
file_contents: List[str] | None
file_names: List[str] | None
get_sisl_atoms() List[Atom][source]

Returns a list of sisl atoms corresponding to the basis.

If the basis does not contain atoms, PointBasis objects are converted to atoms.

index_to_type(index: int) str | int[source]

Converts from the index of the point type to the type ID.

Parameters:

index – The index of the point type in the table for which the ID is desired.

maxR() float[source]

Maximum cutoff radius in the basis.

point_block_pointer(point_types: Sequence[int]) ndarray[source]

Pointers to the beggining of node blocks in a flattened matrix.

Given a flat array that contains all the elements of the matrix corresponing to self-interacting matrix blocks, the indices returned here point to the beggining of the values for each block.

These pointers are useful to recreate the full matrix, for example.

Parameters:

point_types – The type indices for the points in the system, in the order in which they appear in the flattened matrix.

point_block_shape: ndarray
point_block_size: ndarray
point_matrix: List[ndarray] | None
point_type_to_edge_type(point_type: ndarray) int | ndarray[source]

Converts pairs of point types to edge types.

Parameters:

point_type – Shape (2, n_edges) Pair of point types for each edge.

type_to_index(point_type: str | int) int[source]

Converts from the type ID to the index of the point type in the table.

Parameters:

point_type – The type ID of the point type for which the index in the table is desired.

types: List[str | int]
types_to_indices(types: Sequence) ndarray[source]

Converts from an array of types IDs to their indices in the basis table.

Parameters:

types – The array of types to convert.

See also

type_to_index

The function used to convert each type.