Skip to content

Commit 924ce36

Browse files
authored
Merge pull request #4 from kovalp/convert-to-builtin-int
Convert to builtin int
2 parents 276cd13 + 1d6e6d8 commit 924ce36

7 files changed

Lines changed: 22 additions & 13 deletions

File tree

.bumpversion.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[tool.bumpversion]
2-
current_version = "0.2.1"
2+
current_version = "0.3.0"
33
parse = "(?P<major>\\d+)\\.(?P<minor>\\d+)\\.(?P<patch>\\d+)"
44
serialize = ["{major}.{minor}.{patch}"]
55
search = "{current_version}"

CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
# 0.2.0
1+
# 0.3.0
22

33
- Adjustable format for the accuracy and other metrics.
44
- Using the hatchling build system to avoid complains about the `project.license` format.
5-
5+
- Enforce the initial attributes to builtin `ìnt`.
66

77
# 0.1.0
88

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "binary-classification-ratios"
3-
version = "0.2.1"
3+
version = "0.3.0"
44
description = "Binary classification ratios gathered in one package."
55
readme = "README.md"
66
requires-python = ">=3.8,<4.0"

src/binary_classification_ratios/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""."""
22

3-
__version__ = '0.2.1'
3+
__version__ = '0.3.0'
44

55
from .ratios import BinaryClassificationRatios
66

src/binary_classification_ratios/ratios.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
and summarize classification metrics such as accuracy, precision, recall, and F1-score.
44
"""
55

6-
from typing import Dict, Union
6+
from typing import Any, Dict, Union
77

88
from binary_classification_ratios.summary import BinaryClassificationSummary
99

@@ -19,12 +19,12 @@ class BinaryClassificationRatios(object):
1919
fn: Number of false negatives.
2020
"""
2121

22-
def __init__(self, *, tp: int = 0, tn: int = 0, fp: int = 0, fn: int = 0) -> None:
22+
def __init__(self, *, tp: Any = 0, tn: Any = 0, fp: Any = 0, fn: Any = 0) -> None:
2323
"""Initializes a new instance with all zero values."""
24-
self.tp = tp
25-
self.tn = tn
26-
self.fp = fp
27-
self.fn = fn
24+
self.tp = int(tp)
25+
self.tn = int(tn)
26+
self.fp = int(fp)
27+
self.fn = int(fn)
2828
self.summary = BinaryClassificationSummary()
2929

3030
def get_summary(self) -> str:

test/test_ratios.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def bcr() -> BinaryClassificationRatios:
1111
return BinaryClassificationRatios(tp=10, tn=9, fp=8, fn=7)
1212

1313

14-
def test_classification_ratios_init() -> None:
14+
def test_no_args_init() -> None:
1515
"""."""
1616
bcr = BinaryClassificationRatios()
1717
assert bcr.get_f1_score() == pytest.approx(0.0)
@@ -20,6 +20,15 @@ def test_classification_ratios_init() -> None:
2020
assert bcr.get_accuracy() == pytest.approx(0.0)
2121

2222

23+
def test_convert_to_int() -> None:
24+
"""."""
25+
bcr = BinaryClassificationRatios(tp=10.0, tn=9.0, fp=8.0, fn=7.0)
26+
assert isinstance(bcr.tp, int)
27+
assert isinstance(bcr.tn, int)
28+
assert isinstance(bcr.fp, int)
29+
assert isinstance(bcr.fn, int)
30+
31+
2332
def test_classification_ratios_meaningful(bcr: BinaryClassificationRatios) -> None:
2433
"""."""
2534
assert bcr.get_f1_score() == pytest.approx(0.5714285714285715)

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)