Skip to content

Commit

Permalink
Remove simulation concept
Browse files Browse the repository at this point in the history
  • Loading branch information
yngve-sk committed Nov 19, 2024
1 parent cf451e2 commit 5002365
Show file tree
Hide file tree
Showing 11 changed files with 23 additions and 46 deletions.
4 changes: 2 additions & 2 deletions everviz/pages/deltaplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@


def _get_objective_delta_values(api, best_batch):
data = pd.DataFrame(api.objective_values).drop(columns=["simulation"])
data = pd.DataFrame(api.objective_values)
initial = data[(data.batch == 0)].drop(columns=["batch"])
best = data[data.batch == best_batch].drop(columns=["batch"])
initial = initial.pivot(index="realization", values="value", columns="function")
Expand All @@ -25,7 +25,7 @@ def _get_summary_delta_values(api, best_batch):
if summary.empty:
return summary
data = (
summary.drop(columns="simulation")
summary
.set_index(["realization", "date"])
.dropna(axis=1, how="all")
)
Expand Down
1 change: 0 additions & 1 deletion everviz/pages/objectives.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ def _total_objective_values_from_api(api):

def _objective_values(data):
# Sort by the index columns.
data = data.drop(columns=["simulation"])
sorted_values = (
data.set_index(["function", "batch", "realization"]).sort_index().reset_index()
)
Expand Down
2 changes: 1 addition & 1 deletion everviz/pages/summary_values.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
def _summary_values(summary_values):
# Sort by the index columns.
sorted_values = (
summary_values.drop(columns="simulation")
summary_values
.set_index(["batch", "date", "realization"])
.dropna(axis=1, how="all")
.sort_index()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
from everviz.pages.deltaplot import _get_objective_delta_values

_OBJECTIVES = [
{"batch": 0, "realization": 1, "function": "f0", "value": 100, "simulation": 1},
{"batch": 0, "realization": 2, "function": "f0", "value": 200, "simulation": 2},
{"batch": 0, "realization": 1, "function": "f1", "value": 300, "simulation": 1},
{"batch": 0, "realization": 2, "function": "f1", "value": 400, "simulation": 2},
{"batch": 2, "realization": 1, "function": "f0", "value": 500, "simulation": 1},
{"batch": 2, "realization": 2, "function": "f0", "value": 600, "simulation": 2},
{"batch": 2, "realization": 1, "function": "f1", "value": 800, "simulation": 1},
{"batch": 2, "realization": 2, "function": "f1", "value": 900, "simulation": 2},
{"batch": 0, "realization": 1, "function": "f0", "value": 100 },
{"batch": 0, "realization": 2, "function": "f0", "value": 200 },
{"batch": 0, "realization": 1, "function": "f1", "value": 300 },
{"batch": 0, "realization": 2, "function": "f1", "value": 400 },
{"batch": 2, "realization": 1, "function": "f0", "value": 500 },
{"batch": 2, "realization": 2, "function": "f0", "value": 600 },
{"batch": 2, "realization": 1, "function": "f1", "value": 800 },
{"batch": 2, "realization": 2, "function": "f1", "value": 900 },
]


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

_SUMMARY = {
"realization": 3 * [1] + 3 * [2] + 3 * [1] + 3 * [2],
"simulation": 3 * [1] + 3 * [2] + 3 * [1] + 3 * [2],
"batch": [0] * 6 + [2] * 6,
"date": 4
* [
Expand All @@ -19,7 +18,7 @@
"key2": range(10, 130, 10),
}

_EMPTY_SUMMARY = {"realization": [], "simulation": [], "date": [], "batch": []}
_EMPTY_SUMMARY = {"realization": [], "date": [], "batch": []}


def test_summary_delta_plot_callback(app, dash_duo, mocker, caplog):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ def test_objective_plot_callback(app, dash_duo, mocker, caplog):
"realization": 1,
"function": "f0",
"value": 100,
"simulation": 1,
"weight": 0.75,
"norm": 1.5,
},
Expand All @@ -19,7 +18,6 @@ def test_objective_plot_callback(app, dash_duo, mocker, caplog):
"realization": 1,
"function": "f1",
"value": 200,
"simulation": 1,
"weight": 0.25,
"norm": 1,
},
Expand All @@ -28,7 +26,6 @@ def test_objective_plot_callback(app, dash_duo, mocker, caplog):
"realization": 1,
"function": "f0",
"value": 300,
"simulation": 1,
"weight": 0.75,
"norm": 1.5,
},
Expand All @@ -37,7 +34,6 @@ def test_objective_plot_callback(app, dash_duo, mocker, caplog):
"realization": 1,
"function": "f1",
"value": 400,
"simulation": 1,
"weight": 0.25,
"norm": 1,
},
Expand All @@ -46,7 +42,6 @@ def test_objective_plot_callback(app, dash_duo, mocker, caplog):
"realization": 2,
"function": "f0",
"value": 500,
"simulation": 2,
"weight": 0.75,
"norm": 1.5,
},
Expand All @@ -55,7 +50,6 @@ def test_objective_plot_callback(app, dash_duo, mocker, caplog):
"realization": 2,
"function": "f1",
"value": 600,
"simulation": 2,
"weight": 0.25,
"norm": 1,
},
Expand All @@ -64,7 +58,6 @@ def test_objective_plot_callback(app, dash_duo, mocker, caplog):
"realization": 2,
"function": "f0",
"value": 700,
"simulation": 2,
"weight": 0.75,
"norm": 1.5,
},
Expand All @@ -73,7 +66,6 @@ def test_objective_plot_callback(app, dash_duo, mocker, caplog):
"realization": 2,
"function": "f1",
"value": 800,
"simulation": 2,
"weight": 0.25,
"norm": 1,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
def test_summary_plot_callback(app, dash_duo, mocker, caplog):
test_data = {
"realization": range(12),
"simulation": range(12),
"batch": [0] * 6 + [1] * 6,
"date": [
datetime(2000, 1, 1),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
def test_well_plot(app, dash_duo, mocker, caplog):
test_data = {
"realization": range(12),
"simulation": range(12),
"batch": [0] * 6 + [1] * 6,
"date": [
datetime(2000, 1, 1),
Expand Down
19 changes: 9 additions & 10 deletions tests/unit/test_delta_plot_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,18 @@
)

_OBJECTIVES = [
{"batch": 0, "realization": 1, "function": "f0", "value": 100, "simulation": 1},
{"batch": 0, "realization": 2, "function": "f0", "value": 200, "simulation": 2},
{"batch": 0, "realization": 1, "function": "f1", "value": 300, "simulation": 1},
{"batch": 0, "realization": 2, "function": "f1", "value": 400, "simulation": 2},
{"batch": 2, "realization": 1, "function": "f0", "value": 500, "simulation": 1},
{"batch": 2, "realization": 2, "function": "f0", "value": 600, "simulation": 2},
{"batch": 2, "realization": 1, "function": "f1", "value": 800, "simulation": 1},
{"batch": 2, "realization": 2, "function": "f1", "value": 900, "simulation": 2},
{"batch": 0, "realization": 1, "function": "f0", "value": 100 },
{"batch": 0, "realization": 2, "function": "f0", "value": 200 },
{"batch": 0, "realization": 1, "function": "f1", "value": 300 },
{"batch": 0, "realization": 2, "function": "f1", "value": 400 },
{"batch": 2, "realization": 1, "function": "f0", "value": 500 },
{"batch": 2, "realization": 2, "function": "f0", "value": 600 },
{"batch": 2, "realization": 1, "function": "f1", "value": 800 },
{"batch": 2, "realization": 2, "function": "f1", "value": 900 },
]

_SUMMARY = {
"realization": 3 * [1] + 3 * [2] + 3 * [1] + 3 * [2],
"simulation": 3 * [1] + 3 * [2] + 3 * [1] + 3 * [2],
"batch": [0] * 6 + [2] * 6,
"date": 4
* [
Expand Down Expand Up @@ -93,7 +92,7 @@ def test_delta_plot_layout_with_empty_summary(mocker, tmpdir):
mock_api.objective_values = _OBJECTIVES
mock_api.single_objective_values = _SINGLE_OBJECTIVES
mock_api.summary_values.return_value = pandas.DataFrame(
{"realization": [], "simulation": [], "date": [], "batch": []}
{"realization": [], "date": [], "batch": []}
)
mock_api.output_folder = tmpdir

Expand Down
12 changes: 2 additions & 10 deletions tests/unit/test_objective_plot_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
"realization": 1,
"function": "f0",
"value": 100,
"simulation": 1,
"weight": 0.75,
"norm": 1,
},
Expand All @@ -28,7 +27,6 @@
"realization": 1,
"function": "f1",
"value": 200,
"simulation": 1,
"weight": 0.25,
"norm": 1.5,
},
Expand All @@ -37,7 +35,6 @@
"realization": 2,
"function": "f0",
"value": 200,
"simulation": 2,
"weight": 0.75,
"norm": 1,
},
Expand All @@ -46,7 +43,6 @@
"realization": 2,
"function": "f1",
"value": 400,
"simulation": 2,
"weight": 0.25,
"norm": 1.5,
},
Expand All @@ -55,7 +51,6 @@
"realization": 1,
"function": "f0",
"value": 300,
"simulation": 1,
"weight": 0.75,
"norm": 1,
},
Expand All @@ -64,7 +59,6 @@
"realization": 1,
"function": "f1",
"value": 600,
"simulation": 1,
"weight": 0.25,
"norm": 1.5,
},
Expand All @@ -73,7 +67,6 @@
"realization": 2,
"function": "f0",
"value": 400,
"simulation": 2,
"weight": 0.75,
"norm": 1,
},
Expand All @@ -82,7 +75,6 @@
"realization": 2,
"function": "f1",
"value": 800,
"simulation": 2,
"weight": 0.25,
"norm": 1.5,
},
Expand Down Expand Up @@ -183,7 +175,7 @@ def test_set_up_sources(mocker, monkeypatch, tmpdir):
mocker.Mock(return_value=pd.DataFrame(OBJECTIVES)),
)
total_data = pd.DataFrame(OBJECTIVES).drop(
columns=["realization", "function", "simulation"]
columns=["realization", "function"]
)
monkeypatch.setattr(
everviz.pages.objectives,
Expand All @@ -200,7 +192,7 @@ def test_set_up_sources(mocker, monkeypatch, tmpdir):

def test_total_objective_values_data_frame():
total_data = pd.DataFrame(OBJECTIVES).drop(
columns=["realization", "function", "simulation", "weight", "norm"]
columns=["realization", "function", "weight", "norm"]
)
total_objective_values = _total_objective_values(total_data)

Expand Down
2 changes: 0 additions & 2 deletions tests/unit/test_summary_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

__TEST_DATA = {
"realization": range(12),
"simulation": range(12),
"batch": [0] * 6 + [1] * 6,
"date": [
datetime(2000, 1, 1),
Expand Down Expand Up @@ -45,7 +44,6 @@ def test_summary_values_data_frame():
assert list(
summary_values.columns == ["summary_key", "batch", "date", "key1", "key2"]
)
assert len(summary_values) == len(__TEST_DATA["simulation"])
assert set(summary_values["batch"]) == set(__TEST_DATA["batch"])
assert set(summary_values["date"]) == {
pd.Timestamp(date) for date in __TEST_DATA["date"]
Expand Down

0 comments on commit 5002365

Please sign in to comment.