Skip to content

class_property.py

Contains a abstract class to define strategies to fill a grid with different
properties.

StrategyProperty

Bases: ABC

An abstract base class for defining strategies to fill a grid with
properties.

Attributes

self.__name : str
Name of the computed property.

self._atom_constant : AtomConstant
The atom constant object to access different constant.

Source code in src/smiffer/grid/property_strategy/class_property.py
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
class StrategyProperty(ABC):
    """An abstract base class for defining strategies to fill a grid with
    properties.

    Attributes
    ----------
    self.__name : `str`
        Name of the computed property.

    self._atom_constant : `AtomConstant`
        The atom constant object to access different constant.
    """

    def __init__(self, name: str, atom_constant):
        """Define the strategy for property computation.

        Parameters
        ----------
        name : `str`
            Name of the property.

        atom_constant : `AtomConstant`
            An object containing constant linked to atoms.
        """
        self._name: str = name
        self._atom_constant = atom_constant

    def __str__(self) -> str:
        """Redefine `print()` comportement.

        Returns
        -------
        `str`
            The new message to print.
        """
        to_print: str = (
            f'Current used property is "{self._name}". Linked '
            "to an atom_constant object. "
            f"{self._atom_constant}."
        )

        return to_print

    def name(self) -> str:
        """`self.__name` getter.

        Returns
        -------
        `str`
            The property name.
        """
        return self._name

    @abstractmethod
    def populate_grid(self, grid: np.ndarray, grid_object) -> None:
        """Define an abstract method in order to fill a grid with given
        properties.

        Parameters
        ----------
        grid : `np.ndarray`
            The grid to fill.

        grid_object : `Grid`
            The grid object to access all attributes.

        Returns
        -------
        None
            To skip an iteration.
        """

__init__(name, atom_constant)

Define the strategy for property computation.

Parameters

name : str
Name of the property.

AtomConstant

An object containing constant linked to atoms.

Source code in src/smiffer/grid/property_strategy/class_property.py
29
30
31
32
33
34
35
36
37
38
39
40
41
def __init__(self, name: str, atom_constant):
    """Define the strategy for property computation.

    Parameters
    ----------
    name : `str`
        Name of the property.

    atom_constant : `AtomConstant`
        An object containing constant linked to atoms.
    """
    self._name: str = name
    self._atom_constant = atom_constant

__str__()

Redefine print() comportement.

Returns

str
The new message to print.

Source code in src/smiffer/grid/property_strategy/class_property.py
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
def __str__(self) -> str:
    """Redefine `print()` comportement.

    Returns
    -------
    `str`
        The new message to print.
    """
    to_print: str = (
        f'Current used property is "{self._name}". Linked '
        "to an atom_constant object. "
        f"{self._atom_constant}."
    )

    return to_print

name()

self.__name getter.

Returns

str
The property name.

Source code in src/smiffer/grid/property_strategy/class_property.py
59
60
61
62
63
64
65
66
67
def name(self) -> str:
    """`self.__name` getter.

    Returns
    -------
    `str`
        The property name.
    """
    return self._name

populate_grid(grid, grid_object) abstractmethod

Define an abstract method in order to fill a grid with given
properties.

Parameters

grid : np.ndarray
The grid to fill.

Grid

The grid object to access all attributes.

Returns

None
To skip an iteration.

Source code in src/smiffer/grid/property_strategy/class_property.py
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
@abstractmethod
def populate_grid(self, grid: np.ndarray, grid_object) -> None:
    """Define an abstract method in order to fill a grid with given
    properties.

    Parameters
    ----------
    grid : `np.ndarray`
        The grid to fill.

    grid_object : `Grid`
        The grid object to access all attributes.

    Returns
    -------
    None
        To skip an iteration.
    """