Skip to content

Commit

Permalink
Hande new data type returned by everest summary_values data endpoint.
Browse files Browse the repository at this point in the history
  • Loading branch information
DanSava committed Dec 3, 2024
1 parent cf451e2 commit 6997786
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion everviz/pages/deltaplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,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 @@ -26,7 +26,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 = [
"ruff",
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.plugins.delta_plot.delta_plot import DeltaPlot
from everviz.pages.deltaplot import _get_summary_delta_values
Expand All @@ -24,7 +24,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 @@ -61,7 +61,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,
Expand Down Expand Up @@ -57,7 +57,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 @@ -73,7 +73,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 @@ -92,7 +92,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 pandas as pd
import numpy as np
import polars as pl

from everviz.pages.summary_values import page_layout, _summary_values
from everviz.plugins.summary_plot.util import calculate_statistics
Expand Down Expand Up @@ -33,7 +34,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

0 comments on commit 6997786

Please sign in to comment.