Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

regression tests for new api #45

Merged
merged 5 commits into from
Mar 6, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
use matplotlib image comparison with tolerance
  • Loading branch information
DanielGoldfarb committed Mar 6, 2020
commit 6f12d711a32b81e71457ef61257b0c669db1f595
Binary file removed examples/mpftests/reference_images/addplot01.jpg
Binary file not shown.
Binary file added examples/mpftests/reference_images/addplot01.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed examples/mpftests/reference_images/addplot02.jpg
Binary file not shown.
Binary file added examples/mpftests/reference_images/addplot02.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 16 additions & 7 deletions examples/mpftests/test_addplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import pandas as pd
import mplfinance as mpf
import matplotlib.pyplot as plt
from matplotlib.testing.compare import compare_images

print('pd.__version__ =',pd.__version__ ) # for the record
print('mpf.__version__ =',mpf.__version__) # for the record
Expand All @@ -20,24 +21,32 @@
prefix='addplot'
tdir='test_images/'
refd='reference_images/'
os.system('rm -f '+tdir+prefix+'*.jpg')
#os.system('rm -f '+tdir+prefix+'*.jpg')
os.system('rm -f '+tdir+prefix+'*.png')

IMGCOMP_TOLERANCE = 7.0

# ---- Test 01 -----

fname=prefix+'01.jpg'
fname=prefix+'01.png'
mpf.plot(df,volume=True,savefig=tdir+fname)

os.system('ls -l '+tdir+fname)
rc = os.system('diff '+tdir+fname+' '+refd+fname)
assert rc == 0

result = compare_images(refd+fname,tdir+fname,tol=IMGCOMP_TOLERANCE)
if result is not None:
print('result=',result)
assert result is None

# ---- Test 02 -----

fname=prefix+'02.jpg'
fname=prefix+'02.png'
apdict = mpf.make_addplot(df['LowerB'])
mpf.plot(df,volume=True,addplot=apdict,savefig=tdir+fname)

os.system('ls -l '+tdir+fname)
rc = os.system('diff '+tdir+fname+' '+refd+fname)
assert rc == 0

result = compare_images(refd+fname,tdir+fname,tol=IMGCOMP_TOLERANCE)
if result is not None:
print('result=',result)
assert result is None
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.