diff --git a/rllib/contrib/bandits/examples/LinTS_train_wheel_env.py b/rllib/contrib/bandits/examples/LinTS_train_wheel_env.py index d9ab5315a..1b3a26a96 100644 --- a/rllib/contrib/bandits/examples/LinTS_train_wheel_env.py +++ b/rllib/contrib/bandits/examples/LinTS_train_wheel_env.py @@ -10,7 +10,7 @@ from ray.rllib.contrib.bandits.envs import WheelBanditEnv def plot_model_weights(means, covs): fmts = ["bo", "ro", "yx", "k+", "gx"] - labels = [f"arm{i}" for i in range(5)] + labels = ["arm{}".format(i) for i in range(5)] fig, ax = plt.subplots(figsize=(6, 4)) diff --git a/rllib/contrib/bandits/examples/tune_LinTS_train_wheel_env.py b/rllib/contrib/bandits/examples/tune_LinTS_train_wheel_env.py index b319ba444..1b3508862 100644 --- a/rllib/contrib/bandits/examples/tune_LinTS_train_wheel_env.py +++ b/rllib/contrib/bandits/examples/tune_LinTS_train_wheel_env.py @@ -15,7 +15,7 @@ from ray.rllib.contrib.bandits.envs import WheelBanditEnv def plot_model_weights(means, covs, ax): fmts = ["bo", "ro", "yx", "k+", "gx"] - labels = [f"arm{i}" for i in range(5)] + labels = ["arm{}".format(i) for i in range(5)] ax.set_title("Weights distributions of arms") diff --git a/rllib/contrib/bandits/models/linear_regression.py b/rllib/contrib/bandits/models/linear_regression.py index 285486dbb..64c1817e2 100644 --- a/rllib/contrib/bandits/models/linear_regression.py +++ b/rllib/contrib/bandits/models/linear_regression.py @@ -85,9 +85,9 @@ class OnlineLinearRegression(nn.Module): assert x.ndim in [2, 3], \ "Input context tensor must be 2 or 3 dimensional, where the" \ " first dimension is batch size" - assert x.shape[ - 1] == self.d, f"Feature dimensions of weights ({self.d}) and " \ - f"context ({x.shape[1]}) do not match!" + assert x.shape[1] == self.d, \ + "Feature dimensions of weights ({}) and context ({}) do not " \ + "match!".format(self.d, x.shape[1]) if y: assert torch.is_tensor(y) and y.numel() == 1,\ "Target should be a tensor;" \ @@ -134,9 +134,9 @@ class DiscreteLinearModel(TorchModelV2, nn.Module): return scores def partial_fit(self, x, y, arm): - assert 0 <= arm.item() < len(self.arms),\ - f"Invalid arm: {arm.item()}." \ - f"It should be 0 <= arm < {len(self.arms)}" + assert 0 <= arm.item() < len(self.arms), \ + "Invalid arm: {}. It should be 0 <= arm < {}".format( + arm.item(), len(self.arms)) self.arms[arm].partial_fit(x, y) @override(ModelV2)