astropy / astropy/astropy

NDArithmetic API for propagating uncertainties counter-intuitive

Open
#14,404 8 comments 0 reactions 0 assignees View on GitHub
Feature Request nddata
Dominant language
Python
Stars
5.3k
Forks
2.2k
Avg merge
1d 18h
Merged PRs (30d)
74

Description

### What is the problem this feature will solve?

The API for propagating uncertainties via `NDArihtmetic` is to set the `propagate_uncertainties` kwarg to `None`, `True`, or `False`. `None` causes uncertainties to be dropped and `True` causes them to be propagated. While one would expect that `False` would also cause uncertainties to be dropped, it in fact causes the uncertainties from the first operand found with non-`None` uncertainty to be kept without alteration.

This API becomes more confusing in light of #14175 and [ndcube #450](https://github.com/sunpy/ndcube/pull/450) which collapse cube axes and rebin, respectively via some operation, e.g. mean, max, etc. These new features perform arithmetic operations between elements within the same cube and so keeping the first found uncertainty makes no physical sense.

### Describe the desired outcome

The proposed solution is a breaking API change: deprecate the first-found behaviour to be triggered by `propagate_uncertainties="first found"` and make `propagate_uncertainties=False` drop uncertainties.

As a first step, `"first_found"` can be introduced as a valid kwarg value and if `False` is provided, a deprecation warning can be raised and the kwarg value internally can be changed to `"first found"`. After the deprecation period, `propagate_uncertainties=False` will return the same behaviour that `propagate_uncertainties=None` currently does.

### Additional context

_No response_

Contributor guide

Open the contributing guide

Research direction

Start by locating the NDArithmetic implementation and its tests, then trace how the propagate_uncertainties keyword accepts None, True, and False. Add support for the proposed "first found" value and the deprecation behavior for False; done means the transition is covered by tests without changing the current behavior prematurely.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.