-
Notifications
You must be signed in to change notification settings - Fork 658
/
Copy pathtest_hlines.py
95 lines (77 loc) · 2.56 KB
/
test_hlines.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
import os
import os.path
import glob
import mplfinance as mpf
import matplotlib.pyplot as plt
from matplotlib.testing.compare import compare_images
print('mpf.__version__ =',mpf.__version__) # for the record
print("plt.rcParams['backend'] =",plt.rcParams['backend']) # for the record
base='hlines'
tdir = os.path.join('tests','test_images')
refd = os.path.join('tests','reference_images')
globpattern = os.path.join(tdir,base+'*.png')
oldtestfiles = glob.glob(globpattern)
for fn in oldtestfiles:
try:
os.remove(fn)
except:
print('Error removing file "'+fn+'"')
IMGCOMP_TOLERANCE = 10.0 # this works fine for linux
# IMGCOMP_TOLERANCE = 11.0 # required for a windows pass. (really 10.25 may do it).
def test_hlines01(bolldata):
df = bolldata
fname = base+'01.png'
tname = os.path.join(tdir,fname)
rname = os.path.join(refd,fname)
mpf.plot(df,volume=True,savefig=tname,hlines=[120])
tsize = os.path.getsize(tname)
print(glob.glob(tname),'[',tsize,'bytes',']')
rsize = os.path.getsize(rname)
print(glob.glob(rname),'[',rsize,'bytes',']')
result = compare_images(rname,tname,tol=IMGCOMP_TOLERANCE)
if result is not None:
print('result=',result)
assert result is None
def test_hlines02(bolldata):
df = bolldata
fname = base+'02.png'
tname = os.path.join(tdir,fname)
rname = os.path.join(refd,fname)
fig_axis = mpf.plot(
df,
type='ohlc',
volume=True,
savefig=tname,
returnfig=True,
hlines=dict(hlines=[120.000001, 130.0],linestyle='-.',colors='g')
)
tsize = os.path.getsize(tname)
print(glob.glob(tname),'[',tsize,'bytes',']')
rsize = os.path.getsize(rname)
print(glob.glob(rname),'[',rsize,'bytes',']')
result = compare_images(rname,tname,tol=IMGCOMP_TOLERANCE)
if result is not None:
print('result=',result)
assert result is None
#
#
# def test_vlines03(bolldata):
# df = bolldata
#
# fname = base+'03.png'
# tname = os.path.join(tdir,fname)
# rname = os.path.join(refd,fname)
#
# vl = dict(vlines='02-06-2012',linestyle='-.',colors='g')
# mpf.plot(df,type='pnf',vlines=vl,savefig=tname,pointnfig_params=dict(box_size=1.))
#
# tsize = os.path.getsize(tname)
# print(glob.glob(tname),'[',tsize,'bytes',']')
#
# rsize = os.path.getsize(rname)
# print(glob.glob(rname),'[',rsize,'bytes',']')
#
# result = compare_images(rname,tname,tol=IMGCOMP_TOLERANCE)
# if result is not None:
# print('result=',result)
# assert result is None