Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 367
Fixed #1061, Fixed #1080 Failed Snippets Tests#1162
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
+140
−70
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -2,19 +2,19 @@ | ||
| from unittest.mock import patch | ||
| import naive | ||
| import numba | ||
| import numpy as np | ||
| import numpy.testing as npt | ||
| import pytest | ||
| from numba import cuda | ||
| from stumpy import cache, config, core, fastmath, rng, sdp | ||
| from stumpy import config, core, rng, sdp | ||
| if cuda.is_available(): | ||
| from stumpy.gpu_stump import gpu_stump | ||
| else: # pragma: no cover | ||
| from stumpy.core import _gpu_stump_driver_not_found as gpu_stump # noqa: F401 | ||
| from stumpy.snippets import snippets | ||
| from stumpy.snippets import _get_all_profiles, snippets | ||
| try: | ||
| from numba.errors import NumbaPerformanceWarning | ||
| @@ -118,18 +118,25 @@ def test_calculate_squared_distance(): | ||
| npt.assert_almost_equal(ref, comp, decimal=14) | ||
| def test_snippets(): | ||
| # This test function raises an error if there is a considerable loss of precision | ||
| # that violates the symmetry property of a distance measure. | ||
| m = 10 | ||
| k = 3 | ||
| s = 3 | ||
| with rng.fix_seed(332): | ||
| T = rng.RNG.uniform(-1000.0, 1000.0, [64]) | ||
| @pytest.mark.parametrize( | ||
| "seed, m, k, s", | ||
| [(2135137202, 10, 3, 3), (2636, 9, 3, 3), (332, 10, 3, 3), (1615, 10, 3, 3)], | ||
| ) | ||
| def test_snippets(seed, m, k, s): | ||
| with rng.fix_seed(seed): | ||
| T = rng.RNG.uniform(-1000, 1000, [64]).astype(np.float64) | ||
| isconstant_custom_func = functools.partial( | ||
| naive.isconstant_func_stddev_threshold, quantile_threshold=0.05 | ||
| ) | ||
| D = _get_all_profiles( | ||
| T, | ||
| m, | ||
| s=s, | ||
| mpdist_T_subseq_isconstant=isconstant_custom_func, | ||
| ) | ||
| ( | ||
| ref_snippets, | ||
| ref_indices, | ||
| @@ -138,9 +145,13 @@ def test_snippets(): | ||
| ref_areas, | ||
| ref_regimes, | ||
| ) = naive.mpdist_snippets( | ||
| T, m, k, s=s, mpdist_T_subseq_isconstant=isconstant_custom_func | ||
| T, | ||
| m, | ||
| k, | ||
| s=s, | ||
| mpdist_T_subseq_isconstant=isconstant_custom_func, | ||
| D=D, | ||
| ) | ||
| ( | ||
| cmp_snippets, | ||
| cmp_indices, | ||
| @@ -150,29 +161,6 @@ def test_snippets(): | ||
| cmp_regimes, | ||
| ) = snippets(T, m, k, s=s, mpdist_T_subseq_isconstant=isconstant_custom_func) | ||
| if ( | ||
| not np.allclose(ref_snippets, cmp_snippets) and not numba.config.DISABLE_JIT | ||
| ): # pragma: no cover | ||
| # Revise fastmath flags by removing reassoc (to improve precision), | ||
| # recompile njit functions, and re-compute snippets. | ||
| fastmath._set( | ||
| "core", | ||
| "_calculate_squared_distance", | ||
| {"nsz", "arcp", "contract", "afn"}, | ||
| ) | ||
| cache._recompile() | ||
| ( | ||
| cmp_snippets, | ||
| cmp_indices, | ||
| cmp_profiles, | ||
| cmp_fractions, | ||
| cmp_areas, | ||
| cmp_regimes, | ||
| ) = snippets( | ||
| T, m, k, s=s, mpdist_T_subseq_isconstant=isconstant_custom_func | ||
| ) | ||
| npt.assert_almost_equal( | ||
| ref_snippets, cmp_snippets, decimal=config.STUMPY_TEST_PRECISION | ||
| ) | ||
| @@ -190,11 +178,6 @@ def test_snippets(): | ||
| ) | ||
| npt.assert_almost_equal(ref_regimes, cmp_regimes) | ||
| if not numba.config.DISABLE_JIT: # pragma: no cover | ||
| # Revert fastmath flag back to their default values | ||
| fastmath._reset("core", "_calculate_squared_distance") | ||
| cache._recompile() | ||
NimaSarajpoor marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| @pytest.mark.filterwarnings("ignore", category=NumbaPerformanceWarning) | ||
| @patch("stumpy.config.STUMPY_THREADS_PER_BLOCK", TEST_THREADS_PER_BLOCK) | ||
| @@ -215,7 +198,7 @@ def test_distance_symmetry_property_in_gpu(): | ||
| # This test raises an error if arithmetic operation in ... | ||
| # ... `gpu_stump._compute_and_update_PI_kernel` does not | ||
| # generates the same result if values of variable for mean and std | ||
| # generate the same result if values of variable for mean and std | ||
| # are swapped. | ||
| T_A = T[i : i + m] | ||
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.