From 3e40b182a40bfe9544ca77608073782785d93ce6 Mon Sep 17 00:00:00 2001 From: Dmitry Ustalov Date: Mon, 17 Jun 2024 23:08:25 +0200 Subject: [PATCH] Add __version__ --- python/evalica/__init__.py | 4 ++-- python/evalica/evalica.pyi | 2 ++ python/evalica/tests.py | 6 ++++++ src/lib.rs | 3 ++- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/python/evalica/__init__.py b/python/evalica/__init__.py index 9ada907..b15a19b 100644 --- a/python/evalica/__init__.py +++ b/python/evalica/__init__.py @@ -1,3 +1,3 @@ -from .evalica import py_bradley_terry as bradley_terry, py_newman as newman +from .evalica import __version__, py_bradley_terry as bradley_terry, py_newman as newman -__all__ = ['bradley_terry', 'newman'] +__all__ = ['__version__', 'bradley_terry', 'newman'] diff --git a/python/evalica/evalica.pyi b/python/evalica/evalica.pyi index 49896ef..aac9efa 100644 --- a/python/evalica/evalica.pyi +++ b/python/evalica/evalica.pyi @@ -3,6 +3,8 @@ from typing import Tuple import numpy as np import numpy.typing as npt +__version__: str = ... + def py_bradley_terry( m: npt.NDArray[np.int64] ) -> Tuple[npt.NDArray[np.float64], int]: ... diff --git a/python/evalica/tests.py b/python/evalica/tests.py index 39c8f03..2413791 100644 --- a/python/evalica/tests.py +++ b/python/evalica/tests.py @@ -8,6 +8,12 @@ import evalica +class TestMeta(unittest.TestCase): + def test_version(self) -> None: + self.assertIsInstance(evalica.__version__, str) + self.assertGreater(len(evalica.__version__), 0) + + class TestUnordered(unittest.TestCase): def setUp(self) -> None: self.M: npt.NDArray[np.int64] = np.array([ diff --git a/src/lib.rs b/src/lib.rs index 8c840ef..111105d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,5 +1,5 @@ -use numpy::{IntoPyArray, PyArray1, PyArray2}; use numpy::PyArrayMethods; +use numpy::{IntoPyArray, PyArray1, PyArray2}; use pyo3::prelude::*; mod bradley_terry; @@ -27,6 +27,7 @@ fn py_newman( #[pymodule] fn evalica(m: &Bound<'_, PyModule>) -> PyResult<()> { + m.add("__version__", env!("CARGO_PKG_VERSION"))?; m.add_function(wrap_pyfunction!(py_bradley_terry, m)?)?; m.add_function(wrap_pyfunction!(py_newman, m)?)?; Ok(())