Skip to content

Commit cde5008

Browse files
Merge pull request #45 from DanielGoldfarb/master
regression tests for new api
2 parents 8f97c2c + 6f12d71 commit cde5008

File tree

11 files changed

+2032
-168
lines changed

11 files changed

+2032
-168
lines changed
36.6 KB
Loading
50.2 KB
Loading

examples/mpftests/test_addplot.py

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import os as os
2+
import pandas as pd
3+
import mplfinance as mpf
4+
import matplotlib.pyplot as plt
5+
from matplotlib.testing.compare import compare_images
6+
7+
print('pd.__version__ =',pd.__version__ ) # for the record
8+
print('mpf.__version__ =',mpf.__version__) # for the record
9+
print("plt.rcParams['backend'] =",plt.rcParams['backend']) # for the record
10+
11+
import subprocess
12+
pwd = subprocess.run(['pwd'], stdout=subprocess.PIPE)
13+
print('pwd.stdout=',pwd.stdout)
14+
15+
16+
df = pd.read_csv('../data/SPY_20110701_20120630_Bollinger.csv',index_col=0,parse_dates=True)
17+
print('df.shape=' , df.shape )
18+
print('df.head(3)=', df.head(3))
19+
print('df.tail(3)=', df.tail(3))
20+
21+
prefix='addplot'
22+
tdir='test_images/'
23+
refd='reference_images/'
24+
#os.system('rm -f '+tdir+prefix+'*.jpg')
25+
os.system('rm -f '+tdir+prefix+'*.png')
26+
27+
IMGCOMP_TOLERANCE = 7.0
28+
29+
# ---- Test 01 -----
30+
31+
fname=prefix+'01.png'
32+
mpf.plot(df,volume=True,savefig=tdir+fname)
33+
34+
os.system('ls -l '+tdir+fname)
35+
36+
result = compare_images(refd+fname,tdir+fname,tol=IMGCOMP_TOLERANCE)
37+
if result is not None:
38+
print('result=',result)
39+
assert result is None
40+
41+
# ---- Test 02 -----
42+
43+
fname=prefix+'02.png'
44+
apdict = mpf.make_addplot(df['LowerB'])
45+
mpf.plot(df,volume=True,addplot=apdict,savefig=tdir+fname)
46+
47+
os.system('ls -l '+tdir+fname)
48+
49+
result = compare_images(refd+fname,tdir+fname,tol=IMGCOMP_TOLERANCE)
50+
if result is not None:
51+
print('result=',result)
52+
assert result is None

examples/mpftests/test_images/placeholder.png

Loading

examples/savefig.ipynb

Lines changed: 69 additions & 161 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)