-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #186 from kiudee/183_graph_bug
Fix performance and optima plot glitches when reducing parameter ranges
- Loading branch information
Showing
6 changed files
with
102 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
"""Test utility functions of the project.""" | ||
import numpy as np | ||
import pytest | ||
from numpy.testing import assert_allclose | ||
|
||
from tune.utils import latest_iterations | ||
|
||
|
||
def test_latest_iterations(): | ||
iterations = np.array([1.0, 2.0, 3.0, 3.0, 4.0]) | ||
expected_indices = [0, 1, 3, 4] | ||
result = latest_iterations(iterations) | ||
assert len(result) == 1 | ||
assert_allclose(result, (iterations[expected_indices],)) | ||
array = np.array([0.0, 0.1, 0.2, 0.3, 0.4]) | ||
result = latest_iterations(iterations, array) | ||
assert len(result) == 2 | ||
assert_allclose(result[0], iterations[expected_indices]) | ||
assert_allclose(result[1], array[expected_indices]) | ||
|
||
# Test if inconsistent lengths cause an exception | ||
array = np.array([0.0, 0.1]) | ||
with pytest.raises(ValueError): | ||
latest_iterations(iterations, array) | ||
|
||
# Test an empty input: | ||
iterations = np.array([]) | ||
result = latest_iterations(iterations) | ||
assert len(result) == 1 | ||
assert_allclose(result, (iterations,)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters