Skip to content

[pre-commit.ci] pre-commit autoupdate - #376

Merged
mikapfl merged 1 commit into
mainfrom
pre-commit-ci-update-config
Jul 14, 2026
Merged

[pre-commit.ci] pre-commit autoupdate#376
mikapfl merged 1 commit into
mainfrom
pre-commit-ci-update-config

Conversation

@pre-commit-ci

@pre-commit-ci pre-commit-ci Bot commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

@codecov

codecov Bot commented Jun 1, 2026

Copy link
Copy Markdown

❌ 5 Tests Failed:

Tests completed Failed Passed Skipped
467 5 462 0
View the full list of 5 ❄️ flaky test(s)
primap2/_setters.py::DataArraySettersAccessor.set:0

Flake rate in main: 82.76% (Passed 5 times, Failed 24 times)

Stack Traces | 0.009s run time
* REASON: GotWantException
DOCTEST DEBUG INFO
  XDoc ".../primap2/primap2/_setters.py::DataArraySettersAccessor.set:0", line 12 <- wrt doctest
  File ".../primap2/primap2/_setters.py", line 80, <- wrt source file
DOCTEST PART BREAKDOWN
Passed Parts:
      1 >>> import pandas as pd
      2 >>> import xarray as xr
      3 >>> import numpy as np
      4 >>> da = xr.DataArray(
      5 ...     [[0.0, 1.0, 2.0, 3.0], [2.0, 3.0, 4.0, 5.0]],
      6 ...     coords=[
      7 ...         ("area (ISO3)", ["COL", "MEX"]),
      8 ...         ("time", pd.date_range("2000", "2003", freq="YS")),
      9 ...     ],
     10 ... )
Failed Part:
     11 >>> da
Remaining Parts:
     21 >>> da.pr.set("area", "COL", np.array([0.5, 0.6, 0.7, 0.8]))
     25 >>> da.pr.set("area", "COL", np.array([0.5, 0.6, 0.7, 0.8]), existing="overwrite")
     36 >>> da_partly_empty = da.copy(deep=True)
     37 >>> da_partly_empty.pr.loc[{"area": "COL"}] = np.nan
     38 >>> da_partly_empty
     45 >>> da_partly_empty.pr.set("area", "COL", np.array([0.5, 0.6, 0.7, 0.8]))
     52 >>> # if even one value contains data, the default is to raise an Error
     53 >>> da_partly_empty.pr.loc[{"area": "COL", "time": "2001"}] = 0.6
     54 >>> da_partly_empty
     61 >>> da_partly_empty.pr.set("area", "COL", np.array([0.5, 0.6, 0.7, 0.8]))
     68 >>> da.pr.set("area", "ARG", np.array([0.5, 0.6, 0.7, 0.8]))
     79 >>> da.pr.set(
     80 ...     "area",
     81 ...     ["COL", "ARG"],
     82 ...     np.array([[0.5, 0.6, 0.7, 0.8], [5, 6, 7, 8]]),
     83 ...     existing="overwrite",
     84 ... )
     96 >>> da.pr.set("area", "ARG", np.array([0.5, 0.6, 0.7, 0.8]), new="error")
    105 >>> da.pr.set(
    106 ...     "area",
    107 ...     ["COL", "ARG"],
    108 ...     np.array([0.5, 0.6, 0.7, 0.8]),
    109 ...     existing="overwrite",
    110 ... )
    114 >>> da.pr.set(
    115 ...     "area",
    116 ...     ["COL", "ARG"],
    117 ...     np.array([0.5, 0.6, 0.7, 0.8]),
    118 ...     value_dims=["time"],
    119 ...     existing="overwrite",
    120 ... )
    132 >>> da.pr.loc[{"area": "COL", "time": "2001"}] = np.nan
    133 >>> da
    140 >>> da.pr.set(
    141 ...     "area",
    142 ...     ["COL", "ARG"],
    143 ...     np.array([0.5, 0.6, 0.7, 0.8]),
    144 ...     value_dims=["time"],
    145 ...     existing="fillna",
    146 ... )
    158 >>> da.pr.set("area", "ARG", da.pr.loc[{"area": "COL"}] * 2)
DOCTEST TRACEBACK
Differences (unified diff with -expected +actual):
    @@ -4,3 +4,3 @@
     Coordinates:
       * area (ISO3)  (area (ISO3)) <U3 24B 'COL' 'MEX'
    -  * time         (time) datetime64[ns] 32B 2000-01-01 2001-01-01 ... 2003-01-01
    +  * time         (time) datetime64[us] 32B 2000-01-01 2001-01-01 ... 2003-01-01
    
Repr Difference:
    got  = "<xarray.DataArray (area (ISO3): 2, time: 4)> Size: 64B\narray([[0., 1., 2., 3.],\n       [2., 3., 4., 5.]])\nCoordinates:\n  * area (ISO3)  (area (ISO3)) <U3 24B 'COL' 'MEX'\n  * time         (time) datetime64[us] 32B 2000-01-01 2001-01-01 ... 2003-01-01"
    want = "<xarray.DataArray (area (ISO3): 2, time: 4)> Size: 64B\narray([[0., 1., 2., 3.],\n       [2., 3., 4., 5.]])\nCoordinates:\n  * area (ISO3)  (area (ISO3)) <U3 24B 'COL' 'MEX'\n  * time         (time) datetime64[ns] 32B 2000-01-01 2001-01-01 ... 2003-01-01"
DOCTEST REPRODUCTION
CommandLine:
    pytest .../primap2/primap2/_setters.py::DataArraySettersAccessor.set:0
.../primap2/primap2/_setters.py:80: GotWantException
primap2/_setters.py::DatasetSettersAccessor.set:0

Flake rate in main: 82.76% (Passed 5 times, Failed 24 times)

Stack Traces | 0.01s run time
* REASON: GotWantException
DOCTEST DEBUG INFO
  XDoc ".../primap2/primap2/_setters.py::DatasetSettersAccessor.set:0", line 20 <- wrt doctest
  File ".../primap2/primap2/_setters.py", line 429, <- wrt source file
DOCTEST PART BREAKDOWN
Passed Parts:
      1 >>> import pandas as pd
      2 >>> import xarray as xr
      3 >>> import numpy as np
      4 >>> area = ("area (ISO3)", ["COL", "MEX"])
      5 >>> time = ("time", pd.date_range("2000", "2003", freq="YS"))
      6 >>> ds = xr.Dataset(
      7 ...     {
      8 ...         "CO2": xr.DataArray(
      9 ...             [[0.0, 1.0, 2.0, 3.0], [2.0, 3.0, 4.0, 5.0]],
     10 ...             coords=[area, time],
     11 ...         ),
     12 ...         "SF4": xr.DataArray(
     13 ...             [[0.5, 1.5, 2.5, 3.5], [2.5, 3.5, np.nan, 5.5]],
     14 ...             coords=[area, time],
     15 ...         ),
     16 ...     },
     17 ...     attrs={"area": "area (ISO3)"},
     18 ... )
Failed Part:
     19 >>> ds
Remaining Parts:
     33 >>> ds.pr.set("area", "MEX", ds.pr.loc[{"area": "COL"}] * 20)
     37 >>> ds.pr.set("area", "MEX", ds.pr.loc[{"area": "COL"}] * 20, existing="overwrite")
     52 >>> ds.pr.set("area", "MEX", ds.pr.loc[{"area": "COL"}] * 20, existing="fillna")
     67 >>> ds_partly_empty = ds.copy(deep=True)
     68 >>> ds_partly_empty["CO2"].pr.loc[{"area": "COL"}] = np.nan
     69 >>> ds_partly_empty["SF4"].pr.loc[{"area": "COL"}] = np.nan
     70 >>> ds_partly_empty
     81 >>> ds_partly_empty.pr.set("area", "COL", ds_partly_empty.pr.loc[{"area": "MEX"}] * 10)
     92 >>> # if even one value is non-nan, this fails by default
     93 >>> ds_partly_empty["SF4"].pr.loc[{"area": "COL", "time": "2001"}] = 2
     94 >>> ds_partly_empty.pr.set("area", "COL", ds_partly_empty.pr.loc[{"area": "MEX"}] * 10)
    101 >>> ds.pr.set("area", "BOL", ds.pr.loc[{"area": "COL"}] * 20)
    116 >>> ds.pr.set("area", "BOL", ds.pr.loc[{"area": "COL"}] * 20, new="error")
    124 >>> ds["population"] = xr.DataArray([1e6, 1.2e6, 1.3e6, 1.4e6], coords=(time,))
    125 >>> ds
    137 >>> ds.pr.set("area", "BOL", ds.pr.loc[{"area": "COL"}] * 20)
DOCTEST TRACEBACK
Differences (unified diff with -expected +actual):
    @@ -1,7 +1,7 @@
    -<xarray.Dataset> Size: ...
    +<xarray.Dataset> Size: 184B
     Dimensions:      (area (ISO3): 2, time: 4)
     Coordinates:
       * area (ISO3)  (area (ISO3)) <U3 24B 'COL' 'MEX'
    -  * time         (time) datetime64[ns] 32B 2000-01-01 2001-01-01 ... 2003-01-01
    +  * time         (time) datetime64[us] 32B 2000-01-01 2001-01-01 ... 2003-01-01
     Data variables:
         CO2          (area (ISO3), time) float64 64B 0.0 1.0 2.0 3.0 2.0 3.0 4.0 5.0
    
Repr Difference:
    got  = "<xarray.Dataset> Size: 184B\nDimensions:      (area (ISO3): 2, time: 4)\nCoordinates:\n  * area (ISO3)  (area (ISO3)) <U3 24B 'COL' 'MEX'\n  * time         (time) datetime64[us] 32B 2000-01-01 2001-01-01 ... 2003-01-01\nData variables:\n    CO2          (area (ISO3), time) float64 64B 0.0 1.0 2.0 3.0 2.0 3.0 4.0 5.0\n    SF4          (area (ISO3), time) float64 64B 0.5 1.5 2.5 3.5 2.5 3.5 nan 5.5\nAttributes:\n    area:     area (ISO3)"
    want = "<xarray.Dataset> Size: ...\nDimensions:      (area (ISO3): 2, time: 4)\nCoordinates:\n  * area (ISO3)  (area (ISO3)) <U3 24B 'COL' 'MEX'\n  * time         (time) datetime64[ns] 32B 2000-01-01 2001-01-01 ... 2003-01-01\nData variables:\n    CO2          (area (ISO3), time) float64 64B 0.0 1.0 2.0 3.0 2.0 3.0 4.0 5.0\n    SF4          (area (ISO3), time) float64 64B 0.5 1.5 2.5 3.5 2.5 3.5 nan 5.5\nAttributes:\n    area:     area (ISO3)"
DOCTEST REPRODUCTION
CommandLine:
    pytest .../primap2/primap2/_setters.py::DatasetSettersAccessor.set:0
.../primap2/primap2/_setters.py:429: GotWantException
primap2/tests/csg/test_gaps.py::test_calculate_boundary_trend_inner_left

Flake rate in main: 82.76% (Passed 5 times, Failed 24 times)

Stack Traces | 0.059s run time
test_ts = <xarray.DataArray 'test_ts' (time: 74)> Size: 592B
array([        nan,         nan,         nan,         nan,  6.     ...Coordinates:
  * time      (time) datetime64[us] 592B 1952-01-01 1953-01-01 ... 2025-01-01
    category  <U4 16B 'test'
fit_params_linear = FitParameters(fit_degree=1, fallback_degree=0, trend_length=10, trend_length_unit='YS', min_trend_points=5)
fit_params_constant = FitParameters(fit_degree=0, fallback_degree=0, trend_length=10, trend_length_unit='YS', min_trend_points=5)
caplog = <_pytest.logging.LogCaptureFixture object at 0x7f2a0d4708d0>

    def test_calculate_boundary_trend_inner_left(
        test_ts, fit_params_linear, fit_params_constant, caplog
    ):
        gaps = get_gaps(test_ts)
    
        # linear trend for a left boundary
        fit_degree = 1
        # expected result
        data_to_interpolate = test_ts.pr.loc[{"time": slice("1996", "2005")}].data
        coeff = np.polyfit(range(0, 10), data_to_interpolate, deg=fit_degree)
        expected_value = np.polyval(coeff, 9)
        trend_value = calculate_boundary_trend_inner(
            test_ts,
            side="left",
            boundary=gaps[1].left,
            fit_params=fit_params_linear,
        )
        assert np.allclose(expected_value, trend_value)
    
        # constant trend for a right boundary
        fit_degree = 0
        # expected result
        coeff = np.polyfit(range(0, 10), data_to_interpolate, deg=fit_degree)
        expected_value = np.polyval(coeff, 9)
        trend_value = calculate_boundary_trend_inner(
            test_ts,
            side="left",
            boundary=gaps[1].left,
            fit_params=fit_params_constant,
        )
        assert np.allclose(expected_value, trend_value)
    
        # test logging if not enough data points
        test_ts.loc[{"time": slice("1997", "2002")}] = (
            test_ts.loc[{"time": slice("1997", "2002")}] * np.nan
        )
        trend_value = calculate_boundary_trend_inner(
            test_ts, side="left", boundary=gaps[1].left, fit_params=fit_params_linear
        )
        assert np.isnan(trend_value)
    
        log_str = (
            "Not enough values to calculate fit for left boundary at "
            "2005-01-01T00:00:00.000000000.\nfit_degree: 1, trend_length: 10, "
            "trend_length_unit: YS, min_trend_points: 5.\nTimeseries info: "
            "{'category': 'test'}"
        )
    
>       assert log_str in caplog.text
E       assert "Not enough values to calculate fit for left boundary at 2005-01-01T00:00:00.000000000.\nfit_degree: 1, trend_length: 10, trend_length_unit: YS, min_trend_points: 5.\nTimeseries info: {'category': 'test'}" in "INFO     primap2.csg._strategies.gaps:gaps.py:328 Not enough values to calculate fit for left boundary at 2005-01-01T...t_degree: 1, trend_length: 10, trend_length_unit: YS, min_trend_points: 5.\nTimeseries info: {'category': 'test'} {}\n"
E        +  where "INFO     primap2.csg._strategies.gaps:gaps.py:328 Not enough values to calculate fit for left boundary at 2005-01-01T...t_degree: 1, trend_length: 10, trend_length_unit: YS, min_trend_points: 5.\nTimeseries info: {'category': 'test'} {}\n" = <_pytest.logging.LogCaptureFixture object at 0x7f2a0d4708d0>.text

.../tests/csg/test_gaps.py:252: AssertionError
primap2/tests/csg/test_gaps.py::test_calculate_boundary_trend_inner_right

Flake rate in main: 82.76% (Passed 5 times, Failed 24 times)

Stack Traces | 0.054s run time
test_ts = <xarray.DataArray 'test_ts' (time: 74)> Size: 592B
array([        nan,         nan,         nan,         nan,  6.     ...Coordinates:
  * time      (time) datetime64[us] 592B 1952-01-01 1953-01-01 ... 2025-01-01
    category  <U4 16B 'test'
fit_params_linear = FitParameters(fit_degree=1, fallback_degree=0, trend_length=10, trend_length_unit='YS', min_trend_points=5)
fit_params_constant = FitParameters(fit_degree=0, fallback_degree=0, trend_length=10, trend_length_unit='YS', min_trend_points=5)
caplog = <_pytest.logging.LogCaptureFixture object at 0x7f2a0d2dfc90>

    def test_calculate_boundary_trend_inner_right(
        test_ts, fit_params_linear, fit_params_constant, caplog
    ):
        gaps = get_gaps(test_ts)
    
        # linear trend for a right boundary
        fit_degree = 1
        # expected result
        data_to_interpolate = test_ts.pr.loc[{"time": slice("1956", "1965")}].data
        coeff = np.polyfit(range(0, 10), data_to_interpolate, deg=fit_degree)
        expected_value = np.polyval(coeff, 0)
    
        trend_value = calculate_boundary_trend_inner(
            test_ts,
            side="right",
            boundary=gaps[0].right,
            fit_params=fit_params_linear,
        )
    
        assert np.allclose(expected_value, trend_value, rtol=1e-04)
    
        # constant trend for a right boundary
        fit_degree = 0
        # expected result
        coeff = np.polyfit(range(0, 10), data_to_interpolate, deg=fit_degree)
        expected_value = np.polyval(coeff, 0)
    
        trend_value = calculate_boundary_trend_inner(
            test_ts,
            side="right",
            boundary=gaps[0].right,
            fit_params=fit_params_constant,
        )
    
        assert np.allclose(expected_value, trend_value, rtol=1e-04)
    
        # test logging if not enough data points
        test_ts.loc[{"time": slice("1958", "1964")}] = (test_ts.loc)[
            {"time": slice("1958", "1964")}
        ] * np.nan
        trend_value = calculate_boundary_trend_inner(
            test_ts,
            side="right",
            boundary=gaps[0].right,
            fit_params=fit_params_linear,
        )
        assert np.isnan(trend_value)
    
        log_str = (
            "Not enough values to calculate fit for right boundary at "
            "1956-01-01T00:00:00.000000000.\nfit_degree: 1, trend_length: 10, "
            "trend_length_unit: YS, min_trend_points: 5.\nTimeseries info: "
            "{'category': 'test'}"
        )
    
>       assert log_str in caplog.text
E       assert "Not enough values to calculate fit for right boundary at 1956-01-01T00:00:00.000000000.\nfit_degree: 1, trend_length: 10, trend_length_unit: YS, min_trend_points: 5.\nTimeseries info: {'category': 'test'}" in "INFO     primap2.csg._strategies.gaps:gaps.py:328 Not enough values to calculate fit for right boundary at 1956-01-01...t_degree: 1, trend_length: 10, trend_length_unit: YS, min_trend_points: 5.\nTimeseries info: {'category': 'test'} {}\n"
E        +  where "INFO     primap2.csg._strategies.gaps:gaps.py:328 Not enough values to calculate fit for right boundary at 1956-01-01...t_degree: 1, trend_length: 10, trend_length_unit: YS, min_trend_points: 5.\nTimeseries info: {'category': 'test'} {}\n" = <_pytest.logging.LogCaptureFixture object at 0x7f2a0d2dfc90>.text

.../tests/csg/test_gaps.py:310: AssertionError
primap2/tests/csg/test_gaps.py::test_calculate_scaling_factor

Flake rate in main: 82.76% (Passed 5 times, Failed 24 times)

Stack Traces | 0.095s run time
test_ts = <xarray.DataArray 'test_ts' (time: 74)> Size: 592B
array([        nan,         nan,         nan,         nan,  6.     ...Coordinates:
  * time      (time) datetime64[us] 592B 1952-01-01 1953-01-01 ... 2025-01-01
    category  <U4 16B 'test'
fill_ts = <xarray.DataArray 'test_ts' (time: 74)> Size: 592B
array([ 7.        ,  6.66666667,  6.33333333,  6.        , 18.     ...Coordinates:
  * time      (time) datetime64[us] 592B 1952-01-01 1953-01-01 ... 2025-01-01
    category  <U4 16B 'test'
fit_params_linear = FitParameters(fit_degree=1, fallback_degree=0, trend_length=10, trend_length_unit='YS', min_trend_points=5)
caplog = <_pytest.logging.LogCaptureFixture object at 0x7f2a0d4909d0>

    def test_calculate_scaling_factor(test_ts, fill_ts, fit_params_linear, caplog):
        gaps = get_gaps(test_ts)
    
        factor = calculate_scaling_factor(
            ts=test_ts, fill_ts=fill_ts, fit_params=fit_params_linear, gap=gaps[2]
        )
        assert np.allclose([0.33333, 1], factor)
        # as fallback will be used we also check for the log message (not strictly necessary
        # to test his as it's raise by a different function)
>       assert (
            "Not enough values to calculate fit for right boundary "
            "at 1973-01-01T00:00:00.000000000.\nfit_degree: 1, trend_length: 10, "
            "trend_length_unit: YS, min_trend_points: 5.\n"
            "Timeseries info: {'category': 'test'}" in caplog.text
        )
E       assert "Not enough values to calculate fit for right boundary at 1973-01-01T00:00:00.000000000.\nfit_degree: 1, trend_length: 10, trend_length_unit: YS, min_trend_points: 5.\nTimeseries info: {'category': 'test'}" in "INFO     primap2.csg._strategies.gaps:gaps.py:328 Not enough values to calculate fit for right boundary at 1973-01-01...t_degree: 1, trend_length: 10, trend_length_unit: YS, min_trend_points: 5.\nTimeseries info: {'category': 'test'} {}\n"
E        +  where "INFO     primap2.csg._strategies.gaps:gaps.py:328 Not enough values to calculate fit for right boundary at 1973-01-01...t_degree: 1, trend_length: 10, trend_length_unit: YS, min_trend_points: 5.\nTimeseries info: {'category': 'test'} {}\n" = <_pytest.logging.LogCaptureFixture object at 0x7f2a0d4909d0>.text

.../tests/csg/test_gaps.py:428: AssertionError

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

@pre-commit-ci
pre-commit-ci Bot force-pushed the pre-commit-ci-update-config branch from e9596d2 to 5c24459 Compare June 8, 2026 18:50
@pre-commit-ci
pre-commit-ci Bot force-pushed the pre-commit-ci-update-config branch from 5c24459 to a12a274 Compare June 15, 2026 18:54
@pre-commit-ci
pre-commit-ci Bot force-pushed the pre-commit-ci-update-config branch 2 times, most recently from 8f6f331 to a8de9b2 Compare June 29, 2026 18:50
updates:
- [github.com/astral-sh/ruff-pre-commit: v0.15.14 → v0.15.21](astral-sh/ruff-pre-commit@v0.15.14...v0.15.21)
@pre-commit-ci
pre-commit-ci Bot force-pushed the pre-commit-ci-update-config branch from a8de9b2 to 6491d1b Compare July 13, 2026 19:25
@mikapfl
mikapfl merged commit 0db425a into main Jul 14, 2026
2 of 12 checks passed
@mikapfl
mikapfl deleted the pre-commit-ci-update-config branch July 14, 2026 07:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant