-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add EnsemblePlot support for rate plotting drawing
- exploits "steps-pre" drawing style - tests that draw_style is set correctly
- Loading branch information
Showing
2 changed files
with
54 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
from unittest.mock import Mock, patch | ||
|
||
import pandas as pd | ||
import pytest | ||
from matplotlib.figure import Figure | ||
|
||
from ert.gui.plottery import PlotConfig, PlotContext | ||
from ert.gui.plottery.plots.ensemble import EnsemblePlot | ||
from ert.gui.tools.plot.plot_api import EnsembleObject | ||
from ert.shared.storage.summary_key_utils import is_rate | ||
|
||
|
||
@pytest.fixture( | ||
params=[ | ||
pytest.param("WOPR:OP_4"), | ||
pytest.param("BPR:123"), | ||
] | ||
) | ||
def plot_context(request): | ||
context = Mock(spec=PlotContext) | ||
context.ensembles.return_value = [ | ||
EnsembleObject("ensemble_1", "id", False, "experiment_1") | ||
] | ||
context.key.return_value = request.param | ||
context.history_data = None | ||
context.plotConfig.return_value = PlotConfig(title="Ensemble Plot") | ||
return context | ||
|
||
|
||
def test_ensemble_plot_handles_rate(plot_context: PlotContext): | ||
figure = Figure() | ||
with patch( | ||
"ert.gui.plottery.plots.ensemble.EnsemblePlot._plotLines" | ||
) as mock_plotLines: | ||
EnsemblePlot().plot( | ||
figure, | ||
plot_context, | ||
dict.fromkeys( | ||
plot_context.ensembles(), | ||
pd.DataFrame([[0.1], [0.2], [0.3], [0.4], [0.5]]), | ||
), | ||
pd.DataFrame(), | ||
{}, | ||
) | ||
if is_rate(plot_context.key()): | ||
assert mock_plotLines.call_args[0][4] == "steps-pre" | ||
else: | ||
assert mock_plotLines.call_args[0][4] is None |