From 42d46c7e44bf120e23579aaa23f0effaa0613d09 Mon Sep 17 00:00:00 2001 From: shadeMe Date: Wed, 25 May 2022 15:06:33 +0200 Subject: [PATCH 1/2] `test_to_categorical`: Ensure that `label_smoothing < 0.5` --- thinc/tests/test_util.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/thinc/tests/test_util.py b/thinc/tests/test_util.py index b51f23a19..ec504626e 100644 --- a/thinc/tests/test_util.py +++ b/thinc/tests/test_util.py @@ -46,7 +46,7 @@ def test_array_module_cpu_gpu_helpers(): assert not is_numpy_array((1, 2)) -@given(label_smoothing=strategies.floats(min_value=0.0, max_value=0.5)) +@given(label_smoothing=strategies.floats(min_value=0.0, max_value=0.49)) def test_to_categorical(label_smoothing): # Test without n_classes one_hot = to_categorical(numpy.asarray([1, 2], dtype="i")) From 902bd41c395f7353872c7f6560bc43ea09ca0f06 Mon Sep 17 00:00:00 2001 From: shadeMe Date: Wed, 25 May 2022 15:20:14 +0200 Subject: [PATCH 2/2] Use `exclude_max` instead of clamping to `0.49` --- thinc/tests/test_util.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/thinc/tests/test_util.py b/thinc/tests/test_util.py index ec504626e..715d381d5 100644 --- a/thinc/tests/test_util.py +++ b/thinc/tests/test_util.py @@ -46,7 +46,9 @@ def test_array_module_cpu_gpu_helpers(): assert not is_numpy_array((1, 2)) -@given(label_smoothing=strategies.floats(min_value=0.0, max_value=0.49)) +@given( + label_smoothing=strategies.floats(min_value=0.0, max_value=0.5, exclude_max=True) +) def test_to_categorical(label_smoothing): # Test without n_classes one_hot = to_categorical(numpy.asarray([1, 2], dtype="i"))