|
12 | 12 | import yaml |
13 | 13 | import numpy as np |
14 | 14 | import pandas as pd |
| 15 | +import os |
15 | 16 | from numpy.testing import assert_array_almost_equal, assert_array_equal, assert_allclose |
16 | 17 | from ruspy.estimation.estimation import estimate |
17 | 18 | from ruspy.ruspy_config import TEST_RESOURCES_DIR |
|
20 | 21 |
|
21 | 22 | with open(TEST_RESOURCES_DIR + "replication_test/init_replication_test.yml") as y: |
22 | 23 | init_dict = yaml.safe_load(y) |
23 | | -group_folder = "replication_test/group_4/" |
24 | | -bus_id = np.loadtxt(TEST_RESOURCES_DIR + group_folder + "Bus_ID.txt", dtype=int) |
25 | | -state = np.loadtxt(TEST_RESOURCES_DIR + group_folder + "state.txt", dtype=int) |
26 | | -decision = np.loadtxt(TEST_RESOURCES_DIR + group_folder + "decision.txt", dtype=int) |
27 | | -period = np.loadtxt(TEST_RESOURCES_DIR + group_folder + "period.txt", dtype=int) |
28 | | -data = pd.DataFrame( |
29 | | - {"Bus_ID": bus_id, "state": state, "decision": decision, "period": period} |
30 | | -) |
31 | | -result_trans, result_fixp = estimate(init_dict["replication"], data, repl_4=True) |
| 24 | +group_folder = TEST_RESOURCES_DIR + "replication_test/group_4/" |
| 25 | +data = {} |
| 26 | +for file in os.listdir(group_folder): |
| 27 | + data[os.fsdecode(file)[:-4]] = np.loadtxt(group_folder + file, dtype=int) |
| 28 | +df = pd.DataFrame(data) |
| 29 | +result_trans, result_fixp = estimate(init_dict["replication"], df, repl_4=True) |
32 | 30 |
|
33 | 31 |
|
34 | 32 | @pytest.fixture |
@@ -75,10 +73,10 @@ def test_cost_ll(inputs, outputs): |
75 | 73 |
|
76 | 74 |
|
77 | 75 | def test_transition_count(outputs): |
78 | | - num_bus = len(data["Bus_ID"].unique()) |
79 | | - num_periods = int(data.shape[0] / num_bus) |
80 | | - states = data["state"].values.reshape(num_bus, num_periods) |
81 | | - decisions = data["decision"].values.reshape(num_bus, num_periods) |
| 76 | + num_bus = len(df["Bus_ID"].unique()) |
| 77 | + num_periods = int(df.shape[0] / num_bus) |
| 78 | + states = df["state"].values.reshape(num_bus, num_periods) |
| 79 | + decisions = df["decision"].values.reshape(num_bus, num_periods) |
82 | 80 | space_state = states.max() + 1 |
83 | 81 | state_count = np.zeros(shape=(space_state, space_state), dtype=int) |
84 | 82 | increases = np.zeros(shape=(num_bus, num_periods - 1), dtype=int) |
|
0 commit comments