Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions pymc/distributions/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import warnings

from functools import singledispatch

import numpy as np
Expand Down Expand Up @@ -123,6 +125,14 @@ class SumTo1(Transform):

name = "sumto1"

def __init__(self):
warnings.warn(
"SumTo1 is deprecated and will be removed in a future version. "
"Use the Simplex transform instead.",
FutureWarning,
stacklevel=2,
)

def backward(self, value, *inputs):
remaining = 1 - pt.sum(value[..., :], axis=-1, keepdims=True)
return pt.concatenate([value[..., :], remaining], axis=-1)
Expand Down
5 changes: 5 additions & 0 deletions tests/distributions/test_transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,11 @@ def test_sum_to_1():
)


def test_sum_to_1_deprecation_warning():
with pytest.warns(FutureWarning, match="SumTo1 is deprecated"):
tr.SumTo1()


def test_log():
check_transform(tr.log, Rplusbig)

Expand Down