Skip to content

Commit

Permalink
Fix precision problem in metric's testcases (#185)
Browse files Browse the repository at this point in the history
* Solve the precision problem in testcase

* fix typo

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
MooooCat and pre-commit-ci[bot] authored Jun 6, 2024
1 parent 2d76186 commit d60da3f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
9 changes: 4 additions & 5 deletions tests/metrics/test_MISim.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from __future__ import annotations

import math
import random
from datetime import datetime, timedelta

Expand Down Expand Up @@ -94,8 +93,8 @@ def test_MISim_continuous(test_data_num, mi_sim_instance):

assert result >= 0
assert result <= 1
assert result1 == 1
assert round(result2, 9) == round(result, 9)
assert np.isclose(result1, 1, atol=1e-9)
assert np.isclose(result, result2, atol=1e-9)


def test_MISim_time(test_data_time, mi_sim_instance):
Expand All @@ -108,8 +107,8 @@ def test_MISim_time(test_data_time, mi_sim_instance):

assert result >= 0
assert result <= 1
assert result1 == 1
assert result2 == result
assert np.isclose(result1, 1, atol=1e-9)
assert np.isclose(result, result2, atol=1e-9)


if __name__ == "__main__":
Expand Down
6 changes: 3 additions & 3 deletions tests/metrics/test_jsd.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ def test_jsd_discrete(dummy_data, test_data, jsd_instance):

assert result >= 0
assert result <= 1
assert result1 == 0
assert result2 == result
assert np.isclose(result1, 0, atol=1e-9)
assert np.isclose(result, result2, atol=1e-9)


def test_jsd_continuous(dummy_data, test_data, jsd_instance):
Expand All @@ -51,7 +51,7 @@ def test_jsd_continuous(dummy_data, test_data, jsd_instance):

assert result >= 0
assert result <= 1
assert result1 == 0
assert np.isclose(result1, 0, atol=1e-9)


if __name__ == "__main__":
Expand Down

0 comments on commit d60da3f

Please sign in to comment.