Skip to content

[TEST] Reduce pytest warnings #840

@genedan

Description

@genedan

Are you on the latest chainladder version?

  • Yes, this bug occurs on the latest version.

Describe the bug in words

It's looking like our push towards 1.0 is turning into a giant tech debt reduction exercise. I might as well add getting the number of pytest warnings down.

This issue is an open call to all contributors to have at it and see what they can knock down, and governs the overall subject of pytest warnings for the 1.0 release. If you do identify something you can fix, please create a sub-issue and ask to be assigned to it. That way you can receive credit for closing an issue via a PR.

How can the bug be reproduced?

Run uv run pytest.

=============================================================================================================================== test session starts ================================================================================================================================
platform linux -- Python 3.14.4, pytest-9.0.3, pluggy-1.6.0
rootdir: /home/ubuntu/Repos/chainladder-python
configfile: pyproject.toml
testpaths: chainladder, docs/_ext
plugins: nbmake-1.5.5, cov-7.0.0, xdist-3.8.0
collected 723 items                                                                                                                                                                                                                                                                

chainladder/adjustments/tests/test_berqsherm.py ..                                                                                                                                                                                                                           [  0%]
chainladder/adjustments/tests/test_bootstrap.py ...                                                                                                                                                                                                                          [  0%]
chainladder/adjustments/tests/test_parallelogram.py .......                                                                                                                                                                                                                  [  1%]
chainladder/adjustments/tests/test_trend.py ....                                                                                                                                                                                                                             [  2%]
chainladder/core/tests/test_arithmetic.py ....................xx....                                                                                                                                                                                                         [  5%]
chainladder/core/tests/test_correlation.py .....                                                                                                                                                                                                                             [  6%]
chainladder/core/tests/test_display.py ...........................                                                                                                                                                                                                           [ 10%]
chainladder/core/tests/test_grain.py ..............................................................................................................                                                                                                                          [ 25%]
chainladder/core/tests/test_slicing.py ..............................x..                                                                                                                                                                                                     [ 30%]
chainladder/core/tests/test_triangle.py ....................................................................................................xxxxxxxx...........................................                                                                              [ 50%]
chainladder/development/tests/test_barnzehn.py ....                                                                                                                                                                                                                          [ 51%]
chainladder/development/tests/test_constant.py ........                                                                                                                                                                                                                      [ 52%]
chainladder/development/tests/test_development.py ...............................x...........                                                                                                                                                                                [ 58%]
chainladder/development/tests/test_glm.py ....                                                                                                                                                                                                                               [ 59%]
chainladder/development/tests/test_incremental.py ...                                                                                                                                                                                                                        [ 59%]
chainladder/development/tests/test_learning.py .....                                                                                                                                                                                                                         [ 60%]
chainladder/development/tests/test_munich.py ..                                                                                                                                                                                                                              [ 60%]
chainladder/development/tests/test_outstanding.py ..                                                                                                                                                                                                                         [ 60%]
chainladder/methods/tests/test_benktander.py ...........                                                                                                                                                                                                                     [ 62%]
chainladder/methods/tests/test_capecod.py .......                                                                                                                                                                                                                            [ 63%]
chainladder/methods/tests/test_mack.py ..                                                                                                                                                                                                                                    [ 63%]
chainladder/methods/tests/test_predict.py .................                                                                                                                                                                                                                  [ 65%]
chainladder/tails/tests/test_bondy.py .                                                                                                                                                                                                                                      [ 65%]
chainladder/tails/tests/test_constant.py ..                                                                                                                                                                                                                                  [ 66%]
chainladder/tails/tests/test_exponential.py ...                                                                                                                                                                                                                              [ 66%]
chainladder/utils/tests/test_sparse.py .......                                                                                                                                                                                                                               [ 67%]
chainladder/utils/tests/test_utilities.py ........................                                                                                                                                                                                                           [ 70%]
chainladder/workflow/tests/test_predict.py .                                                                                                                                                                                                                                 [ 71%]
chainladder/workflow/tests/test_voting.py ..............                                                                                                                                                                                                                     [ 73%]
chainladder/workflow/tests/test_workflow.py ..................................................................................................................................................................................................                               [ 99%]
docs/_ext/tests/test_ext_linkcode.py .                                                                                                                                                                                                                                       [100%]

================================================================================================================================= warnings summary =================================================================================================================================
chainladder/adjustments/tests/test_bootstrap.py::test_bs_sample[normal_run]
chainladder/adjustments/tests/test_bootstrap.py::test_bs_sample[sparse_only_run]
  /home/ubuntu/Repos/chainladder-python/chainladder/core/pandas.py:525: RuntimeWarning: Mean of empty slice
    obj.values = func(obj.values, axis=axis, *args, **kwargs)

chainladder/core/tests/test_arithmetic.py: 2 warnings
chainladder/core/tests/test_grain.py: 9 warnings
chainladder/core/tests/test_triangle.py: 12 warnings
chainladder/development/tests/test_development.py: 2 warnings
chainladder/methods/tests/test_benktander.py: 2 warnings
chainladder/tails/tests/test_constant.py: 2 warnings
chainladder/utils/tests/test_utilities.py: 3 warnings
  /home/ubuntu/Repos/chainladder-python/chainladder/core/base.py:379: UserWarning: Could not infer format, so each element will be parsed individually, falling back to `dateutil`. To ensure parsing is consistent and as-expected, please specify a format.
    datetime_mapping = dict(zip(datetime_arg, pd.to_datetime(**date_inference)))

chainladder/core/tests/test_grain.py::test_commutative[normal_run]
chainladder/core/tests/test_grain.py::test_commutative[sparse_only_run]
chainladder/utils/tests/test_utilities.py::test_json_subtri[normal_run]
  /home/ubuntu/Repos/chainladder-python/chainladder/core/pandas.py:525: RuntimeWarning: All-NaN slice encountered
    obj.values = func(obj.values, axis=axis, *args, **kwargs)

chainladder/core/tests/test_triangle.py::test_quantile_vs_median[normal_run]
chainladder/core/tests/test_triangle.py::test_quantile_vs_median[sparse_only_run]
  /home/ubuntu/Repos/chainladder-python/.venv/lib/python3.14/site-packages/numpy/lib/_nanfunctions_impl.py:1617: RuntimeWarning: All-NaN slice encountered
    return fnb._ureduce(a,

chainladder/core/tests/test_triangle.py::test_quantile_vs_median[normal_run]
chainladder/core/tests/test_triangle.py::test_quantile_vs_median[sparse_only_run]
  /home/ubuntu/Repos/chainladder-python/.venv/lib/python3.14/site-packages/numpy/lib/_nanfunctions_impl.py:1216: RuntimeWarning: All-NaN slice encountered
    return fnb._ureduce(a, func=_nanmedian, keepdims=keepdims,

chainladder/core/tests/test_triangle.py: 17 warnings
  /home/ubuntu/Repos/chainladder-python/chainladder/core/triangle.py:473: UserWarning: 
                  The cumulative property of your triangle is not set. This may result in
                  undesirable behavior. In a future release this will result in an error.
                  
    warnings.warn(

chainladder/core/tests/test_triangle.py: 2 warnings
chainladder/workflow/tests/test_voting.py: 60 warnings
  /home/ubuntu/Repos/chainladder-python/chainladder/utils/weighted_regression.py:103: RuntimeWarning: invalid value encountered in sqrt
    residual = (y - fitted_value) * xp.sqrt(w)

chainladder/core/tests/test_triangle.py::test_latest_diagonal_vs_full_tri_clrd[normal_run]
chainladder/core/tests/test_triangle.py::test_latest_diagonal_vs_full_tri_clrd[sparse_only_run]
  /home/ubuntu/Repos/chainladder-python/chainladder/utils/weighted_regression.py:110: RuntimeWarning: invalid value encountered in sqrt
    std_err = xp.sqrt(mse / denominator)

chainladder/core/tests/test_triangle.py::test_latest_diagonal_vs_full_tri_clrd[normal_run]
chainladder/core/tests/test_triangle.py::test_latest_diagonal_vs_full_tri_clrd[sparse_only_run]
  /home/ubuntu/Repos/chainladder-python/chainladder/utils/weighted_regression.py:190: RuntimeWarning: overflow encountered in exp
    fill_ = xp.exp(reg.x * slope + intercept) * (1 - w)

chainladder/core/tests/test_triangle.py: 2 warnings
chainladder/workflow/tests/test_voting.py: 60 warnings
  /home/ubuntu/Repos/chainladder-python/chainladder/utils/weighted_regression.py:176: RuntimeWarning: invalid value encountered in sqrt
    / xp.swapaxes(xp.sqrt(self.x ** (2 - self.exponent_))[..., 0:1, :], -1, -2)

chainladder/core/tests/test_triangle.py::test_latest_diagonal_vs_full_tri_clrd[normal_run]
chainladder/core/tests/test_triangle.py::test_latest_diagonal_vs_full_tri_clrd[sparse_only_run]
  /home/ubuntu/Repos/chainladder-python/chainladder/core/dunders.py:330: RuntimeWarning: overflow encountered in square
    obj.values = xp.nan_to_num(obj.values) ** other

chainladder/core/tests/test_triangle.py: 2 warnings
chainladder/workflow/tests/test_voting.py: 60 warnings
  /home/ubuntu/Repos/chainladder-python/chainladder/development/development.py:202: RuntimeWarning: invalid value encountered in sqrt
    std = xp.sqrt((1 / num_to_nan(w_reg)) * (self.sigma_**2).values)

chainladder/core/tests/test_triangle.py: 2 warnings
chainladder/workflow/tests/test_voting.py: 60 warnings
  /home/ubuntu/Repos/chainladder-python/chainladder/tails/base.py:120: RuntimeWarning: overflow encountered in exp
    sigma_ = xp.exp(time_pd * reg.slope_ + reg.intercept_)

chainladder/core/tests/test_triangle.py: 2 warnings
chainladder/workflow/tests/test_voting.py: 60 warnings
  /home/ubuntu/Repos/chainladder-python/chainladder/tails/base.py:124: RuntimeWarning: overflow encountered in exp
    std_err_ = xp.exp(time_pd * reg.slope_ + reg.intercept_)

chainladder/core/tests/test_triangle.py: 2 warnings
chainladder/workflow/tests/test_voting.py: 60 warnings
  /home/ubuntu/Repos/chainladder-python/chainladder/tails/base.py:127: RuntimeWarning: invalid value encountered in multiply
    sigma_ = sigma_ * 0

chainladder/core/tests/test_triangle.py: 2 warnings
chainladder/workflow/tests/test_voting.py: 60 warnings
  /home/ubuntu/Repos/chainladder-python/chainladder/tails/base.py:128: RuntimeWarning: invalid value encountered in multiply
    std_err_ = std_err_* 0

chainladder/development/tests/test_development.py: 12 warnings
  /home/ubuntu/Repos/chainladder-python/chainladder/development/base.py:652: UserWarning: Some exclusions have been ignored. At least 1 (use preserve = ...) link ratio(s) is required for development estimation.
    warnings.warn(warning)

chainladder/development/tests/test_development.py: 10 warnings
  /home/ubuntu/Repos/chainladder-python/chainladder/development/base.py:272: UserWarning: Some exclusions have been ignored. At least 1 (use preserve = ...) link ratio(s) is required for development estimation.
    warnings.warn(warning)

chainladder/development/tests/test_development.py::test_dropabovebelow
chainladder/development/tests/test_development.py::test_dropabovebelow
chainladder/development/tests/test_development.py::test_dropabovebelow
chainladder/development/tests/test_development.py::test_new_drop_6[normal_run]
chainladder/development/tests/test_development.py::test_new_drop_6[normal_run]
chainladder/development/tests/test_development.py::test_new_drop_6[sparse_only_run]
chainladder/development/tests/test_development.py::test_new_drop_6[sparse_only_run]
  /home/ubuntu/Repos/chainladder-python/chainladder/development/base.py:573: UserWarning: Some exclusions have been ignored. At least 1 (use preserve = ...) link ratio(s) is required for development estimation.
    warnings.warn(warning)

chainladder/development/tests/test_development.py::test_dropabovebelow
chainladder/development/tests/test_development.py::test_dropabovebelow
chainladder/development/tests/test_development.py::test_dropabovebelow
chainladder/development/tests/test_development.py::test_new_drop_6[normal_run]
chainladder/development/tests/test_development.py::test_new_drop_6[sparse_only_run]
  /home/ubuntu/Repos/chainladder-python/chainladder/development/base.py:355: UserWarning: Some exclusions have been ignored. At least 1 (use preserve = ...) link ratio(s) is required for development estimation.
    warnings.warn(warning)

chainladder/development/tests/test_development.py::test_assymetric_development
chainladder/development/tests/test_development.py::test_assymetric_development
  /home/ubuntu/Repos/chainladder-python/chainladder/development/development.py:187: UserWarning: Setting n_periods=1 does not allow enough degrees of freedom to support calculation of all regression statistics. Only LDFs have been calculated.
    warnings.warn(

chainladder/development/tests/test_development.py::test_new_drop_5[normal_run]
chainladder/development/tests/test_development.py::test_new_drop_5[sparse_only_run]
  /home/ubuntu/Repos/chainladder-python/chainladder/development/base.py:652: UserWarning: Some exclusions have been ignored. At least 3 link ratio(s) is required for development estimation.
    warnings.warn(warning)

chainladder/development/tests/test_development.py::test_new_drop_7[normal_run]
chainladder/development/tests/test_development.py::test_new_drop_7[sparse_only_run]
  /home/ubuntu/Repos/chainladder-python/chainladder/development/base.py:573: UserWarning: Some exclusions have been ignored. At least 3 link ratio(s) is required for development estimation.
    warnings.warn(warning)

chainladder/methods/tests/test_capecod.py::test_capecod_zero_tri[normal_run]
chainladder/methods/tests/test_capecod.py::test_capecod_zero_tri[normal_run]
chainladder/methods/tests/test_capecod.py::test_capecod_zero_tri[normal_run]
chainladder/methods/tests/test_capecod.py::test_capecod_zero_tri[normal_run]
chainladder/methods/tests/test_capecod.py::test_capecod_zero_tri[sparse_only_run]
chainladder/methods/tests/test_capecod.py::test_capecod_zero_tri[sparse_only_run]
chainladder/methods/tests/test_capecod.py::test_capecod_zero_tri[sparse_only_run]
chainladder/methods/tests/test_capecod.py::test_capecod_zero_tri[sparse_only_run]
  /home/ubuntu/Repos/chainladder-python/chainladder/core/dunders.py:361: RuntimeWarning: divide by zero encountered in divide
    obj.values = other / self.values

chainladder/workflow/tests/test_workflow.py: 288 warnings
  /home/ubuntu/Repos/chainladder-python/chainladder/methods/base.py:160: UserWarning: X and sample_weight are not aligned. Broadcasting may occur.
  
    warnings.warn(

chainladder/workflow/tests/test_workflow.py: 24 warnings
  /home/ubuntu/Repos/chainladder-python/.venv/lib/python3.14/site-packages/numpy/_core/fromnumeric.py:86: RuntimeWarning: overflow encountered in reduce
    return ufunc.reduce(obj, axis, dtype, out, **passkwargs)

chainladder/workflow/tests/test_workflow.py: 144 warnings
  /home/ubuntu/Repos/chainladder-python/.venv/lib/python3.14/site-packages/numpy/_core/fromnumeric.py:57: RuntimeWarning: overflow encountered in accumulate
    return bound(*args, **kwds)

chainladder/workflow/tests/test_workflow.py: 60 warnings
  /home/ubuntu/Repos/chainladder-python/chainladder/core/slice.py:262: RuntimeWarning: invalid value encountered in multiply
    obj.values = num_to_nan(obj.values * obj.get_array_module().array(key))

chainladder/workflow/tests/test_workflow.py: 24 warnings
  /home/ubuntu/Repos/chainladder-python/chainladder/tails/base.py:151: RuntimeWarning: invalid value encountered in log
    time_pd = (xp.log(tail - 1) - reg.intercept_) / reg.slope_

chainladder/workflow/tests/test_workflow.py: 12 warnings
  /home/ubuntu/Repos/chainladder-python/chainladder/methods/capecod.py:255: RuntimeWarning: divide by zero encountered in divide
    trended_ultimate = (latest.values * trend_array * X_olf_array) / (

chainladder/workflow/tests/test_workflow.py: 12 warnings
  /home/ubuntu/Repos/chainladder-python/chainladder/methods/capecod.py:259: RuntimeWarning: invalid value encountered in multiply
    apriori = xp.nansum(weighted_exposure * trended_ultimate, -1) / xp.nansum(

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
============================================================================================================ 711 passed, 12 xfailed, 1110 warnings in 219.67s (0:03:39) ============================================================================================================

What is the expected behavior?

Ideally, we'd get 0 warnings. First we need to find out which warnings are ones we can and can't do anything about. While there are 1110 warnings, perhaps fixing certain common causes can reduce the number dramatically.

If a warning is something we can't do anything about, we should document it in a central place (conftest.py? pytest.ini?).

Metadata

Metadata

Labels

Effort > Serious 🐘Large, complex tasks requiring a few weeks to months of work.Impact > Moderate 🔶User-visible but non-breaking change. Treated like a minor version bump (e.g., 0.6.5 → 0.7.0).

Type

No fields configured for Bug.

Projects

Status

In progress

Relationships

None yet

Development

No branches or pull requests

Issue actions