Skip to content

Commit e64b09a

Browse files
authored
Updated examples to support changes in Pandas and Numpy (sandialabs#85)
* bump action versions * added examples test * Updated to support changes to pandas styler * Updates to support np.multiply when dataframes have difference column names
1 parent 9ca3afe commit e64b09a

File tree

3 files changed

+53
-5
lines changed

3 files changed

+53
-5
lines changed

examples/dashboard/dashboard_example_3.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ def color_value(val):
5353
metrics.style
5454
.format("{:.2f}")
5555
.applymap(color_value)
56-
.highlight_null(null_color='gray')
57-
.render()
56+
.highlight_null(color='gray')
57+
.to_html()
5858
)
5959

6060
# Store content to be displayed in the dashboard

examples/pv/Baseline_config.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,9 @@ Baseline6kW Translation:
8787
Ref Cell Raw: [RefCell1R_Avg, RefCell2R_Avg]
8888

8989
Composite Signals:
90-
- DC Current: "np.sum({DC Current 1},axis=1), np.sum({DC Current 2},axis=1)"
91-
- DC Power: "np.multiply({DC Current},{DC Voltage})"
92-
- Inverter Efficiency: "np.divide({AC Power},{DC Power})"
90+
- DC Current: "np.sum({DC Current 1},axis=1), np.sum({DC Current 2}, axis=1)"
91+
- DC Power: "np.multiply({DC Current},{DC Voltage}.values)"
92+
- Inverter Efficiency: "np.divide({AC Power},{DC Power}.values)"
9393

9494
Corrupt Values: [-999]
9595

pecos/tests/test_examples.py

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# This is a test to ensure all of the examples run.
2+
import os
3+
import sys
4+
import unittest
5+
import pytest
6+
from os.path import abspath, dirname, join, basename
7+
from subprocess import call
8+
from glob import glob
9+
10+
testdir = dirname(abspath(str(__file__)))
11+
examplesdir = join(testdir, "..", "..", "examples")
12+
13+
14+
class TestExamples(unittest.TestCase):
15+
@classmethod
16+
def setUpClass(self):
17+
import pecos
18+
19+
self.pecos = pecos
20+
21+
@classmethod
22+
def tearDownClass(self):
23+
pass
24+
25+
@pytest.mark.time_consuming
26+
def test_that_examples_run(self):
27+
cwd = os.getcwd()
28+
example_files = []
29+
failed_examples = []
30+
flag = 0
31+
for f in glob(join(examplesdir, '**', '*.py'), recursive=True):
32+
filename = basename(f)
33+
directory = dirname(f)
34+
example_files.append(filename)
35+
os.chdir(directory)
36+
tmp_flag = call([sys.executable, filename])
37+
print(filename, tmp_flag)
38+
if tmp_flag == 1:
39+
failed_examples.append(filename)
40+
flag = 1
41+
os.chdir(cwd)
42+
if len(failed_examples) > 0:
43+
print("failed examples: {0}".format(failed_examples))
44+
self.assertEqual(flag, 0)
45+
46+
47+
if __name__ == "__main__":
48+
unittest.main()

0 commit comments

Comments
 (0)