o
    gQ(                     @   s  d dl Z d dlZd dlZd dlmZ d dlmZ d dlm	Z	 eddgddd#d	d
Z
e
gZd
gZdd Zejjdeeddd Zejjdeeddd Zejjdeeddd Zejjdeeddd Zejjdeeddd Zdd Zdd Zdd Zdd  ZG d!d" d"ZdS )$    N_preprocess_data)Axes)check_figures_equalxyreplace_nameslabel_namerxyzc                 C      dt |t ||||f S Nz&x: %s, y: %s, ls: %s, w: %s, label: %slistaxr   r   lslabelw r   c/home/ubuntu/cloudmapper/venv/lib/python3.10/site-packages/matplotlib/tests/test_preprocess_data.py	plot_func      r   c                  C   sH  dd } dd }dd }dd }t d	d
gd|  t d	d
gd| t d	d
gd| tt t g dd| W d   n1 sDw   Y  t g dd|  t g dd| t g dd| t g dd| tt t dd|  W d   n1 sw   Y  tt t dd| W d   dS 1 sw   Y  dS )z.Test decorator invocations -> no replacements.c                 S      d S Nr   )r   r   r   r   r   r   func       z%test_compiletime_checks.<locals>.funcc                 W   r   r   r   )r   r   r   argsr   r   r   	func_args   r   z*test_compiletime_checks.<locals>.func_argsc                 [   r   r   r   )r   r   r   kwargsr   r   r   func_kwargs    r   z,test_compiletime_checks.<locals>.func_kwargsc                  _   r   r   r   )r   r   r   r   r   func_no_ax_args!   r   z0test_compiletime_checks.<locals>.func_no_ax_argsr   r   r	   )r   r   zNr   r#   r
   )r   pytestraisesAssertionError)r   r   r    r!   r   r   r   test_compiletime_checks   s(   "r(   r   )idsc                 C   s   | ddddks
J | dddddksJ | ddddddks!J | dddd	dd
ks-J | ddddddks9J | dddd	dd
ksEJ dS )z%Test without data -> no replacements.Nr   r   z.x: ['x'], y: ['y'], ls: x, w: xyz, label: None)r   r    )r   z*x: ['x'], y: ['y'], ls: x, w: xyz, label: textz.x: ['x'], y: ['y'], ls: x, w: xyz, label: text)r   r   r   r   )r   r   r   r   test_function_call_without_data<   s$   
r,   c                 C   s*   ddd}| d|  | dksJ dS )z8Tests with dict input, unpacking via preprocess_pipeline      )abNz4x: ['a', 'b'], y: [1, 2], ls: x, w: xyz, label: None)keysvaluesr   datar   r   r   "test_function_call_with_dict_inputM   s   
r5   c                 C   s   ddgddgdd}| ddd	|d
dksJ | ddd	|ddks"J | ddd	d|ddks/J | ddd	d|ddks<J | ddd	d|ddksIJ | ddd	d|ddksVJ dS )zCTest with dict data -> label comes from the value of 'x' parameter.r-   r.      	   NOTr/   r0   r   Nr/   r0   r4   -x: [1, 2], y: [8, 9], ls: x, w: xyz, label: br   r   r4   r*   r   r4   ,x: [1, 2], y: [8, 9], ls: x, w: xyz, label: r+   0x: [1, 2], y: [8, 9], ls: x, w: xyz, label: textr   r   r   r4   r   r3   r   r   r   !test_function_call_with_dict_dataU   s&   rA   c                 C   s   ddgdd}| ddd|dd	ksJ | ddd|d
d	ksJ | dddd|ddks,J | dddd|ddks9J | dddd|ddksFJ | dddd|ddksSJ dS )zETest the case that one var is not in data -> half replaces, half keptr-   r.   r8   )r/   r   Nr/   r0   r:   z,x: [1, 2], y: ['b'], ls: x, w: xyz, label: br<   r*   r=   z+x: [1, 2], y: ['b'], ls: x, w: xyz, label: r+   z/x: [1, 2], y: ['b'], ls: x, w: xyz, label: textr@   r   r3   r   r   r   -test_function_call_with_dict_data_not_in_datag   s&   rB   c                 C   s   | tjddgtjdtjddgtjdddgd}| dd	d
|ddks'J | dd	d
|ddks3J | dd	d
d|ddks@J | dd	d
d|ddksMJ | dd	d
d|ddksZJ | dd	d
d|ddksgJ dS )zDTest with pandas dataframe -> label comes from ``data["col"].name``.r-   r.   )dtyper6   r7   r8   r9   Nr/   r0   r:   r;   r<   r*   r=   r>   r+   r?   r@   )	DataFramenparrayint32)r   pdr4   r   r   r   #test_function_call_with_pandas_datay   s,   rI   c                  C   s   ddgddgdd} t ddddd}|d
ddd	| ddks!J |d
ddd	| ddks.J |d
ddd	d| ddks<J |d
ddd	d| ddksJJ |d
ddd	d| ddksXJ |d
ddd	d| ddksfJ d
S )zETest without a "replace_names" argument, all vars should be replaced.r-   r.   r6   r7   r   )r/   r0   r   r   r$   r   Nr8   c                 S   r   r   r   r   r   r   r   func_replace_all   r   z8test_function_call_replace_all.<locals>.func_replace_allr/   r0   )r   r4   r;   )r   r   r   r4   r*   )r   r   r4   r>   r+   r?   )r   r   r   r   r4   )r   Nr8   r   )r4   rJ   r   r   r   test_function_call_replace_all   s*   rK   c                  C   s   t ddgddddd} dd	gd
dgdd}| ddd|ddks#J | ddd|ddks/J | dddd|ddks<J | dddd|ddksIJ dS )z<Test with "label_namer=None" -> no label replacement at all.r   r   Nr   r   c                 S   r   r   r   r   r   r   r   func_no_label   r   z1test_no_label_replacements.<locals>.func_no_labelr-   r.   r6   r7   r8   r9   r/   r0   r:   z0x: [1, 2], y: [8, 9], ls: x, w: xyz, label: Noner<   r*   r=   r>   r+   r?   r   Nr   r   )rL   r4   r   r   r   test_no_label_replacements   s   rN   c               	   C   sr   t ddgddddd} ddgdd	gd
d}tt | d dddd|d W d    d S 1 s2w   Y  d S )Nr   r   r   r-   c                 S   r   r   r   )r   r   r   r#   r   r   r   r      s   z/test_more_args_than_pos_parameter.<locals>.funcr.   r6   r7   r8   r9   r/   r0   r#   r:   )r-   )r   r%   r&   	TypeErrorr3   r   r   r   !test_more_args_than_pos_parameter   s   "rP   c                  C   s   t  dd } td| jsJ td| jrJ t g dddd} td| jr,J td| jr5J t dgdddd} td| jrIJ td	| jrRJ t d
dgdddd} td| jrgJ td| jrpJ d S )Nc                 _      dS zFuncy does nothingNr   )r   r   r   r   r   r   funcy   r   z&test_docstring_addition.<locals>.funcyzevery other argumentzthe following argumentsr"   c                 S   rQ   rR   r   r   r   r   r#   barr   r   r   rS      r   rU   c                 S   rQ   rR   r   rT   r   r   r   rS      r   z%the following arguments .*: \*bar\*\.r   tc                 S   rQ   rR   r   )r   r   r   r#   rV   r   r   r   rS      r   z*the following arguments .*: \*x\*, \*t\*\.r   )r   research__doc__)rS   r   r   r   test_docstring_addition   s(   

rZ   c                   @   s`   e Zd ZejejejgZej	
deedgddd Zej	
deedgddd ZdS )	TestPlotTypesplotterpng)
extensionsc                 C   sJ   g d}g d}t t||}|| | |  || || d S )Nr-   r.               )dictzipsubplotsr1   r2   )selfr\   fig_testfig_refr   r   ddictr   r   r   test_dict_unpack   s   zTestPlotTypes.test_dict_unpackc                 C   s>   g d}g d}||  dd||dd ||  || d S )Nr_   ra   xvalyval)rm   rn   r:   )rg   )rh   r\   ri   rj   r   r   r   r   r   test_data_kwarg   s   zTestPlotTypes.test_data_kwargN)__name__
__module____qualname__r   scatterrU   plotplottersr%   markparametrizer   rl   ro   r   r   r   r   r[      s    
	
r[   rM   )rW   numpyrE   r%   
matplotlibr   matplotlib.axesr   matplotlib.testing.decoratorsr   r   	all_funcsall_func_idsr(   rv   rw   r,   r5   rA   rB   rI   rK   rN   rP   rZ   r[   r   r   r   r   <module>   s4    	!





 