Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle new data type returned by everest summary_values data endpoint. #188

Merged
merged 1 commit into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion everviz/pages/deltaplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def _get_objective_delta_values(api, best_batch):


def _get_summary_delta_values(api, best_batch):
summary = api.summary_values()
summary = api.summary_values().to_pandas()
if summary.empty:
return summary
data = (
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 @@ -25,7 +25,7 @@ def _set_up_data_sources(api, keys=None):
everviz_path = os.path.join(everest_folder, "everviz")

# Make a table which statistics over the realizations.
summary_values = api.summary_values(keys=keys)
summary_values = api.summary_values(keys=keys).to_pandas()

if summary_values.empty:
return None
Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ test = [
"dash[testing]",
"pillow",
"pytest-mock",
"sphinx"
"sphinx",
"polars"
]
style = [
"pre-commit",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from datetime import datetime

import pandas
import polars as pl
from everviz.pages.deltaplot import _get_summary_delta_values
from everviz.plugins.delta_plot.delta_plot import DeltaPlot

Expand All @@ -23,7 +23,7 @@

def test_summary_delta_plot_callback(app, dash_duo, mocker, caplog):
mock_api = mocker.Mock()
mock_api.summary_values.return_value = pandas.DataFrame(_SUMMARY)
mock_api.summary_values.return_value = pl.DataFrame(_SUMMARY)

mocker.patch(
"everviz.plugins.delta_plot.delta_plot.get_data",
Expand Down Expand Up @@ -60,7 +60,7 @@ def test_summary_delta_plot_callback(app, dash_duo, mocker, caplog):

def test_summary_delta_plot_empty_callback(app, dash_duo, mocker, caplog):
mock_api = mocker.Mock()
mock_api.summary_values.return_value = pandas.DataFrame(_EMPTY_SUMMARY)
mock_api.summary_values.return_value = pl.DataFrame(_EMPTY_SUMMARY)

mocker.patch(
"everviz.plugins.delta_plot.delta_plot.get_data",
Expand Down
8 changes: 4 additions & 4 deletions tests/unit/test_delta_plot_data.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
from datetime import datetime

import pandas
import polars as pl
from everviz.pages.deltaplot import (
_get_objective_delta_values,
_get_summary_delta_values,
Expand Down Expand Up @@ -59,7 +59,7 @@ def test_objective_values_data_frame(mocker):
def test_summary_values_data_frame(mocker):
"""Test for the correct layout and size of the objective values data frame."""
mock_api = mocker.Mock()
mock_api.summary_values.return_value = pandas.DataFrame(_SUMMARY)
mock_api.summary_values.return_value = pl.DataFrame(_SUMMARY)

summary_delta_values = _get_summary_delta_values(mock_api, 2)

Expand All @@ -77,7 +77,7 @@ def test_set_up_sources(mocker, tmpdir):
mock_api = mocker.Mock()
mock_api.objective_values = _OBJECTIVES
mock_api.single_objective_values = _SINGLE_OBJECTIVES
mock_api.summary_values.return_value = pandas.DataFrame(_SUMMARY)
mock_api.summary_values.return_value = pl.DataFrame(_SUMMARY)
mock_api.output_folder = tmpdir

os.mkdir(os.path.join(tmpdir, "everviz"))
Expand All @@ -96,7 +96,7 @@ def test_delta_plot_layout_with_empty_summary(mocker, tmpdir):
mock_api = mocker.Mock()
mock_api.objective_values = _OBJECTIVES
mock_api.single_objective_values = _SINGLE_OBJECTIVES
mock_api.summary_values.return_value = pandas.DataFrame(
mock_api.summary_values.return_value = pl.DataFrame(
{"realization": [], "simulation": [], "date": [], "batch": []}
)
mock_api.output_folder = tmpdir
Expand Down
3 changes: 2 additions & 1 deletion tests/unit/test_summary_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import numpy as np
import pandas as pd
import polars as pl
from everviz.pages.summary_values import _summary_values, page_layout
from everviz.plugins.summary_plot.util import calculate_statistics

Expand Down Expand Up @@ -32,7 +33,7 @@ def test_empty_summary_values(mocker):
"""Test for the case of missing summary values."""
mock_api = mocker.Mock()
mock_api.output_folder = "dummy"
mock_api.summary_values.return_value = pd.DataFrame()
mock_api.summary_values.return_value = pl.DataFrame()
layout = page_layout(mock_api)
assert not layout

Expand Down
Loading