-
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 box-plots to standard deviation plot
- test for stddev plot - Update baseline image for test_that_all_snake_oil_visualisations_matches_snapshot - Remove redudant image files Co-authored by Feda Curic <[email protected]>
- Loading branch information
Showing
11 changed files
with
123 additions
and
20 deletions.
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
Binary file removed
BIN
-73.3 KB
...seline/test_that_all_snake_oil_visualisations_matches_snapshot_plot_figure0.png
Binary file not shown.
Binary file removed
BIN
-99.8 KB
...seline/test_that_all_snake_oil_visualisations_matches_snapshot_plot_figure1.png
Binary file not shown.
Binary file removed
BIN
-20.5 KB
...seline/test_that_all_snake_oil_visualisations_matches_snapshot_plot_figure2.png
Binary file not shown.
Binary file modified
BIN
+36.9 KB
(320%)
...line/test_that_all_snake_oil_visualisations_matches_snapshot_plot_figure3-0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed
BIN
-12.6 KB
...seline/test_that_all_snake_oil_visualisations_matches_snapshot_plot_figure3.png
Binary file not shown.
Binary file removed
BIN
-27 KB
...seline/test_that_all_snake_oil_visualisations_matches_snapshot_plot_figure4.png
Binary file not shown.
Binary file removed
BIN
-32.7 KB
...seline/test_that_all_snake_oil_visualisations_matches_snapshot_plot_figure5.png
Binary file not shown.
Binary file removed
BIN
-26.1 KB
...seline/test_that_all_snake_oil_visualisations_matches_snapshot_plot_figure6.png
Binary file not shown.
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,49 @@ | ||
from unittest.mock import Mock | ||
|
||
import matplotlib.pyplot as plt | ||
import numpy as np | ||
import pytest | ||
from matplotlib.figure import Figure | ||
|
||
from ert.gui.plottery import PlotConfig, PlotContext | ||
from ert.gui.plottery.plots.std_dev import StdDevPlot | ||
from ert.gui.tools.plot.plot_api import EnsembleObject | ||
|
||
|
||
@pytest.fixture() | ||
def plot_context(request): | ||
context = Mock(spec=PlotContext) | ||
context.ensembles.return_value = [ | ||
EnsembleObject("ensemble_1", "id", False, "experiment_1") | ||
] | ||
context.history_data = None | ||
context.layer = 0 | ||
context.plotConfig.return_value = PlotConfig(title="StdDev Plot") | ||
return context | ||
|
||
|
||
def test_stddev_plot_shows_boxplot(plot_context: PlotContext): | ||
rng = np.random.default_rng() | ||
figure = Figure() | ||
std_dev_data = rng.random((5, 5)) | ||
StdDevPlot().plot( | ||
figure, | ||
plot_context, | ||
{}, | ||
{}, | ||
{"ensemble_1": std_dev_data}, | ||
) | ||
ax = figure.axes | ||
assert ax[0].get_title() == "experiment_1 : ensemble_1 layer=0" | ||
assert ax[1].get_ylabel() == "Standard Deviation" | ||
annotation = [ | ||
child for child in ax[1].get_children() if isinstance(child, plt.Annotation) | ||
] | ||
assert len(annotation) == 1 | ||
min_value = np.min(std_dev_data) | ||
mean_value = np.mean(std_dev_data) | ||
max_value = np.max(std_dev_data) | ||
assert ( | ||
annotation[0].get_text() | ||
== f"Min: {min_value:.2f}\nMean: {mean_value:.2f}\nMax: {max_value:.2f}" | ||
) |