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
tests/unit_tests/plugin_tests/test_simulation_time_series/test_utils/test_delta_ensemble_utils.py
DELETED
|
@@ -1,222 +0,0 @@
|
|
|
1
|
-
from typing import List
|
|
2
|
-
|
|
3
|
-
import pytest
|
|
4
|
-
|
|
5
|
-
from webviz_subsurface._utils.ensemble_summary_provider_set import (
|
|
6
|
-
EnsembleSummaryProviderSet,
|
|
7
|
-
)
|
|
8
|
-
|
|
9
|
-
# pylint: disable=line-too-long
|
|
10
|
-
from webviz_subsurface.plugins._simulation_time_series._views._subplot_view._utils.delta_ensemble_utils import (
|
|
11
|
-
DeltaEnsemble,
|
|
12
|
-
create_delta_ensemble_name,
|
|
13
|
-
create_delta_ensemble_name_dict,
|
|
14
|
-
create_delta_ensemble_names,
|
|
15
|
-
create_delta_ensemble_provider_pair,
|
|
16
|
-
is_delta_ensemble_providers_in_provider_set,
|
|
17
|
-
)
|
|
18
|
-
|
|
19
|
-
from ....mocks.ensemble_summary_provider_dummy import EnsembleSummaryProviderDummy
|
|
20
|
-
|
|
21
|
-
# *******************************************************************
|
|
22
|
-
#####################################################################
|
|
23
|
-
#
|
|
24
|
-
# CONFIGURE TESTDATA
|
|
25
|
-
#
|
|
26
|
-
#####################################################################
|
|
27
|
-
# *******************************************************************
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
class EnsembleSummaryProviderMock(EnsembleSummaryProviderDummy):
|
|
31
|
-
"""Ensemble summary provider mock for testing
|
|
32
|
-
|
|
33
|
-
Note empty list returned in override methods, only to allow constructing
|
|
34
|
-
EnsembleSummaryProviderSet objects!
|
|
35
|
-
"""
|
|
36
|
-
|
|
37
|
-
def __init__(self, name: str) -> None:
|
|
38
|
-
super().__init__()
|
|
39
|
-
self._name = name
|
|
40
|
-
|
|
41
|
-
def get_name(self) -> str:
|
|
42
|
-
return self._name
|
|
43
|
-
|
|
44
|
-
########################################
|
|
45
|
-
#
|
|
46
|
-
# Override methods
|
|
47
|
-
#
|
|
48
|
-
########################################
|
|
49
|
-
def vector_names(self) -> List[str]:
|
|
50
|
-
"""Return empty list only to allow constructing EnsembleSummaryProviderSet object"""
|
|
51
|
-
return []
|
|
52
|
-
|
|
53
|
-
def realizations(self) -> List[int]:
|
|
54
|
-
"""Return empty list only to allow constructing EnsembleSummaryProviderSet object"""
|
|
55
|
-
return []
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
# *******************************************************************
|
|
59
|
-
#####################################################################
|
|
60
|
-
#
|
|
61
|
-
# UNIT TESTS
|
|
62
|
-
#
|
|
63
|
-
#####################################################################
|
|
64
|
-
# *******************************************************************
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
def test_create_delta_ensemble_name() -> None:
|
|
68
|
-
assert (
|
|
69
|
-
create_delta_ensemble_name(
|
|
70
|
-
DeltaEnsemble(ensemble_a="first name", ensemble_b="second name")
|
|
71
|
-
)
|
|
72
|
-
== "(first name)-(second name)"
|
|
73
|
-
)
|
|
74
|
-
assert (
|
|
75
|
-
create_delta_ensemble_name(
|
|
76
|
-
DeltaEnsemble(ensemble_a="first-Name", ensemble_b="second-Name")
|
|
77
|
-
)
|
|
78
|
-
== "(first-Name)-(second-Name)"
|
|
79
|
-
)
|
|
80
|
-
assert (
|
|
81
|
-
create_delta_ensemble_name(
|
|
82
|
-
DeltaEnsemble(ensemble_a="ens-0", ensemble_b="ens-3")
|
|
83
|
-
)
|
|
84
|
-
== "(ens-0)-(ens-3)"
|
|
85
|
-
)
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
def test_create_delta_ensemble_names() -> None:
|
|
89
|
-
first_delta_ensemble = DeltaEnsemble(
|
|
90
|
-
ensemble_a="first name", ensemble_b="second name"
|
|
91
|
-
)
|
|
92
|
-
second_delta_ensemble = DeltaEnsemble(
|
|
93
|
-
ensemble_a="first-Name", ensemble_b="second-Name"
|
|
94
|
-
)
|
|
95
|
-
third_delta_ensemble = DeltaEnsemble(ensemble_a="ens-0", ensemble_b="ens-3")
|
|
96
|
-
|
|
97
|
-
assert create_delta_ensemble_names(
|
|
98
|
-
[first_delta_ensemble, second_delta_ensemble, third_delta_ensemble]
|
|
99
|
-
) == ["(first name)-(second name)", "(first-Name)-(second-Name)", "(ens-0)-(ens-3)"]
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
def test_create_delta_ensemble_name_dict() -> None:
|
|
103
|
-
first_delta_ensemble = DeltaEnsemble(
|
|
104
|
-
ensemble_a="first name", ensemble_b="second name"
|
|
105
|
-
)
|
|
106
|
-
second_delta_ensemble = DeltaEnsemble(
|
|
107
|
-
ensemble_a="first-Name", ensemble_b="second-Name"
|
|
108
|
-
)
|
|
109
|
-
third_delta_ensemble = DeltaEnsemble(ensemble_a="ens-0", ensemble_b="ens-3")
|
|
110
|
-
|
|
111
|
-
expected_delta_ensemble_name_dict = {
|
|
112
|
-
"(first name)-(second name)": first_delta_ensemble,
|
|
113
|
-
"(first-Name)-(second-Name)": second_delta_ensemble,
|
|
114
|
-
"(ens-0)-(ens-3)": third_delta_ensemble,
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
assert (
|
|
118
|
-
create_delta_ensemble_name_dict(
|
|
119
|
-
[first_delta_ensemble, second_delta_ensemble, third_delta_ensemble]
|
|
120
|
-
)
|
|
121
|
-
== expected_delta_ensemble_name_dict
|
|
122
|
-
)
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
def test_is_delta_ensemble_providers_in_provider_set() -> None:
|
|
126
|
-
provider_set = EnsembleSummaryProviderSet(
|
|
127
|
-
{
|
|
128
|
-
"First provider": EnsembleSummaryProviderMock("First mock"),
|
|
129
|
-
"Second provider": EnsembleSummaryProviderMock("Second mock"),
|
|
130
|
-
}
|
|
131
|
-
)
|
|
132
|
-
|
|
133
|
-
valid_delta_ensemble = DeltaEnsemble(
|
|
134
|
-
ensemble_a="First provider", ensemble_b="Second provider"
|
|
135
|
-
)
|
|
136
|
-
invalid_delta_ensemble = DeltaEnsemble(
|
|
137
|
-
ensemble_a="First provider", ensemble_b="Third provider"
|
|
138
|
-
)
|
|
139
|
-
|
|
140
|
-
assert is_delta_ensemble_providers_in_provider_set(
|
|
141
|
-
valid_delta_ensemble, provider_set
|
|
142
|
-
)
|
|
143
|
-
assert not is_delta_ensemble_providers_in_provider_set(
|
|
144
|
-
invalid_delta_ensemble, provider_set
|
|
145
|
-
)
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
def test_create_delta_ensemble_provider_pair() -> None:
|
|
149
|
-
provider_set = EnsembleSummaryProviderSet(
|
|
150
|
-
{
|
|
151
|
-
"First provider": EnsembleSummaryProviderMock("First mock"),
|
|
152
|
-
"Second provider": EnsembleSummaryProviderMock("Second mock"),
|
|
153
|
-
"Third provider": EnsembleSummaryProviderMock(("Third mock")),
|
|
154
|
-
}
|
|
155
|
-
)
|
|
156
|
-
|
|
157
|
-
first_delta_ensemble = DeltaEnsemble(
|
|
158
|
-
ensemble_a="First provider", ensemble_b="Third provider"
|
|
159
|
-
)
|
|
160
|
-
second_delta_ensemble = DeltaEnsemble(
|
|
161
|
-
ensemble_a="Third provider", ensemble_b="Second provider"
|
|
162
|
-
)
|
|
163
|
-
|
|
164
|
-
first_provider_pair = create_delta_ensemble_provider_pair(
|
|
165
|
-
first_delta_ensemble, provider_set
|
|
166
|
-
)
|
|
167
|
-
second_provider_pair = create_delta_ensemble_provider_pair(
|
|
168
|
-
second_delta_ensemble, provider_set
|
|
169
|
-
)
|
|
170
|
-
|
|
171
|
-
assert len(first_provider_pair) == 2
|
|
172
|
-
ensemble_a = first_provider_pair[0]
|
|
173
|
-
ensemble_b = first_provider_pair[1]
|
|
174
|
-
if not isinstance(ensemble_a, EnsembleSummaryProviderMock):
|
|
175
|
-
pytest.fail(
|
|
176
|
-
f'Expected "{ensemble_a}" in second provider pair to be of type '
|
|
177
|
-
"EnsembleSummaryProviderMock"
|
|
178
|
-
)
|
|
179
|
-
if not isinstance(ensemble_b, EnsembleSummaryProviderMock):
|
|
180
|
-
pytest.fail(
|
|
181
|
-
f'Expected "{ensemble_b}" in second provider pair to be of type '
|
|
182
|
-
"EnsembleSummaryProviderMock"
|
|
183
|
-
)
|
|
184
|
-
assert ensemble_a.get_name() == "First mock"
|
|
185
|
-
assert ensemble_b.get_name() == "Third mock"
|
|
186
|
-
|
|
187
|
-
assert len(second_provider_pair) == 2
|
|
188
|
-
ensemble_a = second_provider_pair[0]
|
|
189
|
-
ensemble_b = second_provider_pair[1]
|
|
190
|
-
if not isinstance(ensemble_a, EnsembleSummaryProviderMock):
|
|
191
|
-
pytest.fail(
|
|
192
|
-
f'Expected "{ensemble_a}" in second provider pair to be of type '
|
|
193
|
-
"EnsembleSummaryProviderMock"
|
|
194
|
-
)
|
|
195
|
-
if not isinstance(ensemble_b, EnsembleSummaryProviderMock):
|
|
196
|
-
pytest.fail(
|
|
197
|
-
f'Expected "{ensemble_b}" in second provider pair to be of type '
|
|
198
|
-
"EnsembleSummaryProviderMock"
|
|
199
|
-
)
|
|
200
|
-
assert ensemble_a.get_name() == "Third mock"
|
|
201
|
-
assert ensemble_b.get_name() == "Second mock"
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
def test_create_delta_ensemble_provider_pair_invalid_ensemble() -> None:
|
|
205
|
-
provider_set = EnsembleSummaryProviderSet(
|
|
206
|
-
{
|
|
207
|
-
"First provider": EnsembleSummaryProviderMock("First mock"),
|
|
208
|
-
"Second provider": EnsembleSummaryProviderMock("Second mock"),
|
|
209
|
-
}
|
|
210
|
-
)
|
|
211
|
-
|
|
212
|
-
# Expect ValueError when retrieveing ensemble_b is invalid
|
|
213
|
-
with pytest.raises(ValueError):
|
|
214
|
-
invalid_provider = "Invalid provider"
|
|
215
|
-
invalid_provider_pair = DeltaEnsemble(
|
|
216
|
-
ensemble_a="First provider", ensemble_b=invalid_provider
|
|
217
|
-
)
|
|
218
|
-
create_delta_ensemble_provider_pair(invalid_provider_pair, provider_set)
|
|
219
|
-
pytest.fail(
|
|
220
|
-
"Expected ValueError when creating delta ensemble provider pair, as ensemble b = "
|
|
221
|
-
f'"{invalid_provider}" is not existing in provider set!'
|
|
222
|
-
)
|
|
@@ -1,319 +0,0 @@
|
|
|
1
|
-
import datetime
|
|
2
|
-
|
|
3
|
-
import pandas as pd
|
|
4
|
-
import pytest
|
|
5
|
-
from pandas._testing import assert_frame_equal
|
|
6
|
-
from webviz_subsurface_components.VectorCalculatorWrapper import (
|
|
7
|
-
ExpressionInfo,
|
|
8
|
-
VariableVectorMapInfo,
|
|
9
|
-
)
|
|
10
|
-
|
|
11
|
-
from webviz_subsurface._utils.dataframe_utils import make_date_column_datetime_object
|
|
12
|
-
|
|
13
|
-
# pylint: disable = line-too-long
|
|
14
|
-
from webviz_subsurface.plugins._simulation_time_series._views._subplot_view._utils.derived_vectors_accessor.derived_delta_ensemble_vectors_accessor_impl import (
|
|
15
|
-
DerivedDeltaEnsembleVectorsAccessorImpl,
|
|
16
|
-
)
|
|
17
|
-
|
|
18
|
-
from ..mocks.derived_vectors_accessor_ensemble_summary_provider_mock import (
|
|
19
|
-
EnsembleSummaryProviderMock,
|
|
20
|
-
)
|
|
21
|
-
|
|
22
|
-
# *******************************************************************
|
|
23
|
-
#####################################################################
|
|
24
|
-
#
|
|
25
|
-
# CONFIGURE TESTDATA
|
|
26
|
-
#
|
|
27
|
-
#####################################################################
|
|
28
|
-
# *******************************************************************
|
|
29
|
-
|
|
30
|
-
# fmt: off
|
|
31
|
-
# Ensemble A
|
|
32
|
-
INPUT_A_DF = pd.DataFrame(
|
|
33
|
-
columns = ["DATE", "REAL", "A", "B"],
|
|
34
|
-
data = [
|
|
35
|
-
[datetime.datetime(2000,1,1), 1, 10.0, 500.0 ],
|
|
36
|
-
[datetime.datetime(2000,2,1), 1, 20.0, 1000.0 ],
|
|
37
|
-
[datetime.datetime(2000,3,1), 1, 30.0, 1500.0 ],
|
|
38
|
-
[datetime.datetime(2000,1,1), 2, 60.0, 3000.0 ],
|
|
39
|
-
[datetime.datetime(2000,2,1), 2, 70.0, 4000.0 ],
|
|
40
|
-
[datetime.datetime(2000,3,1), 2, 80.0, 5000.0 ],
|
|
41
|
-
[datetime.datetime(2000,1,1), 4, 110.0, 10000.0],
|
|
42
|
-
[datetime.datetime(2000,2,1), 4, 120.0, 12000.0],
|
|
43
|
-
[datetime.datetime(2000,3,1), 4, 130.0, 14000.0],
|
|
44
|
-
]
|
|
45
|
-
)
|
|
46
|
-
|
|
47
|
-
# Ensemble B
|
|
48
|
-
INPUT_B_DF = pd.DataFrame(
|
|
49
|
-
columns = ["DATE", "REAL", "A", "B"],
|
|
50
|
-
data = [
|
|
51
|
-
[datetime.datetime(2000,1,1), 1, 1.0, 50.0 ],
|
|
52
|
-
[datetime.datetime(2000,2,1), 1, 2.0, 100.0 ],
|
|
53
|
-
[datetime.datetime(2000,3,1), 1, 3.0, 150.0 ],
|
|
54
|
-
[datetime.datetime(2000,1,1), 2, 6.0, 300.0 ],
|
|
55
|
-
[datetime.datetime(2000,2,1), 2, 7.0, 400.0 ],
|
|
56
|
-
[datetime.datetime(2000,3,1), 2, 8.0, 500.0 ],
|
|
57
|
-
[datetime.datetime(2000,1,1), 4, 11.0, 1000.0],
|
|
58
|
-
[datetime.datetime(2000,2,1), 4, 12.0, 1200.0],
|
|
59
|
-
[datetime.datetime(2000,3,1), 4, 13.0, 1400.0],
|
|
60
|
-
]
|
|
61
|
-
)
|
|
62
|
-
|
|
63
|
-
# Delta between A and B DF (A-B)
|
|
64
|
-
EXPECTED_DELTA_DF = pd.DataFrame(
|
|
65
|
-
columns = ["DATE", "REAL", "A", "B"],
|
|
66
|
-
data = [
|
|
67
|
-
[datetime.datetime(2000,1,1), 1, 9.0, 450.0 ],
|
|
68
|
-
[datetime.datetime(2000,2,1), 1, 18.0, 900.0 ],
|
|
69
|
-
[datetime.datetime(2000,3,1), 1, 27.0, 1350.0 ],
|
|
70
|
-
[datetime.datetime(2000,1,1), 2, 54.0, 2700.0 ],
|
|
71
|
-
[datetime.datetime(2000,2,1), 2, 63.0, 3600.0 ],
|
|
72
|
-
[datetime.datetime(2000,3,1), 2, 72.0, 4500.0 ],
|
|
73
|
-
[datetime.datetime(2000,1,1), 4, 99.0, 9000.0 ],
|
|
74
|
-
[datetime.datetime(2000,2,1), 4, 108.0, 10800.0],
|
|
75
|
-
[datetime.datetime(2000,3,1), 4, 117.0, 12600.0],
|
|
76
|
-
]
|
|
77
|
-
)
|
|
78
|
-
|
|
79
|
-
# PER_INTVL_ calc for col "B" of Delta
|
|
80
|
-
EXPECTED_DELTA_INVTL_DF = pd.DataFrame(
|
|
81
|
-
columns = ["DATE", "REAL", "PER_INTVL_B"],
|
|
82
|
-
data = [
|
|
83
|
-
[datetime.datetime(2000,1,1), 1, 450.0 ],
|
|
84
|
-
[datetime.datetime(2000,2,1), 1, 450.0 ],
|
|
85
|
-
[datetime.datetime(2000,3,1), 1, 0.0 ],
|
|
86
|
-
[datetime.datetime(2000,1,1), 2, 900.0 ],
|
|
87
|
-
[datetime.datetime(2000,2,1), 2, 900.0 ],
|
|
88
|
-
[datetime.datetime(2000,3,1), 2, 0.0 ],
|
|
89
|
-
[datetime.datetime(2000,1,1), 4, 1800.0],
|
|
90
|
-
[datetime.datetime(2000,2,1), 4, 1800.0],
|
|
91
|
-
[datetime.datetime(2000,3,1), 4, 0.0 ],
|
|
92
|
-
]
|
|
93
|
-
)
|
|
94
|
-
|
|
95
|
-
# Sum of col "A" and "B" in Delta
|
|
96
|
-
EXPECTED_SUM_A_AND_B_DF = pd.DataFrame(
|
|
97
|
-
columns = ["DATE", "REAL", "Sum A and B"],
|
|
98
|
-
data = [
|
|
99
|
-
[datetime.datetime(2000,1,1), 1, 459.0 ],
|
|
100
|
-
[datetime.datetime(2000,2,1), 1, 918.0 ],
|
|
101
|
-
[datetime.datetime(2000,3,1), 1, 1377.0 ],
|
|
102
|
-
[datetime.datetime(2000,1,1), 2, 2754.0 ],
|
|
103
|
-
[datetime.datetime(2000,2,1), 2, 3663.0 ],
|
|
104
|
-
[datetime.datetime(2000,3,1), 2, 4572.0 ],
|
|
105
|
-
[datetime.datetime(2000,1,1), 4, 9099.0 ],
|
|
106
|
-
[datetime.datetime(2000,2,1), 4, 10908.0],
|
|
107
|
-
[datetime.datetime(2000,3,1), 4, 12717.0],
|
|
108
|
-
]
|
|
109
|
-
)
|
|
110
|
-
make_date_column_datetime_object(INPUT_A_DF)
|
|
111
|
-
make_date_column_datetime_object(INPUT_B_DF)
|
|
112
|
-
make_date_column_datetime_object(EXPECTED_DELTA_DF)
|
|
113
|
-
make_date_column_datetime_object(EXPECTED_DELTA_INVTL_DF)
|
|
114
|
-
make_date_column_datetime_object(EXPECTED_SUM_A_AND_B_DF)
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
# Dates AFTER year 2262!
|
|
118
|
-
AFTER_2262_DATES = pd.Series(
|
|
119
|
-
[
|
|
120
|
-
datetime.datetime(2265,1,1),
|
|
121
|
-
datetime.datetime(2265,2,1),
|
|
122
|
-
datetime.datetime(2265,3,1),
|
|
123
|
-
datetime.datetime(2265,1,1),
|
|
124
|
-
datetime.datetime(2265,2,1),
|
|
125
|
-
datetime.datetime(2265,3,1),
|
|
126
|
-
datetime.datetime(2265,1,1),
|
|
127
|
-
datetime.datetime(2265,2,1),
|
|
128
|
-
datetime.datetime(2265,3,1),
|
|
129
|
-
]
|
|
130
|
-
)
|
|
131
|
-
# NOTE: datetime.datetime after year 2262 is not converted to pd.Timestamp, thus
|
|
132
|
-
# no need to make date column datetime object
|
|
133
|
-
INPUT_A_AFTER_2262_DF = INPUT_A_DF.copy()
|
|
134
|
-
INPUT_A_AFTER_2262_DF["DATE"] = AFTER_2262_DATES
|
|
135
|
-
INPUT_B_AFTER_2262_DF = INPUT_B_DF.copy()
|
|
136
|
-
INPUT_B_AFTER_2262_DF["DATE"] = AFTER_2262_DATES
|
|
137
|
-
EXPECTED_DELTA_AFTER_2262_DF = EXPECTED_DELTA_DF.copy()
|
|
138
|
-
EXPECTED_DELTA_AFTER_2262_DF["DATE"] = AFTER_2262_DATES
|
|
139
|
-
EXPECTED_DELTA_INVTL_AFTER_2262_DF = EXPECTED_DELTA_INVTL_DF.copy()
|
|
140
|
-
EXPECTED_DELTA_INVTL_AFTER_2262_DF["DATE"] = AFTER_2262_DATES
|
|
141
|
-
EXPECTED_SUM_A_AND_B_AFTER_2262_DF = EXPECTED_SUM_A_AND_B_DF.copy()
|
|
142
|
-
EXPECTED_SUM_A_AND_B_AFTER_2262_DF["DATE"] = AFTER_2262_DATES
|
|
143
|
-
|
|
144
|
-
# fmt: on
|
|
145
|
-
TEST_EXPRESSION = ExpressionInfo(
|
|
146
|
-
name="Sum A and B",
|
|
147
|
-
expression="x+y",
|
|
148
|
-
id="TestId",
|
|
149
|
-
variableVectorMap=[
|
|
150
|
-
VariableVectorMapInfo(variableName="x", vectorName=["A"]),
|
|
151
|
-
VariableVectorMapInfo(variableName="y", vectorName=["B"]),
|
|
152
|
-
],
|
|
153
|
-
isValid=True,
|
|
154
|
-
isDeletable=False,
|
|
155
|
-
)
|
|
156
|
-
|
|
157
|
-
TEST_ACCESSOR = DerivedDeltaEnsembleVectorsAccessorImpl(
|
|
158
|
-
name="Test accessor",
|
|
159
|
-
provider_pair=(
|
|
160
|
-
EnsembleSummaryProviderMock(INPUT_A_DF),
|
|
161
|
-
EnsembleSummaryProviderMock(INPUT_B_DF),
|
|
162
|
-
),
|
|
163
|
-
vectors=["A", "B", "PER_INTVL_B", "Sum A and B"],
|
|
164
|
-
expressions=[TEST_EXPRESSION],
|
|
165
|
-
resampling_frequency=None,
|
|
166
|
-
)
|
|
167
|
-
|
|
168
|
-
TEST_AFTER_2262_ACCESSOR = DerivedDeltaEnsembleVectorsAccessorImpl(
|
|
169
|
-
name="Test 2262 accessor",
|
|
170
|
-
provider_pair=(
|
|
171
|
-
EnsembleSummaryProviderMock(INPUT_A_AFTER_2262_DF),
|
|
172
|
-
EnsembleSummaryProviderMock(INPUT_B_AFTER_2262_DF),
|
|
173
|
-
),
|
|
174
|
-
vectors=["A", "B", "PER_INTVL_B", "Sum A and B"],
|
|
175
|
-
expressions=[TEST_EXPRESSION],
|
|
176
|
-
resampling_frequency=None,
|
|
177
|
-
)
|
|
178
|
-
|
|
179
|
-
TEST_EMPTY_ACCESSOR = DerivedDeltaEnsembleVectorsAccessorImpl(
|
|
180
|
-
name="Empty provider accessor",
|
|
181
|
-
provider_pair=(
|
|
182
|
-
EnsembleSummaryProviderMock(pd.DataFrame()),
|
|
183
|
-
EnsembleSummaryProviderMock(pd.DataFrame()),
|
|
184
|
-
),
|
|
185
|
-
vectors=["A", "B", "PER_INTVL_B", "Sum A and B"],
|
|
186
|
-
expressions=None,
|
|
187
|
-
resampling_frequency=None,
|
|
188
|
-
)
|
|
189
|
-
|
|
190
|
-
# *******************************************************************
|
|
191
|
-
#####################################################################
|
|
192
|
-
#
|
|
193
|
-
# UNIT TESTS
|
|
194
|
-
#
|
|
195
|
-
#####################################################################
|
|
196
|
-
# *******************************************************************
|
|
197
|
-
|
|
198
|
-
TEST_STATUS_CASES = [
|
|
199
|
-
pytest.param(TEST_ACCESSOR, True),
|
|
200
|
-
pytest.param(TEST_AFTER_2262_ACCESSOR, True),
|
|
201
|
-
pytest.param(TEST_EMPTY_ACCESSOR, False),
|
|
202
|
-
]
|
|
203
|
-
TEST_GET_VECTOR_CASES = [
|
|
204
|
-
pytest.param(TEST_ACCESSOR, EXPECTED_DELTA_DF),
|
|
205
|
-
pytest.param(TEST_AFTER_2262_ACCESSOR, EXPECTED_DELTA_AFTER_2262_DF),
|
|
206
|
-
]
|
|
207
|
-
TEST_CREATE_PER_INTVL_PER_DAY_VECTOR_CASES = [
|
|
208
|
-
pytest.param(TEST_ACCESSOR, EXPECTED_DELTA_INVTL_DF),
|
|
209
|
-
pytest.param(TEST_AFTER_2262_ACCESSOR, EXPECTED_DELTA_INVTL_AFTER_2262_DF),
|
|
210
|
-
]
|
|
211
|
-
TEST_CREATE_CALCULATED_VECTOR_CASES = [
|
|
212
|
-
pytest.param(TEST_ACCESSOR, EXPECTED_SUM_A_AND_B_DF),
|
|
213
|
-
pytest.param(TEST_AFTER_2262_ACCESSOR, EXPECTED_SUM_A_AND_B_AFTER_2262_DF),
|
|
214
|
-
]
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
@pytest.mark.parametrize("test_accessor, expected_state", TEST_STATUS_CASES)
|
|
218
|
-
def test_has_provider_vectors(
|
|
219
|
-
test_accessor: DerivedDeltaEnsembleVectorsAccessorImpl, expected_state: bool
|
|
220
|
-
) -> None:
|
|
221
|
-
assert test_accessor.has_provider_vectors() == expected_state
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
@pytest.mark.parametrize("test_accessor, expected_state", TEST_STATUS_CASES)
|
|
225
|
-
def test_has_per_interval_and_per_day_vectors(
|
|
226
|
-
test_accessor: DerivedDeltaEnsembleVectorsAccessorImpl, expected_state: bool
|
|
227
|
-
) -> None:
|
|
228
|
-
assert test_accessor.has_per_interval_and_per_day_vectors() == expected_state
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
@pytest.mark.parametrize("test_accessor, expected_state", TEST_STATUS_CASES)
|
|
232
|
-
def test_has_vector_calculator_expressions(
|
|
233
|
-
test_accessor: DerivedDeltaEnsembleVectorsAccessorImpl, expected_state: bool
|
|
234
|
-
) -> None:
|
|
235
|
-
assert test_accessor.has_vector_calculator_expressions() == expected_state
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
@pytest.mark.parametrize("test_accessor, expected_df", TEST_GET_VECTOR_CASES)
|
|
239
|
-
def test_get_provider_vectors(
|
|
240
|
-
test_accessor: DerivedDeltaEnsembleVectorsAccessorImpl, expected_df: pd.DataFrame
|
|
241
|
-
) -> None:
|
|
242
|
-
assert_frame_equal(expected_df, test_accessor.get_provider_vectors_df())
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
@pytest.mark.parametrize("test_accessor, expected_df", TEST_GET_VECTOR_CASES)
|
|
246
|
-
def test_get_provider_vectors_filter_realizations(
|
|
247
|
-
test_accessor: DerivedDeltaEnsembleVectorsAccessorImpl, expected_df: pd.DataFrame
|
|
248
|
-
) -> None:
|
|
249
|
-
# Filter realizations
|
|
250
|
-
expected_reals_df = (
|
|
251
|
-
expected_df.loc[expected_df["REAL"].isin([2, 4])]
|
|
252
|
-
.reset_index()
|
|
253
|
-
.drop("index", axis=1)
|
|
254
|
-
)
|
|
255
|
-
|
|
256
|
-
test_df = test_accessor.get_provider_vectors_df(realizations=[2, 4])
|
|
257
|
-
|
|
258
|
-
assert_frame_equal(expected_reals_df, test_df)
|
|
259
|
-
assert list(set(test_df["REAL"].values)) == [2, 4]
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
@pytest.mark.parametrize(
|
|
263
|
-
"test_accessor, expected_df", TEST_CREATE_PER_INTVL_PER_DAY_VECTOR_CASES
|
|
264
|
-
)
|
|
265
|
-
def test_create_per_interval_and_per_day_vectors_df(
|
|
266
|
-
test_accessor: DerivedDeltaEnsembleVectorsAccessorImpl, expected_df: pd.DataFrame
|
|
267
|
-
) -> None:
|
|
268
|
-
assert_frame_equal(
|
|
269
|
-
expected_df, test_accessor.create_per_interval_and_per_day_vectors_df()
|
|
270
|
-
)
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
@pytest.mark.parametrize(
|
|
274
|
-
"test_accessor, expected_df", TEST_CREATE_PER_INTVL_PER_DAY_VECTOR_CASES
|
|
275
|
-
)
|
|
276
|
-
def test_create_per_interval_and_per_day_vectors_df_filter_realizations(
|
|
277
|
-
test_accessor: DerivedDeltaEnsembleVectorsAccessorImpl, expected_df: pd.DataFrame
|
|
278
|
-
) -> None:
|
|
279
|
-
# Filter realizations
|
|
280
|
-
expected_reals_df = (
|
|
281
|
-
expected_df.loc[expected_df["REAL"].isin([1, 4])]
|
|
282
|
-
.reset_index()
|
|
283
|
-
.drop("index", axis=1)
|
|
284
|
-
)
|
|
285
|
-
|
|
286
|
-
test_df = test_accessor.create_per_interval_and_per_day_vectors_df(
|
|
287
|
-
realizations=[1, 4]
|
|
288
|
-
)
|
|
289
|
-
|
|
290
|
-
assert_frame_equal(expected_reals_df, test_df)
|
|
291
|
-
assert list(set(test_df["REAL"].values)) == [1, 4]
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
@pytest.mark.parametrize(
|
|
295
|
-
"test_accessor, expected_df", TEST_CREATE_CALCULATED_VECTOR_CASES
|
|
296
|
-
)
|
|
297
|
-
def test_create_calculated_vectors_df(
|
|
298
|
-
test_accessor: DerivedDeltaEnsembleVectorsAccessorImpl, expected_df: pd.DataFrame
|
|
299
|
-
) -> None:
|
|
300
|
-
assert_frame_equal(expected_df, test_accessor.create_calculated_vectors_df())
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
@pytest.mark.parametrize(
|
|
304
|
-
"test_accessor, expected_df", TEST_CREATE_CALCULATED_VECTOR_CASES
|
|
305
|
-
)
|
|
306
|
-
def test_create_calculated_vectors_df_filter_realizations(
|
|
307
|
-
test_accessor: DerivedDeltaEnsembleVectorsAccessorImpl, expected_df: pd.DataFrame
|
|
308
|
-
) -> None:
|
|
309
|
-
# Filter realizations
|
|
310
|
-
expected_reals_df = (
|
|
311
|
-
expected_df.loc[expected_df["REAL"].isin([1, 2])]
|
|
312
|
-
.reset_index()
|
|
313
|
-
.drop("index", axis=1)
|
|
314
|
-
)
|
|
315
|
-
|
|
316
|
-
test_df = test_accessor.create_calculated_vectors_df(realizations=[1, 2])
|
|
317
|
-
|
|
318
|
-
assert_frame_equal(expected_reals_df, test_df)
|
|
319
|
-
assert list(set(test_df["REAL"].values)) == [1, 2]
|