ltbams 1.0.12__py3-none-any.whl → 1.0.13__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ams/_version.py +3 -3
- ams/core/matprocessor.py +170 -104
- ams/io/matpower.py +4 -0
- ams/io/psse.py +2 -0
- ams/opt/exprcalc.py +11 -0
- ams/routines/grbopt.py +2 -0
- ams/routines/pypower.py +8 -0
- ams/routines/routine.py +118 -1
- ams/shared.py +30 -2
- ams/system.py +10 -0
- docs/source/index.rst +4 -3
- docs/source/release-notes.rst +8 -0
- {ltbams-1.0.12.dist-info → ltbams-1.0.13.dist-info}/METADATA +4 -2
- {ltbams-1.0.12.dist-info → ltbams-1.0.13.dist-info}/RECORD +17 -45
- {ltbams-1.0.12.dist-info → ltbams-1.0.13.dist-info}/top_level.txt +0 -1
- tests/__init__.py +0 -0
- tests/test_1st_system.py +0 -64
- tests/test_addressing.py +0 -40
- tests/test_case.py +0 -301
- tests/test_cli.py +0 -34
- tests/test_export_csv.py +0 -89
- tests/test_group.py +0 -83
- tests/test_interface.py +0 -238
- tests/test_io.py +0 -190
- tests/test_jumper.py +0 -27
- tests/test_known_good.py +0 -267
- tests/test_matp.py +0 -437
- tests/test_model.py +0 -54
- tests/test_omodel.py +0 -119
- tests/test_paths.py +0 -89
- tests/test_report.py +0 -251
- tests/test_repr.py +0 -21
- tests/test_routine.py +0 -178
- tests/test_rtn_acopf.py +0 -75
- tests/test_rtn_dcopf.py +0 -121
- tests/test_rtn_dcopf2.py +0 -103
- tests/test_rtn_ed.py +0 -279
- tests/test_rtn_opf.py +0 -142
- tests/test_rtn_pflow.py +0 -147
- tests/test_rtn_pypower.py +0 -315
- tests/test_rtn_rted.py +0 -273
- tests/test_rtn_uc.py +0 -248
- tests/test_service.py +0 -73
- {ltbams-1.0.12.dist-info → ltbams-1.0.13.dist-info}/WHEEL +0 -0
- {ltbams-1.0.12.dist-info → ltbams-1.0.13.dist-info}/entry_points.txt +0 -0
tests/test_model.py
DELETED
@@ -1,54 +0,0 @@
|
|
1
|
-
import unittest
|
2
|
-
import numpy as np
|
3
|
-
|
4
|
-
import ams
|
5
|
-
|
6
|
-
|
7
|
-
class TestModelMethods(unittest.TestCase):
|
8
|
-
"""
|
9
|
-
Test methods of Model.
|
10
|
-
"""
|
11
|
-
|
12
|
-
def setUp(self):
|
13
|
-
self.ss = ams.run(
|
14
|
-
ams.get_case("ieee14/ieee14.json"),
|
15
|
-
default_config=True,
|
16
|
-
no_output=True,
|
17
|
-
)
|
18
|
-
|
19
|
-
def test_model_set(self):
|
20
|
-
"""
|
21
|
-
Test `Model.set()` method.
|
22
|
-
"""
|
23
|
-
|
24
|
-
# set a single value
|
25
|
-
self.ss.PQ.set("p0", "PQ_1", "v", 0.25)
|
26
|
-
self.assertEqual(self.ss.PQ.p0.v[0], 0.25)
|
27
|
-
|
28
|
-
# set a list of values
|
29
|
-
self.ss.PQ.set("p0", ["PQ_1", "PQ_2"], "v", [0.26, 0.51])
|
30
|
-
np.testing.assert_equal(self.ss.PQ.p0.v[[0, 1]], [0.26, 0.51])
|
31
|
-
|
32
|
-
# set a list of values
|
33
|
-
self.ss.PQ.set("p0", ["PQ_3", "PQ_5"], "v", [0.52, 0.16])
|
34
|
-
np.testing.assert_equal(self.ss.PQ.p0.v[[2, 4]], [0.52, 0.16])
|
35
|
-
|
36
|
-
# set a list of idxes with a single element to an array of values
|
37
|
-
self.ss.PQ.set("p0", ["PQ_4"], "v", np.array([0.086]))
|
38
|
-
np.testing.assert_equal(self.ss.PQ.p0.v[3], 0.086)
|
39
|
-
|
40
|
-
# set an array of idxes with a single element to an array of values
|
41
|
-
self.ss.PQ.set("p0", np.array(["PQ_4"]), "v", np.array([0.096]))
|
42
|
-
np.testing.assert_equal(self.ss.PQ.p0.v[3], 0.096)
|
43
|
-
|
44
|
-
# set an array of idxes with a list of single value
|
45
|
-
self.ss.PQ.set("p0", np.array(["PQ_4"]), "v", 0.097)
|
46
|
-
np.testing.assert_equal(self.ss.PQ.p0.v[3], 0.097)
|
47
|
-
|
48
|
-
def test_model_repr(self):
|
49
|
-
"""
|
50
|
-
Test `Model.__repr__()` method.
|
51
|
-
"""
|
52
|
-
|
53
|
-
for mdl in self.ss.models.items():
|
54
|
-
print(mdl.__repr__())
|
tests/test_omodel.py
DELETED
@@ -1,119 +0,0 @@
|
|
1
|
-
import unittest
|
2
|
-
|
3
|
-
import ams
|
4
|
-
|
5
|
-
|
6
|
-
class TestOModelWrappers(unittest.TestCase):
|
7
|
-
"""
|
8
|
-
Test wrappers in module `omodel`.
|
9
|
-
"""
|
10
|
-
|
11
|
-
def setUp(self) -> None:
|
12
|
-
self.ss = ams.load(ams.get_case("matpower/case5.m"),
|
13
|
-
setup=True,
|
14
|
-
default_config=True,
|
15
|
-
no_output=True,
|
16
|
-
)
|
17
|
-
|
18
|
-
def test_ensure_symbols(self):
|
19
|
-
"""
|
20
|
-
Test `ensure_symbols` wrapper.
|
21
|
-
"""
|
22
|
-
self.assertFalse(self.ss.DCOPF._syms, "Symbols should not be ready before generation!")
|
23
|
-
self.ss.DCOPF.pd.parse()
|
24
|
-
self.assertTrue(self.ss.DCOPF._syms, "Symbols should be ready after generation!")
|
25
|
-
|
26
|
-
def test_ensure_mats_and_parsed(self):
|
27
|
-
"""
|
28
|
-
Test `ensure_mats_and_parsed` wrapper.
|
29
|
-
"""
|
30
|
-
self.assertFalse(self.ss.mats.initialized, "MatProcessor should not be initialized before initialization!")
|
31
|
-
self.assertFalse(self.ss.DCOPF.om.parsed, "OModel should be parsed after parsing!")
|
32
|
-
self.ss.DCOPF.pd.evaluate()
|
33
|
-
self.assertTrue(self.ss.mats.initialized, "MatProcessor should be initialized after parsing!")
|
34
|
-
self.assertTrue(self.ss.DCOPF.om.parsed, "OModle should be parsed after parsing!")
|
35
|
-
|
36
|
-
|
37
|
-
class TestOModel(unittest.TestCase):
|
38
|
-
"""
|
39
|
-
Test class `OModel`.
|
40
|
-
"""
|
41
|
-
|
42
|
-
def setUp(self) -> None:
|
43
|
-
self.ss = ams.load(ams.get_case("matpower/case5.m"),
|
44
|
-
setup=True,
|
45
|
-
default_config=True,
|
46
|
-
no_output=True,
|
47
|
-
)
|
48
|
-
|
49
|
-
def test_initialized(self):
|
50
|
-
"""
|
51
|
-
Test `OModel` initialization.
|
52
|
-
"""
|
53
|
-
self.assertFalse(self.ss.DCOPF.om.initialized, "OModel shoud not be initialized before initialziation!")
|
54
|
-
self.ss.DCOPF.om.init()
|
55
|
-
self.assertTrue(self.ss.DCOPF.om.initialized, "OModel should be initialized!")
|
56
|
-
|
57
|
-
def test_uninitialized_after_nonparametric_update(self):
|
58
|
-
"""
|
59
|
-
Test `OModel` initialization after nonparametric update.
|
60
|
-
"""
|
61
|
-
self.ss.DCOPF.om.init()
|
62
|
-
self.assertTrue(self.ss.DCOPF.om.initialized, "OModel should be initialized after initialization!")
|
63
|
-
self.ss.DCOPF.update('ug')
|
64
|
-
self.assertTrue(self.ss.DCOPF.om.initialized, "OModel should be initialized after nonparametric update!")
|
65
|
-
|
66
|
-
|
67
|
-
class TestOModelrepr(unittest.TestCase):
|
68
|
-
"""
|
69
|
-
Test __repr__ in module `omodel`.
|
70
|
-
"""
|
71
|
-
|
72
|
-
def setUp(self) -> None:
|
73
|
-
self.ss = ams.load(ams.get_case("5bus/pjm5bus_demo.json"),
|
74
|
-
setup=True,
|
75
|
-
default_config=True,
|
76
|
-
no_output=True,
|
77
|
-
)
|
78
|
-
|
79
|
-
def test_dcopf(self):
|
80
|
-
"""
|
81
|
-
Test `DCOPF.om` __repr__().
|
82
|
-
"""
|
83
|
-
self.ss.DCOPF.om.parse()
|
84
|
-
self.assertIsInstance(self.ss.DCOPF.pg.__repr__(), str)
|
85
|
-
self.assertIsInstance(self.ss.DCOPF.pmax.__repr__(), str)
|
86
|
-
self.assertIsInstance(self.ss.DCOPF.pb.__repr__(), str)
|
87
|
-
self.assertIsInstance(self.ss.DCOPF.plflb.__repr__(), str)
|
88
|
-
self.assertIsInstance(self.ss.DCOPF.obj.__repr__(), str)
|
89
|
-
|
90
|
-
def test_rted(self):
|
91
|
-
"""
|
92
|
-
Test `RTED.om` __repr__().
|
93
|
-
"""
|
94
|
-
self.ss.RTED.om.parse()
|
95
|
-
self.assertIsInstance(self.ss.RTED.pru.__repr__(), str)
|
96
|
-
self.assertIsInstance(self.ss.RTED.R10.__repr__(), str)
|
97
|
-
self.assertIsInstance(self.ss.RTED.pru.__repr__(), str)
|
98
|
-
self.assertIsInstance(self.ss.RTED.rru.__repr__(), str)
|
99
|
-
self.assertIsInstance(self.ss.RTED.obj.__repr__(), str)
|
100
|
-
|
101
|
-
def test_ed(self):
|
102
|
-
"""
|
103
|
-
Test `ED.om` __repr__().
|
104
|
-
"""
|
105
|
-
self.ss.ED.om.parse()
|
106
|
-
self.assertIsInstance(self.ss.ED.prs.__repr__(), str)
|
107
|
-
self.assertIsInstance(self.ss.ED.R30.__repr__(), str)
|
108
|
-
self.assertIsInstance(self.ss.ED.prsb.__repr__(), str)
|
109
|
-
self.assertIsInstance(self.ss.ED.obj.__repr__(), str)
|
110
|
-
|
111
|
-
def test_uc(self):
|
112
|
-
"""
|
113
|
-
Test `UC.om` __repr__().
|
114
|
-
"""
|
115
|
-
self.ss.UC.om.parse()
|
116
|
-
self.assertIsInstance(self.ss.UC.prns.__repr__(), str)
|
117
|
-
self.assertIsInstance(self.ss.UC.cdp.__repr__(), str)
|
118
|
-
self.assertIsInstance(self.ss.UC.prnsb.__repr__(), str)
|
119
|
-
self.assertIsInstance(self.ss.UC.obj.__repr__(), str)
|
tests/test_paths.py
DELETED
@@ -1,89 +0,0 @@
|
|
1
|
-
import unittest
|
2
|
-
|
3
|
-
import os
|
4
|
-
|
5
|
-
import ams
|
6
|
-
from ams.utils.paths import list_cases, get_export_path
|
7
|
-
|
8
|
-
|
9
|
-
class TestPaths(unittest.TestCase):
|
10
|
-
def setUp(self) -> None:
|
11
|
-
self.npcc = 'npcc/'
|
12
|
-
self.matpower = 'matpower/'
|
13
|
-
self.ieee14 = ams.get_case("ieee14/ieee14.raw")
|
14
|
-
|
15
|
-
def test_tree(self):
|
16
|
-
list_cases(self.npcc, no_print=True)
|
17
|
-
list_cases(self.matpower, no_print=True)
|
18
|
-
|
19
|
-
def test_relative_path(self):
|
20
|
-
ss = ams.run('ieee14.raw',
|
21
|
-
input_path=ams.get_case('ieee14/', check=False),
|
22
|
-
no_output=True, default_config=True,
|
23
|
-
)
|
24
|
-
self.assertNotEqual(ss, None)
|
25
|
-
|
26
|
-
|
27
|
-
class TestExportPath(unittest.TestCase):
|
28
|
-
|
29
|
-
def setUp(self) -> None:
|
30
|
-
self.ss = ams.load(ams.get_case('5bus/pjm5bus_demo.json'),
|
31
|
-
setup=True, no_output=True)
|
32
|
-
|
33
|
-
def test_no_fullname(self):
|
34
|
-
"""
|
35
|
-
Test export path with no full name specified.
|
36
|
-
"""
|
37
|
-
self.ss.files.full_name = None
|
38
|
-
|
39
|
-
path, file_name = get_export_path(self.ss,
|
40
|
-
'DCOPF',
|
41
|
-
path=None,
|
42
|
-
fmt='csv')
|
43
|
-
|
44
|
-
dir_path, only_file_name = os.path.split(path)
|
45
|
-
self.assertTrue(os.path.exists(dir_path))
|
46
|
-
self.assertIsNotNone(only_file_name)
|
47
|
-
self.assertEqual(only_file_name, file_name)
|
48
|
-
|
49
|
-
def test_no_path(self):
|
50
|
-
"""
|
51
|
-
Test export path with no path specified.
|
52
|
-
"""
|
53
|
-
path, file_name = get_export_path(self.ss,
|
54
|
-
'DCOPF',
|
55
|
-
path=None,
|
56
|
-
fmt='csv')
|
57
|
-
|
58
|
-
dir_path, only_file_name = os.path.split(path)
|
59
|
-
self.assertTrue(os.path.exists(dir_path))
|
60
|
-
self.assertIsNotNone(only_file_name)
|
61
|
-
self.assertEqual(only_file_name, file_name)
|
62
|
-
|
63
|
-
def test_current_path(self):
|
64
|
-
"""
|
65
|
-
Test export path with current path specified.
|
66
|
-
"""
|
67
|
-
path, file_name = get_export_path(self.ss,
|
68
|
-
'DCOPF',
|
69
|
-
path='.',
|
70
|
-
fmt='csv')
|
71
|
-
|
72
|
-
dir_path, only_file_name = os.path.split(path)
|
73
|
-
self.assertTrue(os.path.exists(dir_path))
|
74
|
-
self.assertIsNotNone(only_file_name)
|
75
|
-
self.assertEqual(only_file_name, file_name)
|
76
|
-
|
77
|
-
def test_path_with_file_name(self):
|
78
|
-
"""
|
79
|
-
Test export path with path and file name specified.
|
80
|
-
"""
|
81
|
-
path, file_name = get_export_path(self.ss,
|
82
|
-
'DCOPF',
|
83
|
-
path='./test_export.csv',
|
84
|
-
fmt='csv',)
|
85
|
-
|
86
|
-
dir_path, only_file_name = os.path.split(path)
|
87
|
-
self.assertTrue(os.path.exists(dir_path))
|
88
|
-
self.assertEqual(only_file_name, 'test_export.csv')
|
89
|
-
self.assertEqual(only_file_name, file_name)
|
tests/test_report.py
DELETED
@@ -1,251 +0,0 @@
|
|
1
|
-
"""
|
2
|
-
Test system report.
|
3
|
-
"""
|
4
|
-
import unittest
|
5
|
-
import os
|
6
|
-
|
7
|
-
import ams
|
8
|
-
from ams.shared import skip_unittest_without_MISOCP
|
9
|
-
|
10
|
-
|
11
|
-
import logging
|
12
|
-
|
13
|
-
logger = logging.getLogger(__name__)
|
14
|
-
|
15
|
-
|
16
|
-
class TestReport(unittest.TestCase):
|
17
|
-
"""
|
18
|
-
Tests for Report class.
|
19
|
-
"""
|
20
|
-
|
21
|
-
def setUp(self) -> None:
|
22
|
-
self.ss = ams.main.load(
|
23
|
-
ams.get_case("5bus/pjm5bus_demo.json"),
|
24
|
-
default_config=True,
|
25
|
-
no_output=True,
|
26
|
-
)
|
27
|
-
self.expected_report = 'pjm5bus_demo_out.txt'
|
28
|
-
|
29
|
-
def test_no_output(self):
|
30
|
-
"""
|
31
|
-
Test no output.
|
32
|
-
"""
|
33
|
-
self.assertTrue(self.ss.files.no_output)
|
34
|
-
self.assertFalse(self.ss.report())
|
35
|
-
|
36
|
-
def test_no_report(self):
|
37
|
-
"""
|
38
|
-
Test report with no solved routine.
|
39
|
-
"""
|
40
|
-
self.ss.files.no_output = False
|
41
|
-
self.assertTrue(self.ss.report())
|
42
|
-
self.assertTrue(os.path.exists(self.expected_report))
|
43
|
-
|
44
|
-
with open(self.expected_report, "r") as report_file:
|
45
|
-
file_contents = report_file.read()
|
46
|
-
self.assertNotIn("DCOPF", file_contents)
|
47
|
-
|
48
|
-
os.remove(self.expected_report)
|
49
|
-
|
50
|
-
def test_DCOPF_report(self):
|
51
|
-
"""
|
52
|
-
Test report with DCOPF solved.
|
53
|
-
"""
|
54
|
-
self.ss.files.no_output = False
|
55
|
-
self.ss.DCOPF.run(solver='CLARABEL')
|
56
|
-
self.assertTrue(self.ss.report())
|
57
|
-
self.assertTrue(os.path.exists(self.expected_report))
|
58
|
-
|
59
|
-
with open(self.expected_report, "r") as report_file:
|
60
|
-
file_contents = report_file.read()
|
61
|
-
self.assertIn("DCOPF", file_contents)
|
62
|
-
os.remove(self.expected_report)
|
63
|
-
|
64
|
-
self.ss.DCOPF.export_csv()
|
65
|
-
self.assertTrue(os.path.exists('pjm5bus_demo_DCOPF.csv'))
|
66
|
-
os.remove('pjm5bus_demo_DCOPF.csv')
|
67
|
-
|
68
|
-
def test_DCPF_report(self):
|
69
|
-
"""
|
70
|
-
Test report with DCPF solved.
|
71
|
-
"""
|
72
|
-
self.ss.files.no_output = False
|
73
|
-
self.ss.DCPF.run(solver='CLARABEL')
|
74
|
-
self.assertTrue(self.ss.report())
|
75
|
-
self.assertTrue(os.path.exists(self.expected_report))
|
76
|
-
|
77
|
-
with open(self.expected_report, "r") as report_file:
|
78
|
-
file_contents = report_file.read()
|
79
|
-
self.assertIn("DCPF", file_contents)
|
80
|
-
os.remove(self.expected_report)
|
81
|
-
|
82
|
-
self.ss.DCPF.export_csv()
|
83
|
-
self.assertTrue(os.path.exists('pjm5bus_demo_DCPF.csv'))
|
84
|
-
os.remove('pjm5bus_demo_DCPF.csv')
|
85
|
-
|
86
|
-
def test_RTED_report(self):
|
87
|
-
"""
|
88
|
-
Test report with RTED solved.
|
89
|
-
"""
|
90
|
-
self.ss.files.no_output = False
|
91
|
-
self.ss.RTED.run(solver='CLARABEL')
|
92
|
-
self.assertTrue(self.ss.report())
|
93
|
-
self.assertTrue(os.path.exists(self.expected_report))
|
94
|
-
|
95
|
-
with open(self.expected_report, "r") as report_file:
|
96
|
-
file_contents = report_file.read()
|
97
|
-
self.assertIn("RTED", file_contents)
|
98
|
-
os.remove(self.expected_report)
|
99
|
-
|
100
|
-
self.ss.RTED.export_csv()
|
101
|
-
self.assertTrue(os.path.exists('pjm5bus_demo_RTED.csv'))
|
102
|
-
os.remove('pjm5bus_demo_RTED.csv')
|
103
|
-
|
104
|
-
def test_RTEDDG_report(self):
|
105
|
-
"""
|
106
|
-
Test report with RTEDDG solved.
|
107
|
-
"""
|
108
|
-
self.ss.files.no_output = False
|
109
|
-
self.ss.RTEDDG.run(solver='CLARABEL')
|
110
|
-
self.assertTrue(self.ss.report())
|
111
|
-
self.assertTrue(os.path.exists(self.expected_report))
|
112
|
-
|
113
|
-
with open(self.expected_report, "r") as report_file:
|
114
|
-
file_contents = report_file.read()
|
115
|
-
self.assertIn("RTEDDG", file_contents)
|
116
|
-
os.remove(self.expected_report)
|
117
|
-
|
118
|
-
self.ss.RTEDDG.export_csv()
|
119
|
-
self.assertTrue(os.path.exists('pjm5bus_demo_RTEDDG.csv'))
|
120
|
-
os.remove('pjm5bus_demo_RTEDDG.csv')
|
121
|
-
|
122
|
-
@skip_unittest_without_MISOCP
|
123
|
-
def test_RTEDES_report(self):
|
124
|
-
"""
|
125
|
-
Test report with RTEDES solved.
|
126
|
-
"""
|
127
|
-
self.ss.files.no_output = False
|
128
|
-
self.ss.RTEDES.run(solver='SCIP')
|
129
|
-
self.assertTrue(self.ss.report())
|
130
|
-
self.assertTrue(os.path.exists(self.expected_report))
|
131
|
-
|
132
|
-
with open(self.expected_report, "r") as report_file:
|
133
|
-
file_contents = report_file.read()
|
134
|
-
self.assertIn("RTEDES", file_contents)
|
135
|
-
os.remove(self.expected_report)
|
136
|
-
|
137
|
-
self.ss.RTEDES.export_csv()
|
138
|
-
self.assertTrue(os.path.exists('pjm5bus_demo_RTEDES.csv'))
|
139
|
-
os.remove('pjm5bus_demo_RTEDES.csv')
|
140
|
-
|
141
|
-
def test_ED_report(self):
|
142
|
-
"""
|
143
|
-
Test report with ED solved.
|
144
|
-
"""
|
145
|
-
self.ss.files.no_output = False
|
146
|
-
self.ss.ED.run(solver='CLARABEL')
|
147
|
-
self.assertTrue(self.ss.report())
|
148
|
-
self.assertTrue(os.path.exists(self.expected_report))
|
149
|
-
|
150
|
-
with open(self.expected_report, "r") as report_file:
|
151
|
-
file_contents = report_file.read()
|
152
|
-
self.assertIn("ED", file_contents)
|
153
|
-
os.remove(self.expected_report)
|
154
|
-
|
155
|
-
self.ss.ED.export_csv()
|
156
|
-
self.assertTrue(os.path.exists('pjm5bus_demo_ED.csv'))
|
157
|
-
os.remove('pjm5bus_demo_ED.csv')
|
158
|
-
|
159
|
-
def test_EDDG_report(self):
|
160
|
-
"""
|
161
|
-
Test report with EDDG solved.
|
162
|
-
"""
|
163
|
-
self.ss.files.no_output = False
|
164
|
-
self.ss.EDDG.run(solver='CLARABEL')
|
165
|
-
self.assertTrue(self.ss.report())
|
166
|
-
self.assertTrue(os.path.exists(self.expected_report))
|
167
|
-
|
168
|
-
with open(self.expected_report, "r") as report_file:
|
169
|
-
file_contents = report_file.read()
|
170
|
-
self.assertIn("EDDG", file_contents)
|
171
|
-
os.remove(self.expected_report)
|
172
|
-
|
173
|
-
self.ss.EDDG.export_csv()
|
174
|
-
self.assertTrue(os.path.exists('pjm5bus_demo_EDDG.csv'))
|
175
|
-
os.remove('pjm5bus_demo_EDDG.csv')
|
176
|
-
|
177
|
-
@skip_unittest_without_MISOCP
|
178
|
-
def test_EDES_report(self):
|
179
|
-
"""
|
180
|
-
Test report with EDES solved.
|
181
|
-
"""
|
182
|
-
self.ss.files.no_output = False
|
183
|
-
self.ss.EDES.run(solver='SCIP')
|
184
|
-
self.assertTrue(self.ss.report())
|
185
|
-
self.assertTrue(os.path.exists(self.expected_report))
|
186
|
-
|
187
|
-
with open(self.expected_report, "r") as report_file:
|
188
|
-
file_contents = report_file.read()
|
189
|
-
self.assertIn("EDES", file_contents)
|
190
|
-
os.remove(self.expected_report)
|
191
|
-
|
192
|
-
self.ss.EDES.export_csv()
|
193
|
-
self.assertTrue(os.path.exists('pjm5bus_demo_EDES.csv'))
|
194
|
-
os.remove('pjm5bus_demo_EDES.csv')
|
195
|
-
|
196
|
-
@skip_unittest_without_MISOCP
|
197
|
-
def test_UC_report(self):
|
198
|
-
"""
|
199
|
-
Test report with UC solved.
|
200
|
-
"""
|
201
|
-
self.ss.files.no_output = False
|
202
|
-
self.ss.UC.run(solver='SCIP')
|
203
|
-
self.assertTrue(self.ss.report())
|
204
|
-
self.assertTrue(os.path.exists(self.expected_report))
|
205
|
-
|
206
|
-
with open(self.expected_report, "r") as report_file:
|
207
|
-
file_contents = report_file.read()
|
208
|
-
self.assertIn("UC", file_contents)
|
209
|
-
os.remove(self.expected_report)
|
210
|
-
|
211
|
-
self.ss.UC.export_csv()
|
212
|
-
self.assertTrue(os.path.exists('pjm5bus_demo_UC.csv'))
|
213
|
-
os.remove('pjm5bus_demo_UC.csv')
|
214
|
-
|
215
|
-
@skip_unittest_without_MISOCP
|
216
|
-
def test_UCDG_report(self):
|
217
|
-
"""
|
218
|
-
Test report with UCDG solved.
|
219
|
-
"""
|
220
|
-
self.ss.files.no_output = False
|
221
|
-
self.ss.UCDG.run(solver='SCIP')
|
222
|
-
self.assertTrue(self.ss.report())
|
223
|
-
self.assertTrue(os.path.exists(self.expected_report))
|
224
|
-
|
225
|
-
with open(self.expected_report, "r") as report_file:
|
226
|
-
file_contents = report_file.read()
|
227
|
-
self.assertIn("UCDG", file_contents)
|
228
|
-
os.remove(self.expected_report)
|
229
|
-
|
230
|
-
self.ss.UCDG.export_csv()
|
231
|
-
self.assertTrue(os.path.exists('pjm5bus_demo_UCDG.csv'))
|
232
|
-
os.remove('pjm5bus_demo_UCDG.csv')
|
233
|
-
|
234
|
-
@skip_unittest_without_MISOCP
|
235
|
-
def test_UCES_report(self):
|
236
|
-
"""
|
237
|
-
Test report with UCES solved.
|
238
|
-
"""
|
239
|
-
self.ss.files.no_output = False
|
240
|
-
self.ss.UCES.run(solver='SCIP')
|
241
|
-
self.assertTrue(self.ss.report())
|
242
|
-
self.assertTrue(os.path.exists(self.expected_report))
|
243
|
-
|
244
|
-
with open(self.expected_report, "r") as report_file:
|
245
|
-
file_contents = report_file.read()
|
246
|
-
self.assertIn("UCES", file_contents)
|
247
|
-
os.remove(self.expected_report)
|
248
|
-
|
249
|
-
self.ss.UCES.export_csv()
|
250
|
-
self.assertTrue(os.path.exists('pjm5bus_demo_UCES.csv'))
|
251
|
-
os.remove('pjm5bus_demo_UCES.csv')
|
tests/test_repr.py
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
import contextlib
|
2
|
-
import unittest
|
3
|
-
|
4
|
-
import ams
|
5
|
-
|
6
|
-
|
7
|
-
class TestRepr(unittest.TestCase):
|
8
|
-
"""Test __repr__"""
|
9
|
-
def setUp(self):
|
10
|
-
self.ss = ams.run(ams.get_case("ieee39/ieee39_uced.xlsx"),
|
11
|
-
no_output=True,
|
12
|
-
default_config=True,
|
13
|
-
)
|
14
|
-
|
15
|
-
def test_print_model_repr(self):
|
16
|
-
"""
|
17
|
-
Print out Model ``cache``'s fields and values.
|
18
|
-
"""
|
19
|
-
with contextlib.redirect_stdout(None):
|
20
|
-
for model in self.ss.models.values():
|
21
|
-
print(model.cache.__dict__)
|