test: retain and localize channel GPU parity failures
This commit is contained in:
1 parent
b23cb45adc
commit
1f263b9e46
4 files changed
+285
No files matched your search
@@ -0,0 +1,47 @@
|
||||
"""CPU-only traceback capture checks; no CUDA or GPU test import."""
|
||||
import importlib.util
|
||||
from pathlib import Path
|
||||
from types import SimpleNamespace
|
||||
import numpy as np
|
||||
|
||||
PATH = Path(__file__).resolve().parents[1] / 'validation/multigrid/channel_parity_diagnostic/discover.py'
|
||||
spec = importlib.util.spec_from_file_location('channel_discovery', PATH)
|
||||
discovery = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(discovery)
|
||||
|
||||
|
||||
def test_captures_exact_original_frame_and_arrays():
|
||||
def test_uniform_matched_root():
|
||||
cfg = SimpleNamespace(velocity=.025)
|
||||
shifted, profile, clamp, damping, block = True, 'parabolic', False, .8, (4, 1)
|
||||
expected = np.array([.001], np.float32)
|
||||
actual = np.nextafter(expected, np.float32(1))
|
||||
np.testing.assert_array_equal(actual, expected)
|
||||
try:
|
||||
test_uniform_matched_root()
|
||||
except AssertionError as exc:
|
||||
config, expected, actual = discovery.capture_case(exc)
|
||||
assert config['shifted'] == 1 and config['profile'] == 'parabolic'
|
||||
assert config['clamp'] == 0 and config['damping'] == .8
|
||||
assert config['block'] == [4, 1] and config['steps'] == 8
|
||||
np.testing.assert_array_equal(actual, np.nextafter(expected, np.float32(1)))
|
||||
assert expected.flags.owndata and actual.flags.owndata
|
||||
|
||||
|
||||
def test_other_assertion_does_not_guess_case():
|
||||
def test_uniform_matched_root():
|
||||
cfg = SimpleNamespace(velocity=.025)
|
||||
shifted, profile, clamp, damping, block = False, 'uniform', True, .5, (20, 24)
|
||||
expected = actual = np.array([np.nan], np.float32)
|
||||
assert np.isfinite(expected).all()
|
||||
try:
|
||||
test_uniform_matched_root()
|
||||
except AssertionError as exc:
|
||||
assert discovery.capture_case(exc) is None
|
||||
|
||||
|
||||
def test_unrelated_array_assertion_does_not_guess_case():
|
||||
try:
|
||||
np.testing.assert_array_equal([1], [2])
|
||||
except AssertionError as exc:
|
||||
assert discovery.capture_case(exc) is None
|
||||
Reference in new issue
Block a user