From 2efc97028400c8436091aecb766cb10624c321e2 Mon Sep 17 00:00:00 2001 From: Dmitry Ustalov Date: Sat, 24 Aug 2024 23:08:03 +0200 Subject: [PATCH] Update order of arguments --- python/evalica/__init__.py | 24 ++++++++++++------------ python/evalica/evalica.pyi | 4 ++-- python/evalica/naive.py | 4 ++-- python/evalica/test_evalica.py | 12 ++++++------ src/elo.rs | 4 ++-- src/python.rs | 8 ++++---- 6 files changed, 28 insertions(+), 28 deletions(-) diff --git a/python/evalica/__init__.py b/python/evalica/__init__.py index 8d6c6ca..6065d2c 100644 --- a/python/evalica/__init__.py +++ b/python/evalica/__init__.py @@ -483,24 +483,24 @@ class EloResult(Generic[T]): Attributes: scores: The element scores. index: The index. - win_weight: The win weight. - tie_weight: The tie weight. initial: The initial score of each element. base: The base of the exponent. scale: The scale factor. k: The K-factor. + win_weight: The win weight. + tie_weight: The tie weight. solver: The solver. """ scores: pd.Series[float] index: dict[T, int] - win_weight: float - tie_weight: float initial: float base: float scale: float k: float + win_weight: float + tie_weight: float solver: str @@ -509,12 +509,12 @@ def elo( ys: Collection[T], ws: Collection[Winner], index: dict[T, int] | None = None, - win_weight: float = 1.0, - tie_weight: float = 0.5, initial: float = 1000., base: float = 10., scale: float = 400., k: float = 4., + win_weight: float = 1.0, + tie_weight: float = 0.5, solver: Literal["naive", "pyo3"] = "pyo3", ) -> EloResult[T]: """ @@ -528,12 +528,12 @@ def elo( ys: The right-hand side elements. ws: The winner elements. index: The index. - win_weight: The win weight. - tie_weight: The tie weight. initial: The initial score of each element. base: The base of the exponent. scale: The scale factor. k: The K-factor. + win_weight: The win weight. + tie_weight: The tie weight. solver: The solver. Returns: @@ -545,19 +545,19 @@ def elo( assert index is not None, "index is None" if solver == "pyo3": - scores = elo_pyo3(xs_indexed, ys_indexed, ws, len(index), win_weight, tie_weight, initial, base, scale, k) + scores = elo_pyo3(xs_indexed, ys_indexed, ws, len(index), initial, base, scale, k, win_weight, tie_weight) else: - scores = elo_naive(xs_indexed, ys_indexed, ws, len(index), win_weight, tie_weight, initial, base, scale, k) + scores = elo_naive(xs_indexed, ys_indexed, ws, len(index), initial, base, scale, k, win_weight, tie_weight) return EloResult( scores=pd.Series(scores, index=index, name=elo.__name__).sort_values(ascending=False, kind="stable"), index=index, - win_weight=win_weight, - tie_weight=tie_weight, initial=initial, base=base, scale=scale, k=k, + win_weight=win_weight, + tie_weight=tie_weight, solver=solver, ) diff --git a/python/evalica/evalica.pyi b/python/evalica/evalica.pyi index 8dc5fab..deda549 100644 --- a/python/evalica/evalica.pyi +++ b/python/evalica/evalica.pyi @@ -83,12 +83,12 @@ def elo_pyo3( ys: npt.ArrayLike, ws: Collection[Winner], total: int, - win_weight: float, - tie_weight: float, initial: float, base: float, scale: float, k: float, + win_weight: float, + tie_weight: float, ) -> npt.NDArray[np.float64]: ... diff --git a/python/evalica/naive.py b/python/evalica/naive.py index 0bf6ec8..c2db19f 100644 --- a/python/evalica/naive.py +++ b/python/evalica/naive.py @@ -143,12 +143,12 @@ def elo( ys: Collection[int], ws: Collection[Winner], total: int, - win_weight: float = 1.0, - tie_weight: float = 0.5, initial: float = 1000., base: float = 10., scale: float = 400., k: float = 30., + win_weight: float = 1.0, + tie_weight: float = 0.5, ) -> npt.NDArray[np.float64]: if len(xs) != len(ys) or len(xs) != len(ws) or len(ys) != len(ws): raise LengthMismatchError diff --git a/python/evalica/test_evalica.py b/python/evalica/test_evalica.py index 4cb431b..3019618 100644 --- a/python/evalica/test_evalica.py +++ b/python/evalica/test_evalica.py @@ -207,12 +207,12 @@ def test_newman(comparison: Comparison, v_init: float) -> None: @given( comparison=comparisons(), - win_weight=st.floats(0., 10.), - tie_weight=st.floats(0., 10.), initial=st.floats(0., 1000.), base=st.floats(0., 1000.), scale=st.floats(0., 1000.), k=st.floats(0., 1000.), + win_weight=st.floats(0., 10.), + tie_weight=st.floats(0., 10.), ) def test_elo( comparison: Comparison, @@ -227,23 +227,23 @@ def test_elo( result_pyo3 = evalica.elo( xs, ys, ws, - win_weight=win_weight, - tie_weight=tie_weight, initial=initial, base=base, scale=scale, k=k, + win_weight=win_weight, + tie_weight=tie_weight, solver="pyo3", ) result_naive = evalica.elo( xs, ys, ws, - win_weight=win_weight, - tie_weight=tie_weight, initial=initial, base=base, scale=scale, k=k, + win_weight=win_weight, + tie_weight=tie_weight, solver="naive", ) diff --git a/src/elo.rs b/src/elo.rs index a9427b7..4bd90c6 100644 --- a/src/elo.rs +++ b/src/elo.rs @@ -10,12 +10,12 @@ pub fn elo( ys: &ArrayView1, ws: &ArrayView1, total: usize, - win_weight: A, - tie_weight: A, initial: A, base: A, scale: A, k: A, + win_weight: A, + tie_weight: A, ) -> Result, ShapeError> { check_lengths!(xs.len(), ys.len(), ws.len()); diff --git a/src/python.rs b/src/python.rs index 5441d61..1f47240 100644 --- a/src/python.rs +++ b/src/python.rs @@ -195,24 +195,24 @@ fn elo_pyo3<'py>( ys: PyArrayLike1<'py, usize>, ws: PyArrayLike1<'py, Winner>, total: usize, - win_weight: f64, - tie_weight: f64, initial: f64, base: f64, scale: f64, k: f64, + win_weight: f64, + tie_weight: f64, ) -> PyResult>> { match elo( &xs.as_array(), &ys.as_array(), &ws.as_array(), total, - win_weight, - tie_weight, initial, base, scale, k, + win_weight, + tie_weight, ) { Ok(scores) => Ok(scores.into_pyarray_bound(py).unbind()), Err(_) => Err(LengthMismatchError::new_err("mismatching input shapes")),