Skip to content

Commit

Permalink
Fix non-determinist tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mwydmuch committed Sep 7, 2023
1 parent 5359773 commit 5f9c213
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/macos-wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
build_wheels:
strategy:
matrix:
os: [macos-10.15, macos-11, macos-12]
os: [macos-11, macos-12]
python-version: [ '3.8', '3.9', '3.10', '3.11' ]

name: Build macOS wheel on ${{ matrix.os }} for Python ${{ matrix.python-version }}
Expand Down
11 changes: 8 additions & 3 deletions python/tests/test_measures.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,18 @@

# Sets of datasets
binary_set = [(T1, L1l), (T1, L1lf), (T2, L2b), (T3, L3b), (T5, L5l)]
ranking_set = binary_set + [(T1, L1l2), (T2, L2f), (T3, L3f)]
ranking_set = [(T1, L1l2), (T2, L2f), (T3, L3f)]


def _test_binary_set(func, true_result):
k = len(true_result)
for (T, L) in binary_set:
func_result = func(T, L, k)
assert np.allclose(true_result[-1], func_result[-1]), "{}({}, {}, k={}) = {} != {}".format(func.__name__, T, L, func_result[-1], true_result[-1], k)

for (T, L) in ranking_set:
func_result = func(T, L, 3)
assert np.allclose(true_result, func_result), "{}({}, {}, k=3) = {} != {}".format(func.__name__, T, L, func_result, true_result)
func_result = func(T, L, k)
assert np.allclose(true_result, func_result), "{}({}, {}, k={}) = {} != {}".format(func.__name__, T, L, func_result, true_result, k)


def test_precision_at_k():
Expand Down

0 comments on commit 5f9c213

Please sign in to comment.