
    P/Ph                     F    d Z ddlmZ ddlmZ d Zd Zd
dZd
dZ	dd	Z
dS )z|
========================
Widget testing utilities
========================

See also :mod:`matplotlib.tests.test_widgets`.
    )mockNc                      t          j        dd          \  } }|                    ddgddg           |                    d           | j                                         |S )z"Create a plot and return its Axes.   r      g      ?)pltsubplotsplot
set_aspectcanvasdraw)figaxs     Z/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/matplotlib/testing/widgets.pyget_axr      s\    l1a  GCGGQHq#hMM#JOOI    c                      d S N )argskwargss     r   noopr      s    Dr   r   c                 D   t          j                    }||_        | j                            ||f||fg          d         \  |_        |_        ||c|_        |_        | |_	        | 
                    d          j        |_        ||_        ||_        d|_        d|_        |S )a  
    Create a mock event that can stand in for `.Event` and its subclasses.

    This event is intended to be used in tests where it can be passed into
    event handling functions.

    Parameters
    ----------
    ax : `~matplotlib.axes.Axes`
        The Axes the event will be in.
    xdata : float
        x coord of mouse in data coords.
    ydata : float
        y coord of mouse in data coords.
    button : None or `MouseButton` or {'up', 'down'}
        The mouse button pressed in this event (see also `.MouseEvent`).
    key : None or str
        The key pressed when the mouse event triggered (see also `.KeyEvent`).
    step : int
        Number of scroll steps (positive for 'up', negative for 'down').

    Returns
    -------
    event
        A `.Event`\-like Mock instance.
    r   T)rootNCustom)r   Mockbutton	transData	transformxyxdataydatainaxes
get_figurer   keystepguiEventname)r   r   r!   r"   r%   r&   events          r   
mock_eventr*      s    6 IKKEEL|--u~05u~/? @ @@ACEGUW$eEKEL==d=++2ELEIEJENEJLr   c                 n    t          | j        |||||          }t          | |          } ||           dS )aT  
    Trigger an event on the given tool.

    Parameters
    ----------
    tool : matplotlib.widgets.AxesWidget
    etype : str
        The event to trigger.
    xdata : float
        x coord of mouse in data coords.
    ydata : float
        y coord of mouse in data coords.
    button : None or `MouseButton` or {'up', 'down'}
        The mouse button pressed in this event (see also `.MouseEvent`).
    key : None or str
        The key pressed when the mouse event triggered (see also `.KeyEvent`).
    step : int
        Number of scroll steps (positive for 'up', negative for 'down').
    N)r*   r   getattr)	tooletyper   r!   r"   r%   r&   r)   funcs	            r   do_eventr0   D   s=    ( twuc4@@E4DDKKKKKr   c                 V   |!t          | d|d         |d         d|           t          | d|d         |d         d           t          | d|d         |d         d           t          | d	|d         |d         d           |#t          | d
|d         |d         d|           dS dS )a}  
    Helper to simulate a mouse drag operation.

    Parameters
    ----------
    tool : `~matplotlib.widgets.Widget`
    start : [float, float]
        Starting point in data coordinates.
    end : [float, float]
        End point in data coordinates.
    key : None or str
         An optional key that is pressed during the whole operation
         (see also `.KeyEvent`).
    Non_key_pressr   r   )r!   r"   r   r%   press)r!   r"   r   onmovereleaseon_key_release)r0   )r-   startendr%   s       r   click_and_dragr9   ]   s     ~U1XU1Xs	$ 	$ 	$ 	$ T7%(%(1EEEET83q6QBBBBT9CF#a&CCCC
's1vSVs	$ 	$ 	$ 	$ 	$ 	$ r   )r   r   r   Nr   r   )__doc__unittestr   matplotlib.pyplotpyplotr   r   r   r*   r0   r9   r   r   r   <module>r>      s                  	 	 	& & & &R   2$ $ $ $ $ $r   