Skip to content
This repository has been archived by the owner on Nov 8, 2024. It is now read-only.

Commit

Permalink
FF-3106 fix: ContextAttributes.from_dict() should not treat bool as n…
Browse files Browse the repository at this point in the history
…umeric
  • Loading branch information
rasendubi committed Aug 28, 2024
1 parent 79e5259 commit 25e5f8d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion eppo_client/bandit.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def from_dict(cls, attributes: Attributes):
numeric_attributes = {
key: float(value)
for key, value in attributes.items()
if isinstance(value, (int, float))
if isinstance(value, (int, float)) and not isinstance(value, bool)
}
categorical_attributes = {
key: to_string(value)
Expand Down
14 changes: 14 additions & 0 deletions test/context_attributes_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from eppo_client.bandit import ContextAttributes


def test_from_dict_treats_bools_as_categorical():
attrs = ContextAttributes.from_dict(
{
"categorical": True,
}
)

assert attrs.categorical_attributes == {
"categorical": "true",
}
assert attrs.numeric_attributes == {}

0 comments on commit 25e5f8d

Please sign in to comment.