Skip to content

Commit

Permalink
Stop calling float() on single element Series (facebook#2691)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: facebook#2691

This practice was causing a deprecation warning: `Calling float on a single element Series is deprecated and will raise a TypeError in the future.`

Reviewed By: bernardbeckerman

Differential Revision: D61612829

fbshipit-source-id: 955b41b8e6b4f59be14db0363c575995e4b0b481
  • Loading branch information
mpolson64 authored and facebook-github-bot committed Aug 22, 2024
1 parent a163817 commit f90aef2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
6 changes: 4 additions & 2 deletions ax/core/tests/test_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,12 @@ def test_Data(self) -> None:

df = data.df
self.assertEqual(
float(df[df["arm_name"] == "0_0"][df["metric_name"] == "a"]["mean"]), 2.0
float(df[df["arm_name"] == "0_0"][df["metric_name"] == "a"]["mean"].item()),
2.0,
)
self.assertEqual(
float(df[df["arm_name"] == "0_1"][df["metric_name"] == "b"]["sem"]), 0.5
float(df[df["arm_name"] == "0_1"][df["metric_name"] == "b"]["sem"].item()),
0.5,
)

def test_BadData(self) -> None:
Expand Down
8 changes: 4 additions & 4 deletions ax/core/tests/test_multi_type_experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ def test_MTExperimentFlow(self) -> None:

arm_0_slice = df.loc[df["arm_name"] == "0_0"]
self.assertNotEqual(
float(arm_0_slice[df["trial_index"] == 0]["mean"]),
float(arm_0_slice[df["trial_index"] == 1]["mean"]),
float(arm_0_slice[df["trial_index"] == 0]["mean"].item()),
float(arm_0_slice[df["trial_index"] == 1]["mean"].item()),
)
self.assertEqual(len(df), 2 * n)
self.assertEqual(self.experiment.default_trials, {0})
Expand All @@ -60,8 +60,8 @@ def test_MTExperimentFlow(self) -> None:
df = self.experiment.fetch_data().df
arm_0_slice = df.loc[df["arm_name"] == "0_0"]
self.assertAlmostEqual(
float(arm_0_slice[df["trial_index"] == 0]["mean"]),
float(arm_0_slice[df["trial_index"] == 1]["mean"]),
float(arm_0_slice[df["trial_index"] == 0]["mean"].item()),
float(arm_0_slice[df["trial_index"] == 1]["mean"].item()),
places=10,
)

Expand Down

0 comments on commit f90aef2

Please sign in to comment.