
    lj                        d dl mZ d dlZd dlmZ d dlmZmZmZ d dl	Z
ddgZd dlmZ erd dlmZ d d	lmZ  G d
 d          Z G d de          Z G d de          ZdS )    )annotationsN)Iterable)TYPE_CHECKINGAnyoverloadLogBase
LinearBase)Integer)Callable)VMobjectc                  d    e Zd ZdZdddZedd	            Zedd            ZddZddZddZdS )
_ScaleBasezScale baseclass for graphing/functions.

    Parameters
    ----------
    custom_labels
        Whether to create custom labels when plotted on a :class:`~.NumberLine`.
    Fcustom_labelsboolc                    || _         d S N)r   )selfr   s     W/home/agentuser/manim-venv/lib/python3.11/site-packages/manim/mobject/graphing/scale.py__init__z_ScaleBase.__init__   s    *    valuefloatreturnc                    d S r    r   r   s     r   functionz_ScaleBase.function   s    /2sr   
np.ndarrayc                    d S r   r   r   s     r   r   z_ScaleBase.function"   s    9<r   c                    t           )ai  The function that will be used to scale the values.

        Parameters
        ----------
        value
            The number/``np.ndarray`` to be scaled.

        Returns
        -------
        float
            The value after it has undergone the scaling.

        Raises
        ------
        NotImplementedError
            Must be subclassed.
        NotImplementedErrorr   s     r   r   z_ScaleBase.function%   s
    $ "!r   c                    t           )zThe inverse of ``function``. Used for plotting on a particular axis.

        Raises
        ------
        NotImplementedError
            Must be subclassed.
        r!   r   s     r   inverse_functionz_ScaleBase.inverse_function9   s
     "!r   	val_rangeIterable[float]kw_argsr   Iterable[VMobject]c                    t           )a  Custom instructions for generating labels along an axis.

        Parameters
        ----------
        val_range
            The position of labels. Also used for defining the content of the labels.

        Returns
        -------
        Dict
            A list consisting of the labels.
            Can be passed to :meth:`~.NumberLine.add_labels() along with ``val_range``.

        Raises
        ------
        NotImplementedError
            Can be subclassed, optional.
        r!   )r   r%   r'   s      r   get_custom_labelsz_ScaleBase.get_custom_labelsC   s
    . "!r   N)F)r   r   r   r   r   r   )r   r   r   r   )r%   r&   r'   r   r   r(   )	__name__
__module____qualname____doc__r   r   r   r$   r*   r   r   r   r   r      s         + + + + + 222 X2<<< X<" " " "(" " " "" " " " " "r   r   c                  2     e Zd Zd	d
 fdZddZddZ xZS )r	         ?scale_factorr   c                V    t                                                       || _        dS )zThe default scaling class.

        Parameters
        ----------
        scale_factor
            The slope of the linear function, by default 1.0
        N)superr   r2   )r   r2   	__class__s     r   r   zLinearBase.__init__^   s)     	(r   r   r   c                    | j         |z  S )zMultiplies the value by the scale factor.

        Parameters
        ----------
        value
            Value to be multiplied by the scale factor.
        r2   r   s     r   r   zLinearBase.functioni   s      5((r   c                    || j         z  S )zInverse of function. Divides the value by the scale factor.

        Parameters
        ----------
        value
            value to be divided by the scale factor.
        r7   r   s     r   r$   zLinearBase.inverse_functions   s     t(((r   )r1   )r2   r   r+   )r,   r-   r.   r   r   r$   __classcell__r5   s   @r   r	   r	   ]   sj        	) 	) 	) 	) 	) 	) 	)) ) ) )) ) ) ) ) ) ) )r   c                  >     e Zd Zdd fdZdd
ZddZ	 dddZ xZS )r   
   Tbaser   r   r   c                d    t                                                       || _        || _        dS )a  Scale for logarithmic graphs/functions.

        Parameters
        ----------
        base
            The base of the log, by default 10.
        custom_labels
            For use with :class:`~.Axes`:
            Whether or not to include ``LaTeX`` axis labels, by default True.

        Examples
        --------
        .. code-block:: python

            func = ParametricFunction(lambda x: x, scaling=LogBase(base=2))

        N)r4   r   r=   r   )r   r=   r   r5   s      r   r   zLogBase.__init__   s0    $ 		*r   r   r   c                    | j         |z  }|S )zMScales the value to fit it to a logarithmic scale.``self.function(5)==10**5``)r=   )r   r   return_values      r   r   zLogBase.function   s    "i.r   c                    t          |t          j                  r|                                dk    }dd}n|dk    }t          j        }|rt          d           ||| j                  }|S )	z9Inverse of ``function``. The value must be greater than 0r   r   r   r=   r   c                X    t          j        |           t          j        |          z  }|S r   )nplog)r   r=   r@   s      r   funcz&LogBase.inverse_function.<locals>.func   s"    &(fUmmbfTll&B##r   zIlog(0) is undefined. Make sure the value is in the domain of the function)r   r   r=   r   r   r   )
isinstancerC   ndarrayanymathrD   
ValueErrorr=   )r   r   	conditionrE   s       r   r$   zLogBase.inverse_function   s    eRZ(( 
			q(I$ $ $ $ $ 
I8D 	[   UDI&&r   r   r%   r&   unit_decimal_placesintbase_configr   list[Integer]c                ,      fd|D             }|S )a  Produces custom :class:`~.Integer` labels in the form of ``10^2``.

        Parameters
        ----------
        val_range
            The iterable of values used to create the labels. Determines the exponent.
        unit_decimal_places
            The number of decimal places to include in the exponent
        base_config
            Additional arguments to be passed to :class:`~.Integer`.
        c                p    g | ]2}t          j        fd d                    |          d dz  i3S )unitz^{%s}.f)r
   r=   r$   ).0irN   r   rL   s     r   
<listcomp>z-LogBase.get_custom_labels.<locals>.<listcomp>   sv     %
 %
 %
  	 4#8#8#;#; U>Q U U U UV  %
 %
 %
r   r   )r   r%   rL   rN   
tex_labelss   ` `` r   r*   zLogBase.get_custom_labels   sA    $%
 %
 %
 %
 %
 %
 %
 %
 %

 r   )r<   T)r=   r   r   r   r+   )r   )r%   r&   rL   rM   rN   r   r   rO   )r,   r-   r.   r   r   r$   r*   r9   r:   s   @r   r   r   ~   s        + + + + + + +,   
   0 $%        r   )
__future__r   rI   collections.abcr   typingr   r   r   numpyrC   __all__manim.mobject.text.numbersr
   r   &manim.mobject.types.vectorized_mobjectr   r   r	   r   r   r   r   <module>r`      s?   " " " " " "  $ $ $ $ $ $ / / / / / / / / / /    l
# . . . . . . @((((((??????G" G" G" G" G" G" G" G"T) ) ) ) ) ) ) )BK K K K Kj K K K K Kr   