webviz-subsurface 0.2.39__py3-none-any.whl → 0.2.41__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- webviz_subsurface/_figures/timeseries_figure.py +1 -1
- webviz_subsurface/_providers/ensemble_summary_provider/_provider_impl_arrow_lazy.py +3 -1
- webviz_subsurface/_providers/ensemble_summary_provider/_provider_impl_arrow_presampled.py +3 -1
- webviz_subsurface/_providers/ensemble_table_provider/ensemble_table_provider_impl_arrow.py +3 -1
- webviz_subsurface/_utils/dataframe_utils.py +1 -1
- webviz_subsurface/_version.py +34 -0
- webviz_subsurface/plugins/_bhp_qc/views/_view_functions.py +5 -5
- webviz_subsurface/plugins/_co2_migration/__init__.py +1 -0
- webviz_subsurface/plugins/{_co2_leakage → _co2_migration}/_plugin.py +86 -46
- webviz_subsurface/plugins/{_co2_leakage → _co2_migration}/_utilities/callbacks.py +53 -30
- webviz_subsurface/plugins/{_co2_leakage → _co2_migration}/_utilities/co2volume.py +283 -40
- webviz_subsurface/plugins/{_co2_leakage → _co2_migration}/_utilities/color_tables.py +1 -1
- webviz_subsurface/plugins/{_co2_leakage → _co2_migration}/_utilities/containment_data_provider.py +6 -4
- webviz_subsurface/plugins/{_co2_leakage → _co2_migration}/_utilities/containment_info.py +6 -0
- webviz_subsurface/plugins/{_co2_leakage → _co2_migration}/_utilities/ensemble_well_picks.py +1 -1
- webviz_subsurface/plugins/{_co2_leakage → _co2_migration}/_utilities/generic.py +59 -6
- webviz_subsurface/plugins/{_co2_leakage → _co2_migration}/_utilities/initialization.py +73 -10
- webviz_subsurface/plugins/{_co2_leakage → _co2_migration}/_utilities/polygon_handler.py +1 -1
- webviz_subsurface/plugins/{_co2_leakage → _co2_migration}/_utilities/summary_graphs.py +20 -18
- webviz_subsurface/plugins/{_co2_leakage → _co2_migration}/_utilities/surface_publishing.py +18 -20
- webviz_subsurface/plugins/{_co2_leakage → _co2_migration}/_utilities/unsmry_data_provider.py +8 -8
- webviz_subsurface/plugins/{_co2_leakage → _co2_migration}/views/mainview/mainview.py +98 -44
- webviz_subsurface/plugins/{_co2_leakage → _co2_migration}/views/mainview/settings.py +7 -5
- webviz_subsurface/plugins/_disk_usage.py +19 -8
- webviz_subsurface/plugins/_line_plotter_fmu/controllers/build_figure.py +4 -4
- webviz_subsurface/plugins/_map_viewer_fmu/layout.py +2 -1
- webviz_subsurface/plugins/_map_viewer_fmu/map_viewer_fmu.py +1 -1
- webviz_subsurface/plugins/_parameter_analysis/_utils/_parameters_model.py +5 -5
- webviz_subsurface/plugins/_property_statistics/property_statistics.py +1 -1
- webviz_subsurface/plugins/_relative_permeability.py +6 -6
- webviz_subsurface/plugins/_reservoir_simulation_timeseries_regional.py +12 -12
- webviz_subsurface/plugins/_running_time_analysis_fmu.py +6 -1
- webviz_subsurface/plugins/_seismic_misfit.py +2 -3
- webviz_subsurface/plugins/_simulation_time_series/_views/_subplot_view/_utils/vector_statistics.py +4 -4
- webviz_subsurface/plugins/_structural_uncertainty/views/intersection_and_map.py +1 -1
- webviz_subsurface/plugins/_swatinit_qc/_business_logic.py +1 -1
- webviz_subsurface-0.2.41.dist-info/METADATA +822 -0
- {webviz_subsurface-0.2.39.dist-info → webviz_subsurface-0.2.41.dist-info}/RECORD +51 -102
- {webviz_subsurface-0.2.39.dist-info → webviz_subsurface-0.2.41.dist-info}/WHEEL +1 -1
- {webviz_subsurface-0.2.39.dist-info → webviz_subsurface-0.2.41.dist-info}/entry_points.txt +1 -1
- {webviz_subsurface-0.2.39.dist-info → webviz_subsurface-0.2.41.dist-info}/top_level.txt +0 -1
- tests/integration_tests/test_parameter_filter.py +0 -28
- tests/integration_tests/test_surface_selector.py +0 -53
- tests/unit_tests/abbreviations_tests/test_reservoir_simulation.py +0 -94
- tests/unit_tests/data_input/__init__.py +0 -0
- tests/unit_tests/data_input/test_calc_from_cumulatives.py +0 -178
- tests/unit_tests/data_input/test_image_processing.py +0 -11
- tests/unit_tests/mocks/__init__.py +0 -0
- tests/unit_tests/mocks/ensemble_summary_provider_dummy.py +0 -67
- tests/unit_tests/model_tests/__init__.py +0 -0
- tests/unit_tests/model_tests/test_ensemble_model.py +0 -176
- tests/unit_tests/model_tests/test_ensemble_set_model.py +0 -105
- tests/unit_tests/model_tests/test_gruptree_model.py +0 -89
- tests/unit_tests/model_tests/test_property_statistics_model.py +0 -42
- tests/unit_tests/model_tests/test_surface_set_model.py +0 -48
- tests/unit_tests/model_tests/test_well_attributes_model.py +0 -110
- tests/unit_tests/model_tests/test_well_set_model.py +0 -70
- tests/unit_tests/plugin_tests/__init__.py +0 -0
- tests/unit_tests/plugin_tests/test_grouptree.py +0 -175
- tests/unit_tests/plugin_tests/test_simulation_time_series/__init__.py +0 -0
- tests/unit_tests/plugin_tests/test_simulation_time_series/mocks/__init__.py +0 -0
- tests/unit_tests/plugin_tests/test_simulation_time_series/mocks/derived_vectors_accessor_ensemble_summary_provider_mock.py +0 -60
- tests/unit_tests/plugin_tests/test_simulation_time_series/test_utils/__init__.py +0 -0
- tests/unit_tests/plugin_tests/test_simulation_time_series/test_utils/test_create_vector_traces_utils.py +0 -530
- tests/unit_tests/plugin_tests/test_simulation_time_series/test_utils/test_dataframe_utils.py +0 -119
- tests/unit_tests/plugin_tests/test_simulation_time_series/test_utils/test_datetime_utils.py +0 -51
- tests/unit_tests/plugin_tests/test_simulation_time_series/test_utils/test_delta_ensemble_utils.py +0 -222
- tests/unit_tests/plugin_tests/test_simulation_time_series/test_utils/test_derived_delta_ensemble_vectors_accessor_impl.py +0 -319
- tests/unit_tests/plugin_tests/test_simulation_time_series/test_utils/test_derived_ensemble_vectors_accessor_impl.py +0 -271
- tests/unit_tests/plugin_tests/test_simulation_time_series/test_utils/test_derived_ensemble_vectors_accessor_utils.py +0 -78
- tests/unit_tests/plugin_tests/test_simulation_time_series/test_utils/test_derived_vector_accessor.py +0 -57
- tests/unit_tests/plugin_tests/test_simulation_time_series/test_utils/test_ensemble_summary_provider_set_utils.py +0 -213
- tests/unit_tests/plugin_tests/test_simulation_time_series/test_utils/test_from_timeseries_cumulatives.py +0 -322
- tests/unit_tests/plugin_tests/test_simulation_time_series/test_utils/test_history_vectors.py +0 -201
- tests/unit_tests/plugin_tests/test_simulation_time_series/test_utils/test_trace_line_shape.py +0 -56
- tests/unit_tests/plugin_tests/test_simulation_time_series/test_utils/test_vector_statistics.py +0 -171
- tests/unit_tests/plugin_tests/test_tornado_data.py +0 -130
- tests/unit_tests/plugin_tests/test_well_completions.py +0 -158
- tests/unit_tests/provider_tests/__init__.py +0 -0
- tests/unit_tests/provider_tests/test_ensemble_summary_provider.py +0 -255
- tests/unit_tests/provider_tests/test_ensemble_summary_provider_impl_arrow_lazy.py +0 -388
- tests/unit_tests/provider_tests/test_ensemble_summary_provider_impl_arrow_presampled.py +0 -160
- tests/unit_tests/provider_tests/test_ensemble_summary_provider_resampling.py +0 -320
- tests/unit_tests/provider_tests/test_ensemble_table_provider.py +0 -190
- tests/unit_tests/utils_tests/__init__.py +0 -0
- tests/unit_tests/utils_tests/test_dataframe_utils.py +0 -281
- tests/unit_tests/utils_tests/test_ensemble_summary_provider_set/__init__.py +0 -0
- tests/unit_tests/utils_tests/test_ensemble_summary_provider_set/test_ensemble_summary_provider_set.py +0 -306
- tests/unit_tests/utils_tests/test_formatting.py +0 -10
- tests/unit_tests/utils_tests/test_simulation_timeseries.py +0 -51
- webviz_subsurface/plugins/_co2_leakage/__init__.py +0 -1
- webviz_subsurface/plugins/_co2_leakage/_utilities/__init__.py +0 -0
- webviz_subsurface/plugins/_co2_leakage/views/__init__.py +0 -0
- webviz_subsurface/plugins/_co2_leakage/views/mainview/__init__.py +0 -0
- webviz_subsurface-0.2.39.dist-info/METADATA +0 -147
- /webviz_subsurface/plugins/{_co2_leakage → _co2_migration}/_error.py +0 -0
- /webviz_subsurface/plugins/{_co2_leakage → _co2_migration}/_types.py +0 -0
- {tests/integration_tests → webviz_subsurface/plugins/_co2_migration/_utilities}/__init__.py +0 -0
- /webviz_subsurface/plugins/{_co2_leakage → _co2_migration}/_utilities/_misc.py +0 -0
- /webviz_subsurface/plugins/{_co2_leakage → _co2_migration}/_utilities/fault_polygons_handler.py +0 -0
- /webviz_subsurface/plugins/{_co2_leakage → _co2_migration}/_utilities/plume_extent.py +0 -0
- {tests/unit_tests → webviz_subsurface/plugins/_co2_migration/views}/__init__.py +0 -0
- {tests/unit_tests/abbreviations_tests → webviz_subsurface/plugins/_co2_migration/views/mainview}/__init__.py +0 -0
- {webviz_subsurface-0.2.39.dist-info → webviz_subsurface-0.2.41.dist-info/licenses}/LICENSE +0 -0
- {webviz_subsurface-0.2.39.dist-info → webviz_subsurface-0.2.41.dist-info/licenses}/LICENSE.chromedriver +0 -0
|
@@ -1,281 +0,0 @@
|
|
|
1
|
-
import datetime
|
|
2
|
-
|
|
3
|
-
import pandas as pd
|
|
4
|
-
import pytest
|
|
5
|
-
from pandas._testing import assert_frame_equal
|
|
6
|
-
|
|
7
|
-
from webviz_subsurface._utils.dataframe_utils import (
|
|
8
|
-
assert_date_column_is_datetime_object,
|
|
9
|
-
make_date_column_datetime_object,
|
|
10
|
-
)
|
|
11
|
-
|
|
12
|
-
# *******************************************************
|
|
13
|
-
#########################################################
|
|
14
|
-
#
|
|
15
|
-
# SETUP OF INPUT DATAFRAMES FOR TESTS
|
|
16
|
-
#
|
|
17
|
-
#########################################################
|
|
18
|
-
# *******************************************************
|
|
19
|
-
|
|
20
|
-
# fmt: off
|
|
21
|
-
INPUT_EMPTY_DF = pd.DataFrame()
|
|
22
|
-
INPUT_NO_ROWS_DF = pd.DataFrame(columns=["DATE", "A"])
|
|
23
|
-
INPUT_TIMESTAMP_DATETIME_DF = pd.DataFrame(
|
|
24
|
-
columns=["DATE", "A"],
|
|
25
|
-
data=[
|
|
26
|
-
[pd.Timestamp(2000, 1, 1), 1.0], # pd.Timestamp detected in df["DATE"][0]
|
|
27
|
-
[datetime.datetime(2263, 2, 15), 1.0],
|
|
28
|
-
],
|
|
29
|
-
)
|
|
30
|
-
INPUT_DATETIME_YEAR_2020_DF = pd.DataFrame(
|
|
31
|
-
columns=["DATE", "A"],
|
|
32
|
-
data=[
|
|
33
|
-
[datetime.datetime(2020, 1, 15), 1.0],
|
|
34
|
-
[datetime.datetime(2020, 2, 15), 2.0],
|
|
35
|
-
[datetime.datetime(2020, 3, 15), 3.0],
|
|
36
|
-
],
|
|
37
|
-
)
|
|
38
|
-
INPUT_DATETIME_YEAR_2020_DF["DATE"] = pd.Series(
|
|
39
|
-
INPUT_DATETIME_YEAR_2020_DF["DATE"].dt.to_pydatetime(), dtype=object
|
|
40
|
-
) # Converting "DATE"-column to datetime.datetime after construct
|
|
41
|
-
|
|
42
|
-
INPUT_DATETIME_YEAR_2263_DF = pd.DataFrame(
|
|
43
|
-
columns=["DATE", "A"],
|
|
44
|
-
data=[
|
|
45
|
-
[datetime.datetime(2263, 1, 15), 1.0],
|
|
46
|
-
[datetime.datetime(2263, 2, 15), 2.0],
|
|
47
|
-
[datetime.datetime(2263, 3, 15), 3.0],
|
|
48
|
-
],
|
|
49
|
-
)
|
|
50
|
-
INPUT_TIMESTAMP_YEAR_2020_DF = pd.DataFrame(
|
|
51
|
-
columns=["DATE", "A"],
|
|
52
|
-
data=[
|
|
53
|
-
[pd.Timestamp(2020, 1, 15), 1.0],
|
|
54
|
-
[pd.Timestamp(2020, 2, 15), 2.0],
|
|
55
|
-
[pd.Timestamp(2020, 3, 15), 3.0],
|
|
56
|
-
],
|
|
57
|
-
)
|
|
58
|
-
|
|
59
|
-
EXPECTED_YEAR_2020_DF = pd.DataFrame(
|
|
60
|
-
columns=["DATE", "A"],
|
|
61
|
-
data=[
|
|
62
|
-
[datetime.datetime(2020, 1, 15), 1.0],
|
|
63
|
-
[datetime.datetime(2020, 2, 15), 2.0],
|
|
64
|
-
[datetime.datetime(2020, 3, 15), 3.0],
|
|
65
|
-
],
|
|
66
|
-
)
|
|
67
|
-
# Convert "DATE" column to datetime.datetime format as DataFrame constructor
|
|
68
|
-
# converts datetime.datetime to pd.Timestamp
|
|
69
|
-
EXPECTED_YEAR_2020_DF["DATE"] = pd.Series(
|
|
70
|
-
EXPECTED_YEAR_2020_DF["DATE"].dt.to_pydatetime(), dtype=object
|
|
71
|
-
)
|
|
72
|
-
|
|
73
|
-
# Constructor not converting datetime.datetime for year > 2262 to pd.Timestamp
|
|
74
|
-
EXPECTED_YEAR_2263_DF = pd.DataFrame(
|
|
75
|
-
columns=["DATE", "A"],
|
|
76
|
-
data=[
|
|
77
|
-
[datetime.datetime(2263, 1, 15), 1.0],
|
|
78
|
-
[datetime.datetime(2263, 2, 15), 2.0],
|
|
79
|
-
[datetime.datetime(2263, 3, 15), 3.0],
|
|
80
|
-
],
|
|
81
|
-
)
|
|
82
|
-
# fmt: on
|
|
83
|
-
|
|
84
|
-
# *******************************************************
|
|
85
|
-
#########################################################
|
|
86
|
-
#
|
|
87
|
-
# TESTING OF: assert_date_column_is_datetime_object()
|
|
88
|
-
#
|
|
89
|
-
#########################################################
|
|
90
|
-
# *******************************************************
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
def test_assert_date_column_is_datetime_object_no_date_column_error() -> None:
|
|
94
|
-
with pytest.raises(ValueError) as err:
|
|
95
|
-
assert_date_column_is_datetime_object(INPUT_EMPTY_DF)
|
|
96
|
-
assert str(err.value) == 'df does not contain column "DATE"'
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
def test_assert_date_column_is_datetime_object_timestamp_input_error() -> None:
|
|
100
|
-
# fmt: off
|
|
101
|
-
input_timestamp_df = pd.DataFrame(
|
|
102
|
-
columns=["DATE", "A"],
|
|
103
|
-
data=[
|
|
104
|
-
[pd.Timestamp(2000, 1, 15), 1.0],
|
|
105
|
-
[pd.Timestamp(2000, 2, 15), 1.0]],
|
|
106
|
-
)
|
|
107
|
-
# fmt: on
|
|
108
|
-
with pytest.raises(ValueError) as err:
|
|
109
|
-
assert_date_column_is_datetime_object(input_timestamp_df)
|
|
110
|
-
assert (
|
|
111
|
-
str(err.value)
|
|
112
|
-
== '"DATE"-column in dataframe is not on datetime.datetime format!'
|
|
113
|
-
)
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
def test_assert_date_column_is_datetime_object_timestamp_datetime_input_error() -> None:
|
|
117
|
-
with pytest.raises(ValueError) as err:
|
|
118
|
-
assert_date_column_is_datetime_object(INPUT_TIMESTAMP_DATETIME_DF)
|
|
119
|
-
assert (
|
|
120
|
-
str(err.value)
|
|
121
|
-
== '"DATE"-column in dataframe is not on datetime.datetime format!'
|
|
122
|
-
)
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
def test_assert_date_column_is_datetime_object_no_rows_df() -> None:
|
|
126
|
-
try:
|
|
127
|
-
assert_date_column_is_datetime_object(INPUT_NO_ROWS_DF)
|
|
128
|
-
|
|
129
|
-
# pylint: disable = bare-except
|
|
130
|
-
except:
|
|
131
|
-
pytest.fail("Excpected no raise of ERROR!")
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
def test_assert_date_column_is_datetime_object_datetime_year_2020() -> None:
|
|
135
|
-
try:
|
|
136
|
-
assert_date_column_is_datetime_object(INPUT_DATETIME_YEAR_2020_DF)
|
|
137
|
-
|
|
138
|
-
# pylint: disable = bare-except
|
|
139
|
-
except:
|
|
140
|
-
pytest.fail("Excpected no raise of ERROR!")
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
def test_assert_date_column_is_datetime_object_datetime_year_2263() -> None:
|
|
144
|
-
try:
|
|
145
|
-
assert_date_column_is_datetime_object(INPUT_DATETIME_YEAR_2263_DF)
|
|
146
|
-
|
|
147
|
-
# pylint: disable = bare-except
|
|
148
|
-
except:
|
|
149
|
-
pytest.fail("Excpected no raise of ERROR!")
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
def test_assert_date_column_is_datetime_object_datetime_timestamp_df() -> None:
|
|
153
|
-
# fmt: off
|
|
154
|
-
input_datetime_timestamp_df = pd.DataFrame(
|
|
155
|
-
data=[
|
|
156
|
-
[datetime.datetime(2263, 2, 1), 1.0],
|
|
157
|
-
[pd.Timestamp(2000, 1, 1), 1.0], # pd.Timestamp NOT detected in df["DATE"][1]
|
|
158
|
-
],
|
|
159
|
-
columns=["DATE", "A"],
|
|
160
|
-
)
|
|
161
|
-
# fmt: on
|
|
162
|
-
try:
|
|
163
|
-
assert_date_column_is_datetime_object(input_datetime_timestamp_df)
|
|
164
|
-
|
|
165
|
-
# pylint: disable = bare-except
|
|
166
|
-
except:
|
|
167
|
-
pytest.fail("Excpected no raise of ERROR!")
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
def test_assert_date_column_is_datetime_object_datetime_inconsistent_index_df() -> None:
|
|
171
|
-
"""To verify iloc usage"""
|
|
172
|
-
# fmt: off
|
|
173
|
-
input_datetime_year_2263_inconsistent_index_df = pd.DataFrame(
|
|
174
|
-
columns=["DATE", "A"],
|
|
175
|
-
data=[
|
|
176
|
-
[datetime.datetime(2263, 1, 15), 1.0],
|
|
177
|
-
[datetime.datetime(2263, 2, 15), 2.0],
|
|
178
|
-
[datetime.datetime(2263, 3, 15), 3.0],
|
|
179
|
-
],
|
|
180
|
-
index = [2,5,9]
|
|
181
|
-
)
|
|
182
|
-
# fmt: on
|
|
183
|
-
try:
|
|
184
|
-
assert_date_column_is_datetime_object(
|
|
185
|
-
input_datetime_year_2263_inconsistent_index_df
|
|
186
|
-
)
|
|
187
|
-
|
|
188
|
-
# pylint: disable = bare-except
|
|
189
|
-
except:
|
|
190
|
-
pytest.fail("Excpected no raise of ERROR!")
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
# *******************************************************
|
|
194
|
-
########################################################
|
|
195
|
-
#
|
|
196
|
-
# TESTING OF: make_date_column_datetime_object()
|
|
197
|
-
#
|
|
198
|
-
########################################################
|
|
199
|
-
# *******************************************************
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
def _verify_expected_df_date_column_data(df: pd.DataFrame) -> None:
|
|
203
|
-
"""Verify dataframe contains column named "DATE" and that
|
|
204
|
-
each row in column is of type datetime.datetime.
|
|
205
|
-
|
|
206
|
-
NOTE: Can be 0 rows
|
|
207
|
-
"""
|
|
208
|
-
assert "DATE" in df.columns
|
|
209
|
-
for row in df["DATE"]:
|
|
210
|
-
# pylint: disable = unidiomatic-typecheck
|
|
211
|
-
assert type(row) == datetime.datetime
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
def test_make_date_column_datetime_object_datetime_year_2020_df() -> None:
|
|
215
|
-
_verify_expected_df_date_column_data(EXPECTED_YEAR_2020_DF)
|
|
216
|
-
|
|
217
|
-
# Copy to prevent modification if input_df
|
|
218
|
-
test_df = INPUT_DATETIME_YEAR_2020_DF.copy()
|
|
219
|
-
|
|
220
|
-
make_date_column_datetime_object(test_df)
|
|
221
|
-
|
|
222
|
-
assert_frame_equal(test_df, EXPECTED_YEAR_2020_DF)
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
def test_make_date_column_datetime_object_timestamp_year_2020_df() -> None:
|
|
226
|
-
_verify_expected_df_date_column_data(EXPECTED_YEAR_2020_DF)
|
|
227
|
-
|
|
228
|
-
# Copy to prevent modification if input_df
|
|
229
|
-
test_df = INPUT_TIMESTAMP_YEAR_2020_DF.copy()
|
|
230
|
-
|
|
231
|
-
make_date_column_datetime_object(test_df)
|
|
232
|
-
|
|
233
|
-
assert_frame_equal(test_df, EXPECTED_YEAR_2020_DF)
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
def test_make_date_column_datetime_object_datetime_year_2263_df() -> None:
|
|
237
|
-
_verify_expected_df_date_column_data(EXPECTED_YEAR_2263_DF)
|
|
238
|
-
|
|
239
|
-
# Copy to prevent modification if input_df
|
|
240
|
-
test_df = INPUT_DATETIME_YEAR_2263_DF.copy()
|
|
241
|
-
|
|
242
|
-
make_date_column_datetime_object(test_df)
|
|
243
|
-
|
|
244
|
-
assert_frame_equal(test_df, EXPECTED_YEAR_2263_DF)
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
def test_make_date_column_datetime_object_no_rows_df() -> None:
|
|
248
|
-
# Copy to prevent modification if input_df
|
|
249
|
-
test_df = INPUT_NO_ROWS_DF.copy()
|
|
250
|
-
|
|
251
|
-
make_date_column_datetime_object(test_df)
|
|
252
|
-
|
|
253
|
-
assert_frame_equal(test_df, INPUT_NO_ROWS_DF)
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
def test_make_date_column_datetime_object_input_empty_df() -> None:
|
|
257
|
-
with pytest.raises(ValueError) as err:
|
|
258
|
-
make_date_column_datetime_object(INPUT_EMPTY_DF)
|
|
259
|
-
assert str(err.value) == 'df does not contain column "DATE"'
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
def test_make_date_column_datetime_object_input_timestamp_datetime_df() -> None:
|
|
263
|
-
with pytest.raises(AttributeError) as err:
|
|
264
|
-
make_date_column_datetime_object(INPUT_TIMESTAMP_DATETIME_DF)
|
|
265
|
-
assert str(err.value) == "Can only use .dt accessor with datetimelike values"
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
def test_make_date_column_datetime_object_input_date_year_2020_df() -> None:
|
|
269
|
-
# fmt: off
|
|
270
|
-
input_date_year_2020_df = pd.DataFrame(
|
|
271
|
-
columns=["DATE", "A"],
|
|
272
|
-
data=[
|
|
273
|
-
[datetime.date(2020, 1, 15), 1.0],
|
|
274
|
-
[datetime.date(2020, 2, 15), 2.0],
|
|
275
|
-
[datetime.date(2020, 3, 15), 3.0],
|
|
276
|
-
],
|
|
277
|
-
)
|
|
278
|
-
# fmt: on
|
|
279
|
-
with pytest.raises(ValueError) as err:
|
|
280
|
-
make_date_column_datetime_object(input_date_year_2020_df)
|
|
281
|
-
assert str(err.value) == f'Column "DATE" of type {datetime.date} is not handled!'
|
|
File without changes
|
|
@@ -1,306 +0,0 @@
|
|
|
1
|
-
from typing import Dict
|
|
2
|
-
|
|
3
|
-
import pytest
|
|
4
|
-
|
|
5
|
-
from webviz_subsurface._providers.ensemble_summary_provider.ensemble_summary_provider import (
|
|
6
|
-
EnsembleSummaryProvider,
|
|
7
|
-
VectorMetadata,
|
|
8
|
-
)
|
|
9
|
-
from webviz_subsurface._utils.ensemble_summary_provider_set import (
|
|
10
|
-
EnsembleSummaryProviderSet,
|
|
11
|
-
)
|
|
12
|
-
|
|
13
|
-
from .mocks.ensemble_summary_provider_mock import EnsembleSummaryProviderMock
|
|
14
|
-
|
|
15
|
-
TEST_PROVIDER_DICT: Dict[str, EnsembleSummaryProvider] = {
|
|
16
|
-
"First provider": EnsembleSummaryProviderMock.create_mock_with_first_dataset(),
|
|
17
|
-
"Second provider": EnsembleSummaryProviderMock.create_mock_with_second_dataset(),
|
|
18
|
-
"Third provider": EnsembleSummaryProviderMock.create_mock_with_third_dataset(),
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
TEST_INCONSISTENT_PROVIDER_DICT: Dict[str, EnsembleSummaryProvider] = {
|
|
22
|
-
"First provider": EnsembleSummaryProviderMock.create_mock_with_first_dataset(),
|
|
23
|
-
"Third provider": EnsembleSummaryProviderMock.create_mock_with_third_dataset(),
|
|
24
|
-
"Inconsistent provider": EnsembleSummaryProviderMock.create_mock_with_inconsistent_dataset(),
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
def test_verify_consistent_vector_metadata() -> None:
|
|
29
|
-
consistent_provider_set = EnsembleSummaryProviderSet(TEST_PROVIDER_DICT)
|
|
30
|
-
inconsistent_provider_set = EnsembleSummaryProviderSet(
|
|
31
|
-
TEST_INCONSISTENT_PROVIDER_DICT
|
|
32
|
-
)
|
|
33
|
-
|
|
34
|
-
# Expect no ValueError when verifying
|
|
35
|
-
try:
|
|
36
|
-
consistent_provider_set.verify_consistent_vector_metadata()
|
|
37
|
-
except ValueError as err:
|
|
38
|
-
pytest.fail(
|
|
39
|
-
f"Expected successful validation for consistent_metadata_set. Exception: {err}"
|
|
40
|
-
)
|
|
41
|
-
|
|
42
|
-
# Expect ValueError when verifying
|
|
43
|
-
with pytest.raises(ValueError):
|
|
44
|
-
inconsistent_provider_set.verify_consistent_vector_metadata()
|
|
45
|
-
pytest.fail(
|
|
46
|
-
"Expected unsuccessful verification of consistent vector metadata for "
|
|
47
|
-
"inconsistent_metadata_set"
|
|
48
|
-
)
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
def test_create_union_of_vector_names_from_providers() -> None:
|
|
52
|
-
# NOTE: Use explicit type annotation for EnsembleSummaryProviderMock as Dict is invariant.
|
|
53
|
-
# See: https://mypy.readthedocs.io/en/latest/common_issues.html#variance
|
|
54
|
-
provider_dict: Dict[str, EnsembleSummaryProvider] = {
|
|
55
|
-
"First provider": EnsembleSummaryProviderMock.create_mock_with_first_dataset(),
|
|
56
|
-
"Second provider": EnsembleSummaryProviderMock.create_mock_with_second_dataset(),
|
|
57
|
-
}
|
|
58
|
-
provider_set = EnsembleSummaryProviderSet(provider_dict)
|
|
59
|
-
|
|
60
|
-
# Vector names from first and second mock - without duplicates sorted alphabetically
|
|
61
|
-
expected_vector_names = [
|
|
62
|
-
"FGIR",
|
|
63
|
-
"WBHP:A1",
|
|
64
|
-
"WBHP:A2",
|
|
65
|
-
"WGOR:A1",
|
|
66
|
-
"WGOR:A2",
|
|
67
|
-
"WOPR:A2",
|
|
68
|
-
"WOPT:A1",
|
|
69
|
-
"WOPT:A2",
|
|
70
|
-
"WWCT:A1",
|
|
71
|
-
"WWCT:A2",
|
|
72
|
-
]
|
|
73
|
-
|
|
74
|
-
# pylint: disable = protected-access
|
|
75
|
-
created_vector_names = provider_set._create_union_of_vector_names_from_providers(
|
|
76
|
-
list(provider_dict.values())
|
|
77
|
-
)
|
|
78
|
-
|
|
79
|
-
assert created_vector_names == expected_vector_names
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
def test_create_union_of_realizations_from_providers() -> None:
|
|
83
|
-
# NOTE: Use explicit type annotation for EnsembleSummaryProviderMock as Dict is invariant.
|
|
84
|
-
# See: https://mypy.readthedocs.io/en/latest/common_issues.html#variance
|
|
85
|
-
provider_dict: Dict[str, EnsembleSummaryProvider] = {
|
|
86
|
-
"First provider": EnsembleSummaryProviderMock.create_mock_with_first_dataset(),
|
|
87
|
-
"Second provider": EnsembleSummaryProviderMock.create_mock_with_second_dataset(),
|
|
88
|
-
}
|
|
89
|
-
provider_set = EnsembleSummaryProviderSet(provider_dict)
|
|
90
|
-
|
|
91
|
-
# Realizations from first and second mock
|
|
92
|
-
expected_realizations = [1, 2, 3, 4, 5, 8]
|
|
93
|
-
|
|
94
|
-
# pylint: disable = protected-access
|
|
95
|
-
created_realizations = provider_set._create_union_of_realizations_from_providers(
|
|
96
|
-
list(provider_dict.values())
|
|
97
|
-
)
|
|
98
|
-
|
|
99
|
-
assert created_realizations == expected_realizations
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
def test_items() -> None:
|
|
103
|
-
provider_set = EnsembleSummaryProviderSet(TEST_PROVIDER_DICT)
|
|
104
|
-
assert provider_set.items() == TEST_PROVIDER_DICT.items()
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
def test_names() -> None:
|
|
108
|
-
provider_set = EnsembleSummaryProviderSet(TEST_PROVIDER_DICT)
|
|
109
|
-
assert provider_set.provider_names() == list(TEST_PROVIDER_DICT.keys())
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
def test_provider() -> None:
|
|
113
|
-
provider_set = EnsembleSummaryProviderSet(TEST_PROVIDER_DICT)
|
|
114
|
-
|
|
115
|
-
first_provider = provider_set.provider("First provider")
|
|
116
|
-
second_provider = provider_set.provider("Second provider")
|
|
117
|
-
third_provider = provider_set.provider("Third provider")
|
|
118
|
-
if not isinstance(first_provider, EnsembleSummaryProviderMock):
|
|
119
|
-
pytest.fail(
|
|
120
|
-
f'Expected first provider "{first_provider}" to be type EnsembleSummaryProviderMock'
|
|
121
|
-
)
|
|
122
|
-
if not isinstance(second_provider, EnsembleSummaryProviderMock):
|
|
123
|
-
pytest.fail(
|
|
124
|
-
f'Expected second provider "{second_provider}" to be type EnsembleSummaryProviderMock'
|
|
125
|
-
)
|
|
126
|
-
if not isinstance(third_provider, EnsembleSummaryProviderMock):
|
|
127
|
-
pytest.fail(
|
|
128
|
-
f'Expected third provider "{third_provider}" to be type EnsembleSummaryProviderMock'
|
|
129
|
-
)
|
|
130
|
-
|
|
131
|
-
assert first_provider.get_dataset_name() == "First dataset"
|
|
132
|
-
assert second_provider.get_dataset_name() == "Second dataset"
|
|
133
|
-
assert third_provider.get_dataset_name() == "Third dataset"
|
|
134
|
-
|
|
135
|
-
# Expect ValueError when getting invalid provider name
|
|
136
|
-
with pytest.raises(ValueError):
|
|
137
|
-
name = "Invalid Provider"
|
|
138
|
-
provider_set.provider(name)
|
|
139
|
-
pytest.fail(
|
|
140
|
-
f'Expected getting provider "{name}" to fail, as it is not among provider names in set!'
|
|
141
|
-
)
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
def test_all_providers() -> None:
|
|
145
|
-
provider_set = EnsembleSummaryProviderSet(TEST_PROVIDER_DICT)
|
|
146
|
-
all_providers = provider_set.all_providers()
|
|
147
|
-
|
|
148
|
-
assert len(all_providers) == 3
|
|
149
|
-
first_provider = all_providers[0]
|
|
150
|
-
second_provider = all_providers[1]
|
|
151
|
-
third_provider = all_providers[2]
|
|
152
|
-
if not isinstance(first_provider, EnsembleSummaryProviderMock):
|
|
153
|
-
pytest.fail(
|
|
154
|
-
f'Expected first provider "{first_provider}" to be type EnsembleSummaryProviderMock'
|
|
155
|
-
)
|
|
156
|
-
if not isinstance(second_provider, EnsembleSummaryProviderMock):
|
|
157
|
-
pytest.fail(
|
|
158
|
-
f'Expected second provider "{second_provider}" to be type EnsembleSummaryProviderMock'
|
|
159
|
-
)
|
|
160
|
-
if not isinstance(third_provider, EnsembleSummaryProviderMock):
|
|
161
|
-
pytest.fail(
|
|
162
|
-
f'Expected third provider "{third_provider}" to be type EnsembleSummaryProviderMock'
|
|
163
|
-
)
|
|
164
|
-
|
|
165
|
-
assert first_provider.get_dataset_name() == "First dataset"
|
|
166
|
-
assert second_provider.get_dataset_name() == "Second dataset"
|
|
167
|
-
assert third_provider.get_dataset_name() == "Third dataset"
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
def test_all_realizations() -> None:
|
|
171
|
-
provider_set = EnsembleSummaryProviderSet(TEST_PROVIDER_DICT)
|
|
172
|
-
expected_realizations = [1, 2, 3, 4, 5, 7, 8]
|
|
173
|
-
|
|
174
|
-
assert provider_set.all_realizations() == expected_realizations
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
def test_all_vector_names() -> None:
|
|
178
|
-
provider_set = EnsembleSummaryProviderSet(TEST_PROVIDER_DICT)
|
|
179
|
-
|
|
180
|
-
# Vector names from first, second and third mock - without duplicates sorted alphabetically
|
|
181
|
-
expected_vector_names = [
|
|
182
|
-
"FGIR",
|
|
183
|
-
"FGIT",
|
|
184
|
-
"WBHP:A1",
|
|
185
|
-
"WBHP:A2",
|
|
186
|
-
"WGOR:A1",
|
|
187
|
-
"WGOR:A2",
|
|
188
|
-
"WOPR:A1",
|
|
189
|
-
"WOPR:A2",
|
|
190
|
-
"WOPT:A1",
|
|
191
|
-
"WOPT:A2",
|
|
192
|
-
"WWCT:A1",
|
|
193
|
-
"WWCT:A2",
|
|
194
|
-
]
|
|
195
|
-
|
|
196
|
-
assert provider_set.all_vector_names() == expected_vector_names
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
def test_vector_metadata() -> None:
|
|
200
|
-
provider_set = EnsembleSummaryProviderSet(TEST_PROVIDER_DICT)
|
|
201
|
-
|
|
202
|
-
first_expected_metadata = VectorMetadata(
|
|
203
|
-
unit="SM3/SM3",
|
|
204
|
-
is_total=False,
|
|
205
|
-
is_rate=True,
|
|
206
|
-
is_historical=False,
|
|
207
|
-
keyword="WGOR",
|
|
208
|
-
wgname="A1",
|
|
209
|
-
get_num=6,
|
|
210
|
-
)
|
|
211
|
-
|
|
212
|
-
second_expected_metadata = VectorMetadata(
|
|
213
|
-
unit="",
|
|
214
|
-
is_total=False,
|
|
215
|
-
is_rate=True,
|
|
216
|
-
is_historical=False,
|
|
217
|
-
keyword="WWCT",
|
|
218
|
-
wgname="A1",
|
|
219
|
-
get_num=6,
|
|
220
|
-
)
|
|
221
|
-
|
|
222
|
-
third_expected_metadata = VectorMetadata(
|
|
223
|
-
unit="SM3",
|
|
224
|
-
is_total=True,
|
|
225
|
-
is_rate=False,
|
|
226
|
-
is_historical=False,
|
|
227
|
-
keyword="FGIT",
|
|
228
|
-
wgname=None,
|
|
229
|
-
get_num=0,
|
|
230
|
-
)
|
|
231
|
-
|
|
232
|
-
assert provider_set.vector_metadata("WGOR:A1") == first_expected_metadata
|
|
233
|
-
assert provider_set.vector_metadata("WWCT:A1") == second_expected_metadata
|
|
234
|
-
assert provider_set.vector_metadata("FGIT") == third_expected_metadata
|
|
235
|
-
assert provider_set.vector_metadata("Invalid Vector") is None
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
def test_vector_metadata_order() -> None:
|
|
239
|
-
"""The metadata returns first existing metadata, thereby inconsistent metadata
|
|
240
|
-
will affect result based on the order of the providers in set.
|
|
241
|
-
"""
|
|
242
|
-
|
|
243
|
-
# NOTE: Use explicit type annotation for EnsembleSummaryProviderMock as Dict is invariant.
|
|
244
|
-
# See: https://mypy.readthedocs.io/en/latest/common_issues.html#variance
|
|
245
|
-
first_provider_dict: Dict[str, EnsembleSummaryProvider] = {
|
|
246
|
-
"First": EnsembleSummaryProviderMock.create_mock_with_first_dataset(),
|
|
247
|
-
"Inconsistent": EnsembleSummaryProviderMock.create_mock_with_inconsistent_dataset(),
|
|
248
|
-
}
|
|
249
|
-
second_provider_dict: Dict[str, EnsembleSummaryProvider] = {
|
|
250
|
-
"Inconsistent": EnsembleSummaryProviderMock.create_mock_with_inconsistent_dataset(),
|
|
251
|
-
"First": EnsembleSummaryProviderMock.create_mock_with_first_dataset(),
|
|
252
|
-
}
|
|
253
|
-
first_provider_set = EnsembleSummaryProviderSet(first_provider_dict)
|
|
254
|
-
second_provider_set = EnsembleSummaryProviderSet(second_provider_dict)
|
|
255
|
-
|
|
256
|
-
# Metadata for first ensemble mock implementation
|
|
257
|
-
first_ensemble_wwct_a1 = VectorMetadata(
|
|
258
|
-
unit="",
|
|
259
|
-
is_total=False,
|
|
260
|
-
is_rate=True,
|
|
261
|
-
is_historical=False,
|
|
262
|
-
keyword="WWCT",
|
|
263
|
-
wgname="A1",
|
|
264
|
-
get_num=6,
|
|
265
|
-
)
|
|
266
|
-
first_ensemble_wgor_a2 = VectorMetadata(
|
|
267
|
-
unit="SM3/SM3",
|
|
268
|
-
is_total=False,
|
|
269
|
-
is_rate=True,
|
|
270
|
-
is_historical=False,
|
|
271
|
-
keyword="WGOR",
|
|
272
|
-
wgname="A2",
|
|
273
|
-
get_num=7,
|
|
274
|
-
)
|
|
275
|
-
|
|
276
|
-
# Metadata for inconsistent ensemble mock implementation
|
|
277
|
-
inconsistent_ensemble_wwct_a1 = VectorMetadata(
|
|
278
|
-
unit="Invalid Unit",
|
|
279
|
-
is_total=False,
|
|
280
|
-
is_rate=False,
|
|
281
|
-
is_historical=False,
|
|
282
|
-
keyword="WWCT",
|
|
283
|
-
wgname="A1",
|
|
284
|
-
get_num=6,
|
|
285
|
-
)
|
|
286
|
-
inconsistent_ensemble_wgor_a2 = VectorMetadata(
|
|
287
|
-
unit="SM3",
|
|
288
|
-
is_total=False,
|
|
289
|
-
is_rate=False,
|
|
290
|
-
is_historical=True,
|
|
291
|
-
keyword="WGOR",
|
|
292
|
-
wgname="A2",
|
|
293
|
-
get_num=7,
|
|
294
|
-
)
|
|
295
|
-
|
|
296
|
-
# First provider set should return metadata for the first ensemble mock implementation
|
|
297
|
-
assert first_provider_set.vector_metadata("WWCT:A1") == first_ensemble_wwct_a1
|
|
298
|
-
assert first_provider_set.vector_metadata("WGOR:A2") == first_ensemble_wgor_a2
|
|
299
|
-
|
|
300
|
-
# Second provider set should return metadata for the inconsistent ensemble mock implementation
|
|
301
|
-
assert (
|
|
302
|
-
second_provider_set.vector_metadata("WWCT:A1") == inconsistent_ensemble_wwct_a1
|
|
303
|
-
)
|
|
304
|
-
assert (
|
|
305
|
-
second_provider_set.vector_metadata("WGOR:A2") == inconsistent_ensemble_wgor_a2
|
|
306
|
-
)
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
from webviz_subsurface._utils.formatting import printable_int_list
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
def test_printable_int_list() -> None:
|
|
5
|
-
assert printable_int_list([1, 2, 5, 6, 9, 8, 19]) == "1-2, 5-6, 8-9, 19"
|
|
6
|
-
assert printable_int_list([5, 3, 4, 0]) == "0, 3-5"
|
|
7
|
-
assert printable_int_list([0, 1, 2, 3, 6]) == "0-3, 6"
|
|
8
|
-
assert printable_int_list([]) == "None"
|
|
9
|
-
assert printable_int_list(None) == "None"
|
|
10
|
-
assert printable_int_list([5]) == "5"
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import pytest
|
|
2
|
-
|
|
3
|
-
from webviz_subsurface._utils import simulation_timeseries
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
@pytest.mark.parametrize(
|
|
7
|
-
"date,vector,interval,as_date,res",
|
|
8
|
-
[
|
|
9
|
-
# Testing AVG_ vectors
|
|
10
|
-
("2000-01-01", "AVG_FOPR", "monthly", False, "2000-01"),
|
|
11
|
-
("2003-05-12", "AVG_WOPR:OP_1", "monthly", False, "2003-05"),
|
|
12
|
-
("2002-05-12", "AVG_WOPR:OP_1", "yearly", False, "2002"),
|
|
13
|
-
("2002-05-12", "AVG_WOPR:OP_1", "yearly", True, "2002-01-01"),
|
|
14
|
-
("2002-05-12", "AVG_WOPR:OP_1", "daily", False, "2002-05-12"),
|
|
15
|
-
("2002-05-12", "AVG_WOPR:OP_1", "daily", True, "2002-05-12"),
|
|
16
|
-
(None, "AVG_WOPR:OP_1", "daily", True, None),
|
|
17
|
-
# Testing INTVL_ vectors
|
|
18
|
-
("2000-01-01", "INTVL_FOPR", "monthly", False, "2000-01"),
|
|
19
|
-
("2003-05-12", "INTVL_WGPT:OP_1", "monthly", False, "2003-05"),
|
|
20
|
-
("2002-05-12", "INTVL_WGPT:OP_1", "yearly", False, "2002"),
|
|
21
|
-
("2002-05-12", "INTVL_WGPT:OP_1", "yearly", True, "2002-01-01"),
|
|
22
|
-
("2002-05-12", "INTVL_WGPT:OP_1", "daily", False, "2002-05-12"),
|
|
23
|
-
("2002-05-12", "INTVL_WGPT:OP_1", "daily", True, "2002-05-12"),
|
|
24
|
-
(None, "INTVL_WGPT:OP_1", "daily", True, None),
|
|
25
|
-
# Testing vectors that are not AVG_ or INTVL_. Dates should return as is.
|
|
26
|
-
("2000-01-01", "FOPR", "monthly", False, "2000-01-01"),
|
|
27
|
-
("2003-05-12", "FGPT", "monthly", False, "2003-05-12"),
|
|
28
|
-
("2002-05-12", "WGPT:OP_1", "yearly", False, "2002-05-12"),
|
|
29
|
-
("2002-05-12", "WOPR:OP_1", "yearly", True, "2002-05-12"),
|
|
30
|
-
("2002-05-12", "TIMESTEP", "daily", False, "2002-05-12"),
|
|
31
|
-
("2002-05-12", "NSUMPROB", "daily", True, "2002-05-12"),
|
|
32
|
-
(None, "WWCT:OP_2", "daily", True, None),
|
|
33
|
-
],
|
|
34
|
-
)
|
|
35
|
-
def test_date_to_interval_conversion(
|
|
36
|
-
date: str, vector: str, interval: str, as_date: bool, res: str
|
|
37
|
-
) -> None:
|
|
38
|
-
if res is None:
|
|
39
|
-
assert (
|
|
40
|
-
simulation_timeseries.date_to_interval_conversion(
|
|
41
|
-
date=date, vector=vector, interval=interval, as_date=as_date
|
|
42
|
-
)
|
|
43
|
-
is None
|
|
44
|
-
)
|
|
45
|
-
else:
|
|
46
|
-
assert (
|
|
47
|
-
simulation_timeseries.date_to_interval_conversion(
|
|
48
|
-
date=date, vector=vector, interval=interval, as_date=as_date
|
|
49
|
-
)
|
|
50
|
-
== res
|
|
51
|
-
)
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
from ._plugin import CO2Leakage
|
|
File without changes
|
|
File without changes
|
|
File without changes
|