Skip to content

polykin.math.roots¤

RootResult dataclass ¤

Dataclass with scalar root solution results.

ATTRIBUTE DESCRIPTION
method

Method used to find the root.

TYPE: str

success

If True, the root was found.

TYPE: bool

message

Description of the exit status.

TYPE: str

nfeval

Number of function evaluations.

TYPE: int

niter

Number of iterations.

TYPE: int

x

Root value.

TYPE: float

f

Function (residual) value at root.

TYPE: float

Source code in src/polykin/math/roots/results.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
@dataclass
class RootResult:
    """Dataclass with scalar root solution results.

    Attributes
    ----------
    method: str
        Method used to find the root.
    success: bool
        If `True`, the root was found.
    message: str
        Description of the exit status.
    nfeval: int
        Number of function evaluations.
    niter: int
        Number of iterations.
    x: float
        Root value.
    f: float
        Function (residual) value at root.
    """

    method: str
    success: bool
    message: str
    nfeval: int
    niter: int
    x: float
    f: float

    def __repr__(self) -> str:
        """Return a string representation of the root result."""
        return (
            f" method: {self.method}\n"
            f"success: {colored_bool(self.success)}\n"
            f"message: {self.message}\n"
            f" nfeval: {self.nfeval}\n"
            f"  niter: {self.niter}\n"
            f"      x: {self.x}\n"
            f"      f: {self.f}"
        )

__repr__ ¤

__repr__() -> str

Return a string representation of the root result.

Source code in src/polykin/math/roots/results.py
46
47
48
49
50
51
52
53
54
55
56
def __repr__(self) -> str:
    """Return a string representation of the root result."""
    return (
        f" method: {self.method}\n"
        f"success: {colored_bool(self.success)}\n"
        f"message: {self.message}\n"
        f" nfeval: {self.nfeval}\n"
        f"  niter: {self.niter}\n"
        f"      x: {self.x}\n"
        f"      f: {self.f}"
    )