Skip to content

Commit

Permalink
test: update tests for new change table storage format
Browse files Browse the repository at this point in the history
  • Loading branch information
danielolsen committed Feb 3, 2021
1 parent 90d0a43 commit 48a94d7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
4 changes: 2 additions & 2 deletions powersimdata/input/tests/test_change_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,15 +422,15 @@ def test_add_bus_bad_type(ct):


def test_add_new_elements_at_new_buses(ct):
max_existing_index = grid.bus.index.max()
max_existing_index = int(grid.bus.index.max())
new_buses = [
{"lat": 40, "lon": 50.5, "zone_id": 2, "baseKV": 69},
{"lat": -40.5, "lon": -50, "zone_name": "Massachusetts", "Pd": 10},
]
ct.add_bus(new_buses)
new_bus1 = max_existing_index + 1
new_bus2 = max_existing_index + 2
ct.add_storage_capacity(bus_id={new_bus1: 100})
ct.add_storage_capacity([{"bus_id": new_bus1, "capacity": 100}])
ct.add_dcline([{"from_bus_id": new_bus1, "to_bus_id": new_bus2, "capacity": 200}])
ct.add_branch([{"from_bus_id": new_bus1, "to_bus_id": new_bus2, "capacity": 300}])
ct.add_plant([{"type": "wind", "bus_id": new_bus2, "Pmax": 400}])
Expand Down
10 changes: 7 additions & 3 deletions powersimdata/input/tests/test_transform_grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -489,16 +489,20 @@ def test_add_gen_add_entries_in_gencost_data_frame(ct):


def test_add_storage(ct):
storage = {2021005: 116.0, 2028827: 82.5, 2028060: 82.5}
storage = [
{"bus_id": 2021005, "capacity": 116.0},
{"bus_id": 2028827, "capacity": 82.5},
{"bus_id": 2028060, "capacity": 82.5},
]
ct.add_storage_capacity(storage)
new_grid = TransformGrid(grid, ct.ct).get_grid()

pmin = new_grid.storage["gen"].Pmin.values
pmax = new_grid.storage["gen"].Pmax.values

assert new_grid.storage["gen"].shape[0] != grid.storage["gen"].shape[0]
assert np.array_equal(pmin, -1 * np.array(list(storage.values())))
assert np.array_equal(pmax, np.array(list(storage.values())))
assert np.array_equal(pmin, -1 * np.array([d["capacity"] for d in storage]))
assert np.array_equal(pmax, np.array([d["capacity"] for d in storage]))


def test_add_bus(ct):
Expand Down

0 comments on commit 48a94d7

Please sign in to comment.