You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We're currently getting a bunch of test errors coming from Line 98 in core.py in the adjust quantile mapping function coming from how we're slicing time:
=================================== FAILURES ===================================
__________ test_adjust_quantiledeltamapping_year_kind[additive kind] ___________
variable_kind = '+', expected = -1.0
@pytest.mark.parametrize(
"variable_kind, expected",
[
pytest.param("+", -1.0, id="additive kind"),
pytest.param("*", 0.5, id="multiplicative kind"),
],
)
def test_adjust_quantiledeltamapping_year_kind(variable_kind, expected):
"""Test that QDM 'kind' is handled"""
# Setup input data.
target_variable = "fakevariable"
n_simdays = 100 * 365 # 100 years of daily simulation.
model_bias = 2.0
ts_sim = np.ones(n_simdays, dtype=np.float64)
sim = _timeseriesfactory(
ts_sim * model_bias, start_dt="2015-01-01", variable_name=target_variable
)
target_year = 2026
# Yes, I'm intentionally training the QDM to a different bias. This is to
# spurn a difference between "kind" adjustments...
qdm = _train_simple_qdm(
target_variable="fakevariable", kind=variable_kind, additive_bias=model_bias + 1
)
> adjusted_ds = adjust_quantiledeltamapping_year(
simulation=sim,
qdm=qdm,
year=target_year,
variable=target_variable,
)
opt/dodola/dodola/tests/test_core.py:109:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
opt/dodola/dodola/core.py:98: in adjust_quantiledeltamapping_year
simulation = simulation[variable].sel(
opt/conda/lib/python3.9/site-packages/xarray/core/dataarray.py:1271: in sel
ds = self._to_temp_dataset().sel(
opt/conda/lib/python3.9/site-packages/xarray/core/dataset.py:2365: in sel
pos_indexers, new_indexes = remap_label_indexers(
opt/conda/lib/python3.9/site-packages/xarray/core/coordinates.py:421: in remap_label_indexers
pos_indexers, new_indexes = indexing.remap_label_indexers(
opt/conda/lib/python3.9/site-packages/xarray/core/indexing.py:274: in remap_label_indexers
idxr, new_idx = convert_label_indexer(index, label, dim, method, tolerance)
opt/conda/lib/python3.9/site-packages/xarray/core/indexing.py:121: in convert_label_indexer
indexer = index.slice_indexer(
opt/conda/lib/python3.9/site-packages/pandas/core/indexes/base.py:5686: in slice_indexer
start_slice, end_slice = self.slice_locs(start, end, step=step)
opt/conda/lib/python3.9/site-packages/pandas/core/indexes/base.py:5888: in slice_locs
start_slice = self.get_slice_bound(start, "left")
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = CFTimeIndex([2015-01-01 00:00:00, 2015-01-02 00:00:00, 2015-01-03 00:00:00,
2015-01-04 00:00:00, 2015-01-...-30 00:00:00,
2114-12-31 00:00:00],
dtype='object', length=36500, calendar='noleap', freq='D')
label = '2015-12-17', side = 'left', kind = None
def get_slice_bound(self, label, side: str_t, kind=None) -> int:
"""
Calculate slice bound that corresponds to given label.
Returns leftmost (one-past-the-rightmost if ``side=='right'``) position
of given label.
Parameters
----------
label : object
side : {'left', 'right'}
kind : {'loc', 'getitem'} or None
Returns
-------
int
Index of label.
"""
assert kind in ["loc", "getitem", None]
if side not in ("left", "right"):
raise ValueError(
"Invalid value for side kwarg, must be either "
f"'left' or 'right': {side}"
)
original_label = label
# For datetime indices label may be a string that has to be converted
# to datetime boundary according to its resolution.
> label = self._maybe_cast_slice_bound(label, side)
E TypeError: _maybe_cast_slice_bound() missing 1 required positional argument: 'kind'
opt/conda/lib/python3.9/site-packages/pandas/core/indexes/base.py:5798: TypeError
We're currently getting a bunch of test errors coming from Line 98 in
core.py
in the adjust quantile mapping function coming from how we're slicing time:Edit: Can see this in PR #95 CI job https://github.com/ClimateImpactLab/dodola/runs/2975167693.
The text was updated successfully, but these errors were encountered: