Skip to content

designs

Designs

Super class for all design classes (factorial and space-filling).

Attributes:

Name Type Description
designs List

A list of design instances.

k int

The dimension of the design.

seed int

The seed for the random number generator.

rng Generator

A random number generator instance.

Source code in spotpython/design/designs.py
 5
 6
 7
 8
 9
10
11
12
13
14
15
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
class Designs:
    """
    Super class for all design classes (factorial and space-filling).

    Attributes:
        designs (List): A list of design instances.
        k (int): The dimension of the design.
        seed (int): The seed for the random number generator.
        rng (Generator): A random number generator instance.
    """

    def __init__(self, k: int, seed: int = 123) -> None:
        """
        Initializes a Designs object with the given dimension and seed.

        Args:
            k (int): The dimension of the design.
            seed (int): The seed for the random number generator. Defaults to 123.

        Raises:
            ValueError: If 'k' is not an integer.

        Examples:
            >>> from spotpython.design.designs import Designs
            >>> designs = Designs(k=2, seed=123)
            >>> designs.get_dim()
            2
        """
        if not isinstance(k, int):
            raise ValueError("The dimension of the design must be an integer.")

        self.k: int = k
        self.seed: int = seed
        self.rng = default_rng(self.seed)
        self.designs: List = []

    def get_dim(self) -> int:
        """
        Returns the dimension of the design.

        Returns:
            int: The dimension of the design.
        """
        return self.k

__init__(k, seed=123)

Initializes a Designs object with the given dimension and seed.

Parameters:

Name Type Description Default
k int

The dimension of the design.

required
seed int

The seed for the random number generator. Defaults to 123.

123

Raises:

Type Description
ValueError

If ‘k’ is not an integer.

Examples:

>>> from spotpython.design.designs import Designs
>>> designs = Designs(k=2, seed=123)
>>> designs.get_dim()
2
Source code in spotpython/design/designs.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
def __init__(self, k: int, seed: int = 123) -> None:
    """
    Initializes a Designs object with the given dimension and seed.

    Args:
        k (int): The dimension of the design.
        seed (int): The seed for the random number generator. Defaults to 123.

    Raises:
        ValueError: If 'k' is not an integer.

    Examples:
        >>> from spotpython.design.designs import Designs
        >>> designs = Designs(k=2, seed=123)
        >>> designs.get_dim()
        2
    """
    if not isinstance(k, int):
        raise ValueError("The dimension of the design must be an integer.")

    self.k: int = k
    self.seed: int = seed
    self.rng = default_rng(self.seed)
    self.designs: List = []

get_dim()

Returns the dimension of the design.

Returns:

Name Type Description
int int

The dimension of the design.

Source code in spotpython/design/designs.py
41
42
43
44
45
46
47
48
def get_dim(self) -> int:
    """
    Returns the dimension of the design.

    Returns:
        int: The dimension of the design.
    """
    return self.k