Skip to content

Commit

Permalink
Merge pull request #45 from DanielGoldfarb/master
Browse files Browse the repository at this point in the history
regression tests for new api
  • Loading branch information
DanielGoldfarb authored Mar 6, 2020
2 parents 8f97c2c + 6f12d71 commit cde5008
Show file tree
Hide file tree
Showing 11 changed files with 2,032 additions and 168 deletions.
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 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.
52 changes: 52 additions & 0 deletions examples/mpftests/test_addplot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import os as os
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
print("plt.rcParams['backend'] =",plt.rcParams['backend']) # for the record

import subprocess
pwd = subprocess.run(['pwd'], stdout=subprocess.PIPE)
print('pwd.stdout=',pwd.stdout)


df = pd.read_csv('../data/SPY_20110701_20120630_Bollinger.csv',index_col=0,parse_dates=True)
print('df.shape=' , df.shape )
print('df.head(3)=', df.head(3))
print('df.tail(3)=', df.tail(3))

prefix='addplot'
tdir='test_images/'
refd='reference_images/'
#os.system('rm -f '+tdir+prefix+'*.jpg')
os.system('rm -f '+tdir+prefix+'*.png')

IMGCOMP_TOLERANCE = 7.0

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

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

os.system('ls -l '+tdir+fname)

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.png'
apdict = mpf.make_addplot(df['LowerB'])
mpf.plot(df,volume=True,addplot=apdict,savefig=tdir+fname)

os.system('ls -l '+tdir+fname)

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.
230 changes: 69 additions & 161 deletions examples/savefig.ipynb

Large diffs are not rendered by default.

Loading

0 comments on commit cde5008

Please sign in to comment.