Skip to content

Commit d79c24a

Browse files
author
Yingli
committed
code quality
1 parent 167f402 commit d79c24a

85 files changed

Lines changed: 66937 additions & 62779 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 43 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env python3
22

3-
""" Tests for AddKeyValsTest """
3+
"""Tests for AddKeyValsTest"""
44

55
from scout.ecm_prep import Measure
66
from scout.ecm_prep_vars import UsefulVars, UsefulInputFiles
@@ -29,61 +29,45 @@ def test_data():
2929
"structure_type": ["new", "existing"],
3030
"climate_zone": ["AIA_CZ1", "AIA_CZ2"],
3131
"bldg_type": ["single family home"],
32-
"fuel_type": {
33-
"primary": ["electricity"],
34-
"secondary": None},
32+
"fuel_type": {"primary": ["electricity"], "secondary": None},
3533
"fuel_switch_to": None,
36-
"end_use": {
37-
"primary": ["heating", "cooling"],
38-
"secondary": None},
34+
"end_use": {"primary": ["heating", "cooling"], "secondary": None},
3935
"technology": {
4036
"primary": ["resistance heat", "ASHP", "GSHP", "room AC"],
41-
"secondary": None}}
42-
sample_measure_in = Measure(
43-
base_dir, handyvars, handyfiles, opts_dict,
44-
**sample_measure_in)
45-
ok_dict1_in, ok_dict2_in = ({
46-
"level 1a": {
47-
"level 2aa": {"2009": 2, "2010": 3},
48-
"level 2ab": {"2009": 4, "2010": 5}},
49-
"level 1b": {
50-
"level 2ba": {"2009": 6, "2010": 7},
51-
"level 2bb": {"2009": 8, "2010": 9}}} for n in range(2))
52-
ok_dict3_in, ok_dict4_in = ({
53-
"level 1a": {
54-
"level 2aa": {"2009": 2, "2010": 3},
55-
"level 2ab": {"2009": 4, "2010": 5}},
56-
"lifetime": {
57-
"level 2ba": {"2009": 6, "2010": 7},
58-
"level 2bb": {"2009": 8, "2010": 9}}} for n in range(2))
37+
"secondary": None,
38+
},
39+
}
40+
sample_measure_in = Measure(base_dir, handyvars, handyfiles, opts_dict, **sample_measure_in)
41+
ok_dict1_in, ok_dict2_in = (
42+
{
43+
"level 1a": {"level 2aa": {"2009": 2, "2010": 3}, "level 2ab": {"2009": 4, "2010": 5}},
44+
"level 1b": {"level 2ba": {"2009": 6, "2010": 7}, "level 2bb": {"2009": 8, "2010": 9}},
45+
}
46+
for n in range(2)
47+
)
48+
ok_dict3_in, ok_dict4_in = (
49+
{
50+
"level 1a": {"level 2aa": {"2009": 2, "2010": 3}, "level 2ab": {"2009": 4, "2010": 5}},
51+
"lifetime": {"level 2ba": {"2009": 6, "2010": 7}, "level 2bb": {"2009": 8, "2010": 9}},
52+
}
53+
for n in range(2)
54+
)
5955
fail_dict1_in = {
60-
"level 1a": {
61-
"level 2aa": {"2009": 2, "2010": 3},
62-
"level 2ab": {"2009": 4, "2010": 5}},
63-
"level 1b": {
64-
"level 2ba": {"2009": 6, "2010": 7},
65-
"level 2bb": {"2009": 8, "2010": 9}}}
56+
"level 1a": {"level 2aa": {"2009": 2, "2010": 3}, "level 2ab": {"2009": 4, "2010": 5}},
57+
"level 1b": {"level 2ba": {"2009": 6, "2010": 7}, "level 2bb": {"2009": 8, "2010": 9}},
58+
}
6659
fail_dict2_in = {
67-
"level 1a": {
68-
"level 2aa": {"2009": 2, "2010": 3},
69-
"level 2ab": {"2009": 4, "2010": 5}},
70-
"level 1b": {
71-
"level 2ba": {"2009": 6, "2010": 7},
72-
"level 2bb": {"2009": 8, "2011": 9}}}
60+
"level 1a": {"level 2aa": {"2009": 2, "2010": 3}, "level 2ab": {"2009": 4, "2010": 5}},
61+
"level 1b": {"level 2ba": {"2009": 6, "2010": 7}, "level 2bb": {"2009": 8, "2011": 9}},
62+
}
7363
ok_out = {
74-
"level 1a": {
75-
"level 2aa": {"2009": 4, "2010": 6},
76-
"level 2ab": {"2009": 8, "2010": 10}},
77-
"level 1b": {
78-
"level 2ba": {"2009": 12, "2010": 14},
79-
"level 2bb": {"2009": 16, "2010": 18}}}
64+
"level 1a": {"level 2aa": {"2009": 4, "2010": 6}, "level 2ab": {"2009": 8, "2010": 10}},
65+
"level 1b": {"level 2ba": {"2009": 12, "2010": 14}, "level 2bb": {"2009": 16, "2010": 18}},
66+
}
8067
ok_out_restrict = {
81-
"level 1a": {
82-
"level 2aa": {"2009": 4, "2010": 6},
83-
"level 2ab": {"2009": 8, "2010": 10}},
84-
"lifetime": {
85-
"level 2ba": {"2009": 6, "2010": 7},
86-
"level 2bb": {"2009": 8, "2010": 9}}}
68+
"level 1a": {"level 2aa": {"2009": 4, "2010": 6}, "level 2ab": {"2009": 8, "2010": 10}},
69+
"lifetime": {"level 2ba": {"2009": 6, "2010": 7}, "level 2bb": {"2009": 8, "2010": 9}},
70+
}
8771

8872
return {
8973
"sample_measure_in": sample_measure_in,
@@ -106,7 +90,10 @@ def test_ok_add_keyvals(test_data):
10690
"""
10791
dict_check(
10892
test_data["sample_measure_in"].add_keyvals(
109-
test_data["ok_dict1_in"], test_data["ok_dict2_in"]), test_data["ok_out"])
93+
test_data["ok_dict1_in"], test_data["ok_dict2_in"]
94+
),
95+
test_data["ok_out"],
96+
)
11097

11198

11299
def test_fail_add_keyvals(test_data):
@@ -117,11 +104,15 @@ def test_fail_add_keyvals(test_data):
117104
"""
118105
with pytest.raises(KeyError):
119106
test_data["sample_measure_in"].add_keyvals(
120-
test_data["fail_dict1_in"], test_data["fail_dict2_in"])
107+
test_data["fail_dict1_in"], test_data["fail_dict2_in"]
108+
)
121109

122110

123111
def test_ok_add_keyvals_restrict(test_data):
124112
"""Test 'add_keyvals_restrict' function given valid inputs."""
125113
dict_check(
126114
test_data["sample_measure_in"].add_keyvals_restrict(
127-
test_data["ok_dict3_in"], test_data["ok_dict4_in"]), test_data["ok_out_restrict"])
115+
test_data["ok_dict3_in"], test_data["ok_dict4_in"]
116+
),
117+
test_data["ok_out_restrict"],
118+
)

0 commit comments

Comments
 (0)