Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow Negative Values in Media Channels #1092

Merged
merged 4 commits into from
Oct 24, 2024
Merged
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
7 changes: 5 additions & 2 deletions pymc_marketing/mmm/validating.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"""Validating methods for MMM classes."""

from collections.abc import Callable
from warnings import warn

import pandas as pd

Expand Down Expand Up @@ -116,8 +117,10 @@ def validate_channel_columns(self, data: pd.DataFrame) -> None:
f"channel_columns {self.channel_columns} contains duplicates"
)
if (data.filter(list(self.channel_columns)) < 0).any().any():
raise ValueError(
f"channel_columns {self.channel_columns} contains negative values"
warn(
f"channel_columns {self.channel_columns} contains negative values",
UserWarning,
stacklevel=2,
)


Expand Down
4 changes: 2 additions & 2 deletions tests/mmm/test_validating.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ def test_channel_columns():
):
obj.channel_columns = ["channel_1", "channel_1"]
obj.validate_channel_columns(toy_X)
with pytest.raises(
ValueError,
with pytest.warns(
UserWarning,
match=r"channel_columns \['channel_1'\] contains negative values",
):
new_toy_X = toy_X.copy()
Expand Down
Loading