o
    :a                     @   sb   d dl mZ d dlZd dlZd dlmZ d dlmZmZ d dlm	Z	 ej
dg ddd	 ZdS )
    )PathN)approx)compare_imagesmake_test_filename)_image_directorieszim1, im2, tol, expect_rms))basn3p02.pngbasn3p02-minorchange.png
   N)r   r   r   gBs@)r   zbasn3p02-1px-offset.pngr   g%̴V@)r   zbasn3p02-half-1px-offset.pngr   g     O@)r   zbasn3p02-scrambled.pngr   gD/Xe@)
all127.png
all128.pngr      )r   r
   r   r   c           	      C   s   t ttdd \}}t||  d}t||  | ||  }t|| | t|||dd}|du r:|du s8J dS |dus@J |d t|dd	ksLJ dS )
a  
    Compare two images, expecting a particular RMS error.

    im1 and im2 are filenames relative to the baseline_dir directory.

    tol is the tolerance to pass to compare_images.

    expect_rms is the expected RMS value, or None. If None, the test will
    succeed if compare_images succeeds. Otherwise, the test will succeed if
    compare_images fails and returns an RMS error almost equal to this value.
    c                   S   s   dS )NZdummy r   r   r   F/usr/lib/python3/dist-packages/matplotlib/tests/test_compare_images.py<lambda>9   s    z2test_image_comparison_expect_rms.<locals>.<lambda>ZexpectedT)tolZin_decoratorNZrmsg-C6?)abs)mapr   r   r   shutilcopyfiler   r   )	Zim1Zim2r   Z
expect_rmsZbaseline_dirZ
result_dirZ
result_im1Z
result_im2resultsr   r   r    test_image_comparison_expect_rms   s   -r   )Zpathlibr   r   Zpytestr   Zmatplotlib.testing.comparer   r   Zmatplotlib.testing.decoratorsr   ZmarkZparametrizer   r   r   r   r   <module>   s    !