a
    s=ic                     @   sN   d Z ddlmZ ddlmZ dd Zdd Zdd	d
ZdddZ	dddZ
dS )z|
========================
Widget testing utilities
========================

See also :mod:`matplotlib.tests.test_widgets`.
    N)mockc                  C   s>   t dd\} }|ddgddg |d |jj  |S )z"Create a plot and return its axes.   r      g      ?)pltZsubplotsZplotZ
set_aspectfigurecanvasZdraw)Zfigax r	   k/home/droni/.local/share/virtualenvs/DPS-5Je3_V2c/lib/python3.9/site-packages/matplotlib/testing/widgets.pyget_ax   s
    
r   c                  O   s   d S )Nr	   )argskwargsr	   r	   r
   noop   s    r   r   c                 C   sl   t  }||_| j||f||fgd \|_|_|| |_|_| |_	| j
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 : int
        x coord of mouse in data coords.
    ydata : int
        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   NZCustom)r   ZMockbuttonZ	transDataZ	transformxyxdataydataZinaxesr   r   keystepZguiEventname)r   r   r   r   r   r   eventr	   r	   r
   
mock_event   s    
r   c           	      C   s*   t | j|||||}t| |}|| dS )aW  
    Trigger an event on the given tool.

    Parameters
    ----------
    tool : matplotlib.widgets.RectangleSelector
    etype : str
        The event to trigger.
    xdata : int
        x coord of mouse in data coords.
    ydata : int
        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   funcr	   r	   r
   do_eventC   s    
r   c                 C   s   |dur$t | d|d |d d|d t | d|d |d dd t | d|d |d dd t | d	|d |d dd |durt | d
|d |d d|d 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`).
    NZon_key_pressr   r   )r   r   r   r   Zpress)r   r   r   ZonmovereleaseZon_key_release)r   )r   startendr   r	   r	   r
   click_and_drag\   s    r!   )r   r   r   Nr   )r   r   r   Nr   )N)__doc__Zmatplotlib.pyplotZpyplotr   Zunittestr   r   r   r   r   r!   r	   r	   r	   r
   <module>   s   	
)
