From 0490e424c76d3005edbb44594451f0c6ffd91fd0 Mon Sep 17 00:00:00 2001 From: Wai-Shing Luk Date: Wed, 27 Dec 2023 03:27:47 +0000 Subject: [PATCH] add document by cody AI --- src/ellalgo/ell_calc_core.py | 41 +++++++++++++++++++++--------------- src/ellalgo/ell_config.py | 24 ++++++++++----------- 2 files changed, 36 insertions(+), 29 deletions(-) diff --git a/src/ellalgo/ell_calc_core.py b/src/ellalgo/ell_calc_core.py index 19731ec..48340e3 100644 --- a/src/ellalgo/ell_calc_core.py +++ b/src/ellalgo/ell_calc_core.py @@ -20,12 +20,12 @@ class EllCalcCore: _cst3: float def __init__(self, n_f: float) -> None: - """ - The function initializes several variables based on the input value. + """Initialize EllCalcCore instance. - :param n_f: The parameter `n_f` represents a floating point value. It is used to - initialize the `EllCalcCore` object + The __init__ method initializes the EllCalcCore object with the provided + n_f parameter. This sets up internal variables used in calculations. + :param n_f: Float value to initialize the instance with. :type n_f: float Examples: @@ -54,13 +54,15 @@ def __init__(self, n_f: float) -> None: self._cst3 = self._n_f * self._cst0 def calc_central_cut(self, tau: float) -> Tuple[float, float, float]: - r"""Calculate Central Cut - - The `calc_central_cut` function calculates the central cut values based on the given input. - - :param tau: tau is a float representing the value of tau + r"""Calculate the central cut values. + + The `calc_central_cut` method calculates the central cut values ρ, σ, δ + based on the input tau value. + + :param tau: The tau value :type tau: float - :return: The function `calc_central_cut` returns a tuple containing the following elements: + :return: Tuple of (ρ, σ, δ) + :rtype: Tuple[float, float, float] .. svgbob:: :align: center @@ -105,9 +107,14 @@ def calc_central_cut(self, tau: float) -> Tuple[float, float, float]: def calc_deep_cut_fast( self, beta: float, tau: float, eta: float ) -> Tuple[float, float, float]: - r"""Calculate Deep Cut fast - - The `calc_deep_cut_fast` function calculates the deep cut values based on the given input. + r"""Calculates the deep cut ellipsoid parameters using precomputed eta values. + + Given the beta, tau, and eta values, this method calculates the + deep cut ellipsoid parameters rho, sigma, and delta using a precomputed eta value. + that avoids explicitly calculating the intermediate eta value. + This allows the deep cut to be computed faster. + + The rho, sigma, and delta values define the deep cut ellipsoid. :param beta: beta is a float representing the value of beta :type beta: float @@ -159,10 +166,10 @@ def calc_deep_cut_fast( return (rho, sigma, delta) def calc_deep_cut(self, beta: float, tau: float) -> Tuple[float, float, float]: - r"""Calculate Deep Cut - - The `calc_deep_cut` function calculates the deep cut values based on the given input. - + r"""Calculate deep cut values. + + Calculates the deep cut values ρ, σ, δ for given β and τ. + :param beta: beta is a float representing the value of beta :type beta: float :param tau: tau is a float representing the value of tau diff --git a/src/ellalgo/ell_config.py b/src/ellalgo/ell_config.py index c3061cb..d2bd400 100644 --- a/src/ellalgo/ell_config.py +++ b/src/ellalgo/ell_config.py @@ -1,7 +1,14 @@ from enum import Enum -# The above class defines an enumeration for different cut statuses. +# The CutStatus enum defines a set of constant values that represent different statuses that can result from a cut operation. A cut is likely some optimization operation that partitions or divides a problem into smaller pieces. +# +# This enum has four possible values: +# +# Success - Indicates the cut operation succeeded +# NoSoln - Indicates the cut did not yield a valid solution +# NoEffect - The cut had no effect on improving the optimization +# Unknown - The status is unknown or unclear class CutStatus(Enum): Success = 0 NoSoln = 1 @@ -20,18 +27,11 @@ class Options: # the number of iterations it took. class CInfo: def __init__(self, feasible: bool, num_iters: int) -> None: - """ - The function initializes a new CInfo object with the given feasibility and number of iterations. - - :param feasible: A boolean value indicating whether the solution is feasible or not - - :type feasible: bool - - :param num_iters: The `num_iters` parameter represents the number of iterations or steps taken - in a process or algorithm. It is an integer value that indicates how many times a certain - operation or calculation has been performed + """Initializes a CInfo object. - :type num_iters: int + Args: + feasible (bool): Whether the solution is feasible. + num_iters (int): Number of iterations performed. """ self.feasible: bool = feasible self.num_iters: int = num_iters