Skip to content

Commit

Permalink
Add test on GroupBase.finx_idx
Browse files Browse the repository at this point in the history
  • Loading branch information
jinningwang committed Sep 27, 2024
1 parent 1e71bf2 commit 4d69304
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tests/test_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ def test_group_access(self):
[6, 7, 8, 1])

# --- find_idx ---
# same Model
self.assertListEqual(ss.DG.find_idx('name', ['PVD1_1', 'PVD1_2']),
ss.PVD1.find_idx('name', ['PVD1_1', 'PVD1_2']),
)
Expand All @@ -82,6 +83,22 @@ def test_group_access(self):
[('PVD1_1', 'PVD1_2'),
(1.0, 1.0)]))

# cross Model, given results
self.assertListEqual(ss.StaticGen.find_idx(keys='bus',
values=[1, 2, 3, 4]),
[1, 2, 3, 6])

self.assertListEqual(ss.StaticGen.find_idx(keys='bus',
values=[1, 2, 3, 4],
no_flatten=True),
[[1], [2], [3], [6]])

self.assertListEqual(ss.StaticGen.find_idx(keys='bus',
values=[1, 2, 3, 4, 2024],
allow_none=True,
default=2011),
[1, 2, 3, 6, 2011])

# --- get_field ---
ff = ss.DG.get_field('f', list(ss.DG._idx2model.keys()), 'v_code')
self.assertTrue(any([item == 'y' for item in ff]))

0 comments on commit 4d69304

Please sign in to comment.