Terry Zhuo commited on
Commit
f59915f
·
1 Parent(s): e50aaef
Files changed (1) hide show
  1. src/tools/plots.py +7 -5
src/tools/plots.py CHANGED
@@ -26,18 +26,20 @@ def plot_solve_rate(df, task, rows=30, cols=38):
26
  n = len(values)
27
  pad_width = rows * cols - n
28
 
29
- # Use masked array to handle NaN values
30
- masked_values = np.ma.array(values)
31
- masked_values = np.ma.pad(masked_values, (0, pad_width), 'constant', constant_values=np.ma.masked)
 
32
  masked_values = masked_values.reshape((rows, cols))
33
 
34
- keys = np.pad(keys, (0, pad_width), 'constant', constant_values='').reshape((rows, cols))
 
35
 
36
  hover_text = np.empty_like(masked_values, dtype=object)
37
  for i in range(rows):
38
  for j in range(cols):
39
  if not masked_values.mask[i, j]:
40
- hover_text[i, j] = f"{keys[i, j]}<br>Solve Rate: {masked_values[i, j]:.2f}"
41
  else:
42
  hover_text[i, j] = "NaN"
43
 
 
26
  n = len(values)
27
  pad_width = rows * cols - n
28
 
29
+ # Create a masked array
30
+ masked_values = np.ma.array(np.full(rows * cols, np.nan), mask=True)
31
+ masked_values[:n] = values
32
+ masked_values.mask[:n] = False
33
  masked_values = masked_values.reshape((rows, cols))
34
 
35
+ keys_padded = np.pad(keys, (0, pad_width), 'constant', constant_values='')
36
+ keys_reshaped = keys_padded.reshape((rows, cols))
37
 
38
  hover_text = np.empty_like(masked_values, dtype=object)
39
  for i in range(rows):
40
  for j in range(cols):
41
  if not masked_values.mask[i, j]:
42
+ hover_text[i, j] = f"{keys_reshaped[i, j]}<br>Solve Rate: {masked_values[i, j]:.2f}"
43
  else:
44
  hover_text[i, j] = "NaN"
45