Skip to content

Commit

Permalink
Remove Winner.Ignore
Browse files Browse the repository at this point in the history
  • Loading branch information
dustalov committed Aug 24, 2024
1 parent cb7e3d4 commit ac035cd
Show file tree
Hide file tree
Showing 10 changed files with 13 additions and 22 deletions.
6 changes: 3 additions & 3 deletions Chatbot-Arena.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"metadata": {},
"outputs": [],
"source": [
"!curl -LOC - 'https://storage.googleapis.com/arena_external_data/public/clean_battle_20240629_public.json'"
"!curl -LOC - 'https://storage.googleapis.com/arena_external_data/public/clean_battle_20240814_public.json'"
]
},
{
Expand Down Expand Up @@ -94,7 +94,7 @@
" \"tie\": evalica.Winner.Draw,\n",
" \"tie (bothbad)\": evalica.Winner.Draw,\n",
"})\n",
"df_arena[\"winner\"] = df_arena[\"winner\"].fillna(evalica.Winner.Ignore) # type: ignore[call-overload]\n",
"df_arena = df_arena[~df_arena[\"winner\"].isna()]\n",
"df_arena"
]
},
Expand Down Expand Up @@ -417,7 +417,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.9"
"version": "3.12.5"
}
},
"nbformat": 4,
Expand Down
1 change: 0 additions & 1 deletion python/evalica/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
Winner.X,
Winner.Y,
Winner.Draw,
Winner.Ignore,
]
"""Known values of Winner."""

Expand Down
9 changes: 4 additions & 5 deletions python/evalica/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,15 @@
}


def map_winner(winner: str) -> Winner:
return WINNERS.get(winner.lower(), Winner.Ignore)


def read_csv(f: IO[str]) -> tuple[list[str], list[str], list[Winner]]:
df_input = pd.read_csv(f, dtype=str)

df_input["winner"] = df_input["winner"].lower().map(WINNERS)
df_input = df_input[~df_input["winner"].isna()]

xs = df_input["left"].tolist()
ys = df_input["right"].tolist()
ws = df_input["winner"].apply(map_winner).tolist() # type: ignore[arg-type]
ws = df_input["winner"].tolist()

return xs, ys, ws

Expand Down
2 changes: 0 additions & 2 deletions python/evalica/evalica.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ class Winner(Enum):
"""The second element won."""
Draw = ...
"""There is a tie."""
Ignore = ...
"""The comparison should be ignored."""


class LengthMismatchError(ValueError):
Expand Down
2 changes: 1 addition & 1 deletion python/evalica/test_evalica.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ def test_misshaped(comparison: Comparison, algorithm: str, solver: str) -> None:
def test_incomplete_index(algorithm: str, solver: str) -> None:
xs = ["a", "c", "e"]
ys = ["b", "d", "f"]
ws = [evalica.Winner.X, evalica.Winner.Ignore, evalica.Winner.Y]
ws = [evalica.Winner.X, evalica.Winner.Draw, evalica.Winner.Y]

_, _, index = evalica.indexing(xs, ys)

Expand Down
1 change: 0 additions & 1 deletion src/counting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ pub fn counting<A: Num + Copy + AddAssign>(
scores[*x] += tie_weight;
scores[*y] += tie_weight;
}
_ => {}
}
}

Expand Down
1 change: 0 additions & 1 deletion src/elo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ pub fn elo<A: Float + AddAssign>(
Winner::X => (A::one(), A::zero()),
Winner::Y => (A::zero(), A::one()),
Winner::Draw => (half, half),
_ => continue,
};

scores[*x] += k * (scored_x - expected_x);
Expand Down
4 changes: 1 addition & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ pub enum Winner {
X,
Y,
Draw,
Ignore,
}

impl From<u8> for Winner {
Expand All @@ -25,7 +24,7 @@ impl From<u8> for Winner {
0 => Self::Draw,
1 => Self::X,
2 => Self::Y,
_ => Self::Ignore,
_ => panic!("Invalid value: {}", value),
}
}
}
Expand All @@ -36,7 +35,6 @@ impl Into<u8> for Winner {
Self::Draw => 0,
Self::X => 1,
Self::Y => 2,
Self::Ignore => u8::MAX,
}
}
}
2 changes: 1 addition & 1 deletion src/python.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use crate::Winner;
impl Winner {
#[new]
fn new() -> Self {
Winner::Ignore
Winner::Draw
}

fn __hash__(&self) -> u64 {
Expand Down
7 changes: 3 additions & 4 deletions src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ pub fn matrices<A: Num + Copy + AddAssign, B: Num + Copy + AddAssign>(
ties[[*x, *y]] += tie_weight;
ties[[*y, *x]] += tie_weight;
}
_ => {}
}
}

Expand Down Expand Up @@ -182,9 +181,9 @@ mod tests {

#[test]
fn test_matrices() {
let xs = array![0, 1, 2, 3];
let ys = array![1, 2, 3, 4];
let ws = array![Winner::X, Winner::Y, Winner::Draw, Winner::Ignore];
let xs = array![0, 1, 2];
let ys = array![1, 2, 3];
let ws = array![Winner::X, Winner::Y, Winner::Draw];

let expected_wins = array![
[0, 1, 0, 0, 0],
Expand Down

0 comments on commit ac035cd

Please sign in to comment.