Skip to content

mkdocs_demo.lib.superfluous

This module contains additional trivial filler code.

TestClass

TestClass(num_features: int, hidden_layers: int)

Bases: object

The TestClass is a basic Python class.

Parameters

num_features : int The num_features parameter represents the number of input features in your model. It indicates the size of the input layer of your neural network.

hidden_layers : int The hidden_layers parameter represents the number of hidden layers in a neural network.

Source code in src/mkdocs_demo/lib/superfluous.py
def __init__(self, num_features: int, hidden_layers: int) -> None:
    """
    Initializes the number of features and the number of hidden layers for a neural network.

    Parameters
    ----------
    `num_features` : `int`
        The `num_features` parameter represents the number of input features in your model. It
        indicates the size of the input layer of your neural network.

    `hidden_layers` : `int`
        The `hidden_layers` parameter represents the number of hidden layers in a neural network.
    """

    self.num_features: int = num_features
    self.hidden_layers: int = hidden_layers

MODEL_TYPE class-attribute instance-attribute

MODEL_TYPE: str = 'MLP'

hidden_layers instance-attribute

hidden_layers: int = hidden_layers

num_features instance-attribute

num_features: int = num_features

get_type staticmethod

get_type() -> Literal['Neural Network']

The method get_type returns the string "Neural Network".

Returns

Literal The string "Neural Network".

Source code in src/mkdocs_demo/lib/superfluous.py
@staticmethod
def get_type() -> Literal["Neural Network"]:
    """
    The method `get_type` returns the string "Neural Network".

    Returns
    -------
    `Literal`
        The string "Neural Network".
    """

    return "Neural Network"

load_model classmethod

load_model(path: Path | str) -> str

The method load_model loads a model from a given path and returns a string indicating the path from which the model was loaded.

Parameters

path : Path | str The path parameter is the path to the model file that needs to be loaded. It can be either a string or a Path object.

Returns

str A string that indicates the path from which the model was loaded.

Source code in src/mkdocs_demo/lib/superfluous.py
@classmethod
def load_model(cls, path: Path | str) -> str:
    """
    The method `load_model` loads a model from a given path and returns a string indicating the
    path from which the model was loaded.

    Parameters
    ----------
    `path` : `Path` | `str`
        The `path` parameter is the path to the model file that needs to be loaded. It can be either a
        string or a `Path` object.

    Returns
    -------
    `str`
        A string that indicates the path from which the model was loaded.
    """

    if isinstance(path, str):
        path = Path(path)

    return f"Model loaded from: '{path}' - Type: {cls.MODEL_TYPE}"

show_model

show_model() -> dict[str, str | int]

The method show_model returns a dictionary containing the model type and information about its layers.

Returns

dict[str, str | int] A dictionary containing the model type and the layers of the model.

Source code in src/mkdocs_demo/lib/superfluous.py
def show_model(self) -> dict[str, str | int]:
    """
    The method `show_model` returns a dictionary containing the model type and information about
    its layers.

    Returns
    -------
    `dict`[`str`, `str` | `int`]
        A dictionary containing the model type and the layers of the model.
    """

    model_dict: dict[str, str | int] = {"model_type": self.MODEL_TYPE}
    model_dict.update(self._show_layers())

    return model_dict

Trolling

Trolling(x: float, n: int)

Bases: ITrolling

The class Trolling implements the ITrolling interface.

Parameters

x : float The parameter x is a float, which means it can hold decimal values. It is used to store a numerical value.

n : int The parameter n is an integer that represents the number of iterations or steps in a process.

Source code in src/mkdocs_demo/config/interfaces.py
def __init__(self, x: float, n: int) -> None:
    """
    The above function is an initializer method for a class that takes in
    two parameters, `x` and `n`, and does not return anything.

    Parameters
    ----------
    `x` : `float`
        The parameter `x` is a float, which means it can hold decimal
        values. It is used to store a numerical value.

    `n` : `int`
        The parameter `n` is an integer that represents the number of
        iterations or steps in a process.
    """

    self.x = x
    self.n = n

multiple property

multiple: float

The function calculates the product of the variables x and n.

Returns

float The product of self.x and self.n.

n instance-attribute

n = n

x instance-attribute

x = x

__repr__

__repr__() -> str
Source code in src/mkdocs_demo/config/interfaces.py
def __repr__(self) -> str:
    return f"""{self.x} * {self.n} = {self.multiple}"""

__str__

__str__() -> str
Source code in src/mkdocs_demo/config/interfaces.py
def __str__(self) -> str:
    return f"""x={self.x}, n={self.n}, hence the multiple={self.multiple}"""

from_dict classmethod

from_dict(d: dict[str, int]) -> Self

The function from_dict takes a dictionary as input, checks if it contains the required keys, and returns an instance of the class with the dictionary values as arguments.

Parameters

d : dict[str, int] The parameter d is a dictionary with string keys and integer values.

Returns

Self The method is returning an instance of the class itself with the attributes specified in the dictionary d.

Source code in src/mkdocs_demo/lib/superfluous.py
@classmethod
def from_dict(cls, d: dict[str, int]) -> Self:
    """
    The function `from_dict` takes a dictionary as input, checks if it
    contains the required keys, and returns an instance of the class with
    the dictionary values as arguments.

    Parameters
    ----------
    `d` : `dict`[`str`, `int`]
        The parameter `d` is a dictionary with string keys and integer
        values.

    Returns
    -------
    `Self`
        The method is returning an instance of the class itself with the
        attributes specified in the dictionary `d`.
    """

    required = ("x", "n")
    obj = {k: v for k, v in d.items()}

    assert obj.keys() in required

    return cls(**obj)

create_trolling

create_trolling(d: dict[str, int]) -> Trolling

The function create_trolling takes a dictionary d and returns a Trolling object created from the dictionary.

Parameters

d : dict[str, int] A dictionary containing the data needed to create a Trolling object. The keys of the dictionary are strings representing the attributes of the Trolling object, and the values are integers representing the values of those attributes.

Returns

Trolling An instance of the class Trolling.

Source code in src/mkdocs_demo/lib/superfluous.py
def create_trolling(d: dict[str, int]) -> Trolling:
    """
    The function `create_trolling` takes a dictionary `d` and returns a `Trolling` object created from
    the dictionary.

    Parameters
    ----------
    `d` : `dict`[`str`, `int`]
        A dictionary containing the data needed to create a Trolling object. The keys of the dictionary are
    strings representing the attributes of the Trolling object, and the values are integers representing
    the values of those attributes.

    Returns
    -------
    `Trolling`
        An instance of the class Trolling.
    """

    return Trolling.from_dict(d)