• File: compare.pyc
  • Full Path: /home3/farmfre2/public_html/ALFA_DATA/alfasymlink/root/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/testing/compare.pyc
  • Date Modified: 07/22/2015 11:41 PM
  • File size: 8.26 KB
  • MIME-type: text/x-bytecode.python
  • Charset: 8 bit

_3Lc@sndZddlZddlmZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZdddgZdddZiZejdk	rejdkrd	Znd
ZdZeed<eed
<nejdk	rdZeed<ndZdZiZdZejrUerUded<nedZdZdS(s+ A set of utilities for comparing results.
iN(tImageComparisonFailuret
compare_floattcompare_imagestcomparable_formatscCs|dkr>|dkr>d}|d7}|d7}t|nd}|dk	rt||}||krt|}t|}t|}	t|}
|d7}|d|d7}|d|d7}|d|	d7}|d	|
d7}qn|dk	rt||}|r)|t|}n||krt|}t|}
t|}t|}|d7}|d|d7}|d|d7}|d
|d7}|d|
d7}qn|r|SdSdS(
sFail if the floating point values are not close enough, with
      the givem message.

   You can specify a relative tolerance, absolute tolerance, or both.
   s4You haven't specified a 'relTol' relative tolerance s5or a 'absTol' absolute tolerance function argument.  sYou must specify one.ts
s  Expected: s  Actual:   s  Abs Diff: s  Abs Tol:  s  Rel Diff: s  Rel Tol:  N(tNonet
ValueErrortabststr(texpectedtactualtrelToltabsToltexMsgtmsgtabsDifftexpectedStrt	actualStrt
absDiffStrt	absTolStrtrelDifft
relDiffStrt	relTolStr((sM/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/testing/compare.pyRsF



twin32tgswin32ctgscCstddddd||gS(Ns-qs-sDEVICE=png16ms	-dNOPAUSEs-dBATCHs
-sOutputFile=(R(toldtnew((sM/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/testing/compare.pyt<lambda>\stpdftepscCsd|d|gS(Ntinkscapes
--export-png=((RR((sM/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/testing/compare.pyRcstsvgcCsdgtjS(sSReturns the list of file formats that compare_images can compare
   on this system.tpng(t	convertertkeys(((sM/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/testing/compare.pyRgsc
Cs$|jdd\}}|tkr4td|n|d|d}tjj|shtd|nt|||}tj|dtj	dtj	}|j
\}}|j}tjj|s|r d	d
j|}	|r|	d|7}	n|r|	d|7}	nt|	n|S(
sX
   Convert the named file into a png file.
   Returns the name of the created file.
   t.is)Don't know how to convert %s files to pngt_s.pngs'%s' does not existtstdouttstderrsConversion command failed:
%s
t sStandard output:
%s
sStandard error:
%s
(
trsplitR"RtostpathtexiststIOErrort
subprocesstPopentPIPEtcommunicatetwaittjoin(
tfilenametbaset	extensiontnewnametcmdtpipeR&R'terrcodeR((sM/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/testing/compare.pytconvertls$!c
Cstjj|s"td|n|jdd\}}tj|d}|dk	r||}tj	|dtj
dtj
}|j\}}|j}|dkrddj
|}	|r|	d	|7}	n|r|	d
|7}	nt|	qndS(s?
   Verify the file through some sort of verification tool.
   s'%s' does not existR$iR&R'is%File verification command failed:
%s
R(sStandard output:
%s
sStandard error:
%s
N(R*R+R,R-R)t	verifierstgetRR.R/R0R1R2R3(
R4R5R6tverifierR8R9R&R'R:R((sM/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/testing/compare.pytverifys !cCsdddd|gS(Ntxmllints--valids--nowarnings--noout((R4((sM/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/testing/compare.pyRsc
Csy ddlm}m}m}Wn3tk
rU}d|}|rNt|qV|SnXt||jdd}	|	dkrt|t|}}n|j	|jd}
|j	|jd}|j
|
d}
|j
|d}|
j}|j}
tj
ttjtd||
t|}tjjtjj|d	tjj|}d
tjj|}|d|krtjj|rtj|ntjj|rtj|ndSt||||r7tj||td|d
t|dt|dt|}|Stjj|rYtj|ndt|ddt|dt|dt|dt|d}|SdS(s=Compare two image files - not the greatest, but fast and good enough.

   = EXAMPLE

   # img1 = "./baseline/plot.png"
   # img2 = "./output/plot.png"
   #
   # compare_images( img1, img2, 0.001 ):

   = INPUT VARIABLES
   - expected  The filename of the expected image.
   - actual    The filename of the actual image.
   - tol       The tolerance (a unitless float).  This is used to
               determine the 'fuzziness' to use when comparing images.
   - in_decorator If called from image_comparison decorator, this should be
               True. (default=False)
   i(tImagetImageOpstImageFiltersImage Comparison requires the Python Imaging Library to be installed.  To run tests without using PIL, then use the '--without-tag=PIL' command-line option.
Importing PIL failed with the following error:
%sR$R!tRGBicSs||dS(Ni((tatb((sM/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/testing/compare.pyRssfailed-diff-s	expected-g@trmsR	R
tdiffs1  Error: Image files did not match.
  RMS Value: s
  Expected:
    s
  Actual:
    s
  Difference:
    s
  Tolerance: s
N( tPILRARBRCtImportErrortNotImplementedErrorR?tsplitR;topentautocontrastt	histogramtmathtsqrttreducetoperatortaddtmaptlenR*R+R3tdirnametbasenameR,tunlinkRtsave_diff_imagetshutiltcopyfiletdictR(R	R
ttoltin_decoratorRARBRCteRR6t
expectedImagetactualImageth1th2RGt
diff_imaget
expected_copytresults((sM/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/testing/compare.pyRsR 
4Pc	Csddlm}tj|j|jdjtj}tj|j|jdjtj}|j|jkst	|j
|j
kst	t||}|d9}tj|ddjtj
}|j|}|j|dS(Ni(RARDi
ii(RIRAtnptarrayRMR;tastypetfloattndimtAssertionErrortshapeRtcliptuint8t	fromarraytsave(	R	R
toutputRARaRbtabsDiffImaget
save_image_npt
save_image((sM/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/testing/compare.pyRZs--
!(t__doc__t
matplotlibtmatplotlib.testing.noseclassesRRPRSR*tnumpyRhR[R.tsyst__all__RRR"tcheckdep_ghostscripttplatformRR8tcheckdep_inkscapeRR;R<R?tcheckdep_xmllinttFalseRRZ(((sM/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/testing/compare.pyt<module>s@	;		

	
			V