Skip to content

Commit

Permalink
Fix test_export_csv
Browse files Browse the repository at this point in the history
  • Loading branch information
jinningwang committed Nov 24, 2024
1 parent 1dc7c6e commit fe1d179
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions tests/test_export_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def test_export_DCOPF(self):
Test export DCOPF to CSV.
"""
self.ss.DCOPF.run(solver='CLARABEL')
self.assertTrue(self.ss.DCOPF.export_csv())
self.ss.DCOPF.export_csv(self.expected_csv_DCOPF)
self.assertTrue(os.path.exists(self.expected_csv_DCOPF))

n_rows = 0
Expand All @@ -48,7 +48,9 @@ def test_export_DCOPF(self):
if n_cols == 0 or len(row) > n_cols:
n_cols = len(row)

n_cols_expected = np.sum([v.shape[0] for v in self.ss.DCOPF.vars.values()])
n_cols_expected = np.sum([v.owner.n for v in self.ss.DCOPF.vars.values()])
n_cols_expected += np.sum([v.owner.n for v in self.ss.DCOPF.exprs.values()])
n_cols_expected += np.sum([v.owner.n for v in self.ss.DCOPF.exprcs.values()])
# cols number plus one for the index column
self.assertEqual(n_cols, n_cols_expected + 1)
# header row plus data row
Expand All @@ -62,7 +64,7 @@ def test_export_ED(self):
Test export ED to CSV.
"""
self.ss.ED.run(solver='CLARABEL')
self.assertTrue(self.ss.ED.export_csv())
self.ss.ED.export_csv(self.expected_csv_ED)
self.assertTrue(os.path.exists(self.expected_csv_ED))

n_rows = 0
Expand All @@ -75,7 +77,9 @@ def test_export_ED(self):
if n_cols == 0 or len(row) > n_cols:
n_cols = len(row)

n_cols_expected = np.sum([v.shape[0] for v in self.ss.ED.vars.values()])
n_cols_expected = np.sum([v.owner.n for v in self.ss.ED.vars.values()])
n_cols_expected += np.sum([v.owner.n for v in self.ss.ED.exprs.values()])
n_cols_expected += np.sum([v.owner.n for v in self.ss.ED.exprcs.values()])
# cols number plus one for the index column
self.assertEqual(n_cols, n_cols_expected + 1)
# header row plus data row
Expand Down

0 comments on commit fe1d179

Please sign in to comment.