From 692eb2574fc86da72b296fa3bb8ca3adf2b93af9 Mon Sep 17 00:00:00 2001 From: Peter Koval Date: Thu, 4 Sep 2025 15:45:54 +0200 Subject: [PATCH 1/3] + conversion to int --- src/binary_classification_ratios/ratios.py | 8 ++++---- test/test_ratios.py | 11 ++++++++++- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/binary_classification_ratios/ratios.py b/src/binary_classification_ratios/ratios.py index e5561fc..5f37b69 100644 --- a/src/binary_classification_ratios/ratios.py +++ b/src/binary_classification_ratios/ratios.py @@ -21,10 +21,10 @@ class BinaryClassificationRatios(object): def __init__(self, *, tp: int = 0, tn: int = 0, fp: int = 0, fn: int = 0) -> None: """Initializes a new instance with all zero values.""" - self.tp = tp - self.tn = tn - self.fp = fp - self.fn = fn + self.tp = int(tp) + self.tn = int(tn) + self.fp = int(fp) + self.fn = int(fn) self.summary = BinaryClassificationSummary() def get_summary(self) -> str: diff --git a/test/test_ratios.py b/test/test_ratios.py index 9d412b6..76922c2 100644 --- a/test/test_ratios.py +++ b/test/test_ratios.py @@ -11,7 +11,7 @@ def bcr() -> BinaryClassificationRatios: return BinaryClassificationRatios(tp=10, tn=9, fp=8, fn=7) -def test_classification_ratios_init() -> None: +def test_no_args_init() -> None: """.""" bcr = BinaryClassificationRatios() assert bcr.get_f1_score() == pytest.approx(0.0) @@ -20,6 +20,15 @@ def test_classification_ratios_init() -> None: assert bcr.get_accuracy() == pytest.approx(0.0) +def test_convert_to_int() -> None: + """.""" + bcr = BinaryClassificationRatios(tp=10.0, tn=9.0, fp=8.0, fn=7.0) + assert isinstance(bcr.tp, int) + assert isinstance(bcr.tn, int) + assert isinstance(bcr.fp, int) + assert isinstance(bcr.fn, int) + + def test_classification_ratios_meaningful(bcr: BinaryClassificationRatios) -> None: """.""" assert bcr.get_f1_score() == pytest.approx(0.5714285714285715) From 241dda8584df14922b903b5f1952e9ae07bb0ebe Mon Sep 17 00:00:00 2001 From: Peter Koval Date: Thu, 4 Sep 2025 15:46:32 +0200 Subject: [PATCH 2/3] =?UTF-8?q?Bump=20version:=200.2.1=20=E2=86=92=200.3.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .bumpversion.toml | 2 +- pyproject.toml | 2 +- src/binary_classification_ratios/__init__.py | 2 +- uv.lock | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.bumpversion.toml b/.bumpversion.toml index dcdd040..0916f72 100644 --- a/.bumpversion.toml +++ b/.bumpversion.toml @@ -1,5 +1,5 @@ [tool.bumpversion] -current_version = "0.2.1" +current_version = "0.3.0" parse = "(?P\\d+)\\.(?P\\d+)\\.(?P\\d+)" serialize = ["{major}.{minor}.{patch}"] search = "{current_version}" diff --git a/pyproject.toml b/pyproject.toml index ab62a2c..41ec209 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "binary-classification-ratios" -version = "0.2.1" +version = "0.3.0" description = "Binary classification ratios gathered in one package." readme = "README.md" requires-python = ">=3.8,<4.0" diff --git a/src/binary_classification_ratios/__init__.py b/src/binary_classification_ratios/__init__.py index 419aa5d..227e0ba 100644 --- a/src/binary_classification_ratios/__init__.py +++ b/src/binary_classification_ratios/__init__.py @@ -1,6 +1,6 @@ """.""" -__version__ = '0.2.1' +__version__ = '0.3.0' from .ratios import BinaryClassificationRatios diff --git a/uv.lock b/uv.lock index c28908b..6f946d2 100644 --- a/uv.lock +++ b/uv.lock @@ -33,7 +33,7 @@ wheels = [ [[package]] name = "binary-classification-ratios" -version = "0.2.1" +version = "0.3.0" source = { editable = "." } [package.dev-dependencies] From 1d6e6d8547a4017241739aa56f815c17896e84b4 Mon Sep 17 00:00:00 2001 From: Peter Koval Date: Thu, 4 Sep 2025 15:50:47 +0200 Subject: [PATCH 3/3] int -> Any --- CHANGELOG.md | 4 ++-- src/binary_classification_ratios/ratios.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 31ab6b5..588b552 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,8 @@ -# 0.2.0 +# 0.3.0 - Adjustable format for the accuracy and other metrics. - Using the hatchling build system to avoid complains about the `project.license` format. - + - Enforce the initial attributes to builtin `ìnt`. # 0.1.0 diff --git a/src/binary_classification_ratios/ratios.py b/src/binary_classification_ratios/ratios.py index 5f37b69..a05d9ac 100644 --- a/src/binary_classification_ratios/ratios.py +++ b/src/binary_classification_ratios/ratios.py @@ -3,7 +3,7 @@ and summarize classification metrics such as accuracy, precision, recall, and F1-score. """ -from typing import Dict, Union +from typing import Any, Dict, Union from binary_classification_ratios.summary import BinaryClassificationSummary @@ -19,7 +19,7 @@ class BinaryClassificationRatios(object): fn: Number of false negatives. """ - def __init__(self, *, tp: int = 0, tn: int = 0, fp: int = 0, fn: int = 0) -> None: + def __init__(self, *, tp: Any = 0, tn: Any = 0, fp: Any = 0, fn: Any = 0) -> None: """Initializes a new instance with all zero values.""" self.tp = int(tp) self.tn = int(tn)