-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtest_plots.py
88 lines (58 loc) · 2.06 KB
/
test_plots.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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import unittest
import opcsim
import pandas as pd
import os
import matplotlib as mpl
from opcsim.distributions import *
from opcsim.models import *
from opcsim.plots import *
class SetupTestCase(unittest.TestCase):
def setUp(self):
pass
def tearDown(self):
pass
def test_histplot(self):
opc = opcsim.OPC(wl=0.658, n_bins=10)
opc.calibrate("psl")
d = opcsim.load_distribution("Urban")
ax = opcsim.plots.histplot(opc.evaluate(d), opc.bins)
self.assertIsNotNone(ax)
def test_pdfplot(self):
d = opcsim.load_distribution("Urban")
ax = opcsim.plots.pdfplot(d)
self.assertIsNotNone(ax)
# Try with a different weight
ax = opcsim.plots.pdfplot(d, weight='volume')
self.assertIsNotNone(ax)
with self.assertRaises(Exception):
ax = opcsim.plots.pdfplot(1)
# Test invalid weight
with self.assertRaises(ValueError):
ax = opcsim.plots.pdfplot(d, weight='mass2')
# Test with_modes
ax = opcsim.plots.pdfplot(d, with_modes=True)
self.assertIsNotNone(ax)
def test_pdf_plot_with_fill(self):
d = opcsim.load_distribution("Urban")
ax = opcsim.plots.pdfplot(d, fill=True)
self.assertIsNotNone(ax)
# Try with a different weight
ax = opcsim.plots.pdfplot(d, weight='volume')
def test_cdfplot(self):
d = opcsim.load_distribution("Urban")
ax = opcsim.plots.cdfplot(d)
self.assertIsNotNone(ax)
# Try with a different weight
ax = opcsim.plots.cdfplot(d, weight='volume')
self.assertIsNotNone(ax)
with self.assertRaises(Exception):
ax = opcsim.plots.cdfplot(1)
# Test invalid weight
with self.assertRaises(ValueError):
ax = opcsim.plots.cdfplot(d, weight='mass2')
def test_calplot(self):
opc = opcsim.OPC(wl=0.658, n_bins=10)
opc.calibrate("psl", method="spline")
ax = opcsim.plots.calplot(opc)