Skip to content

Commit

Permalink
utilize both numpy 1.26 and 2.0
Browse files Browse the repository at this point in the history
stable Fedora is on 1.26 while rawhide already has 2.2
we need to support both

the function compute_certainty is not used in the CLI codebase but in
server

we need this to properly build detective in Fedora as an RPM

Signed-off-by: Tomas Tomecek <[email protected]>
  • Loading branch information
TomasTomecek committed Jan 6, 2025
1 parent 81ad0d1 commit 2998ed1
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
2 changes: 2 additions & 0 deletions logdetective/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ def compute_certainty(probs: List[Dict[str, float] | None]) -> float:
In this case it's just a matter of applying inverse operation exp.
Of course that leaves you with a value in range <0, 1> so it needs to be multiplied by 100.
Simply put, this is the most straightforward way to get the numbers out.
This function is used in the server codebase.
"""

top_logprobs = [
Expand Down
4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ requests = ">0.2.31"
llama-cpp-python = ">0.2.56,!=0.2.86"
drain3 = "^0.9.11"
huggingface-hub = ">0.23.2"
numpy = "^1.26.0"
# rawhide has numpy 2, F40 and F41 are still on 1.26
# we need to support both versions
numpy = ">=1.26.0"

[build-system]
requires = ["poetry-core"]
Expand Down
10 changes: 10 additions & 0 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import pytest

Check warning

Code scanning / vcs-diff-lint

Unable to import 'pytest' Warning test

Unable to import 'pytest'
from logdetective.utils import compute_certainty


@pytest.mark.parametrize("probs",(
[{"a": 66.6}],
[{"b": 99.9}, {"c": 1.0}]
))
def test_compute_certainty(probs):

Check warning

Code scanning / vcs-diff-lint

test_compute_certainty: Missing function or method docstring Warning test

test_compute_certainty: Missing function or method docstring
compute_certainty(probs)

0 comments on commit 2998ed1

Please sign in to comment.