Spaces:
Running
on
CPU Upgrade
Handle accuracy data missing the spaces around +/-
Browse filesThe current leaderboard is raising a runtime error when invalid accuracy data is processed. This results in the following stack trace:
Traceback (most recent call last):
File "/home/user/app/app.py", line 292, in <module>
run_update_dataset()
File "/home/user/app/app.py", line 270, in run_update_dataset
update_leaderboard_dataset(rl_env["rl_env"], path_)
File "/home/user/app/app.py", line 212, in update_leaderboard_dataset
mean_reward, std_reward = parse_rewards(accuracy)
File "/home/user/app/app.py", line 175, in parse_rewards
mean_reward = float(parsed[0])
ValueError: could not convert string to float: '1.0000+/-0.00'
Based on this, it seems this data misses the spaces that were expected around "+/-". I updated the logic so it can handle both "+/-" and " +/- ".
I don't know if this is an acceptable change, but I thought to create a PR for it anyway since the current leaderboard is broken.
@@ -167,14 +167,13 @@ def parse_rewards(accuracy):
|
|
167 |
default_reward=-1000
|
168 |
if accuracy != None:
|
169 |
accuracy = str(accuracy)
|
170 |
-
parsed = accuracy.split('
|
171 |
-
if len(parsed)>1:
|
172 |
-
mean_reward = float(parsed[0])
|
173 |
-
std_reward = float(parsed[1])
|
174 |
-
elif len(parsed)==1: #only mean reward
|
175 |
-
mean_reward = float(parsed[0])
|
176 |
-
std_reward = float(0)
|
177 |
-
|
178 |
else:
|
179 |
mean_reward = float(default_std)
|
180 |
std_reward = float(default_reward)
|
|
|
167 |
default_reward=-1000
|
168 |
if accuracy != None:
|
169 |
accuracy = str(accuracy)
|
170 |
+
parsed = accuracy.split('+/-')
|
171 |
+
if len(parsed)>1):
|
172 |
+
mean_reward = float(parsed[0].strip())
|
173 |
+
std_reward = float(parsed[1].strip())
|
174 |
+
elif len(parsed)==1): #only mean reward
|
175 |
+
mean_reward = float(parsed[0].strip())
|
176 |
+
std_reward = float(0)
|
|
|
177 |
else:
|
178 |
mean_reward = float(default_std)
|
179 |
std_reward = float(default_reward)
|