-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_plotters.py
30 lines (26 loc) · 1012 Bytes
/
test_plotters.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
import os
import pandas as pd
from . import plotters
currentPath = os.path.dirname(os.path.realpath(__file__))
testResultsDir = os.path.join(currentPath, '.test_results')
if not os.path.exists(testResultsDir):
os.mkdir(testResultsDir)
def test_plotHeatmapFromDf():
""" Saves a plot in the folder given by the varaible testResultsDir. The
plot should be of a heat map with four squares. Each square on the bottom
should be lighter than the square directly above it. Each square on the
left should be lighter than the square directly to the right.
"""
cbarMode = 'auto'
cbarSpec = {'cCenter': 0,
'cMap': 'RdBu_r',
'addCBar': True}
df = pd.DataFrame()
df.loc[1, 1] = 0
df.loc[2, 1] = 10
df.loc[1, 2] = 50
df.loc[2, 2] = 100
fig = plotters.plotHeatmapFromDf(df, cbarMode=cbarMode, cbarSpec=cbarSpec)
plotters.saveFigAndClose(
os.path.join(testResultsDir, 'plotHeatmapFromDf.pdf'),
figsToSave = fig)