@@ -447,7 +447,7 @@ def _get_padding(a_size, v_size, mode):
447
447
r_pad = v_size - l_pad - 1
448
448
elif mode == "full" :
449
449
l_pad , r_pad = v_size - 1 , v_size - 1
450
- else :
450
+ else : # pragma: no cover
451
451
raise ValueError (
452
452
f"Unknown mode: { mode } . Only 'valid', 'same', 'full' are supported."
453
453
)
@@ -458,9 +458,11 @@ def _get_padding(a_size, v_size, mode):
458
458
def _choose_conv_method (a , v , rdtype ):
459
459
assert a .size >= v .size
460
460
if rdtype == dpnp .bool :
461
+ # to avoid accuracy issues
461
462
return "direct"
462
463
463
464
if v .size < 10 ** 4 or a .size < 10 ** 4 :
465
+ # direct method is faster for small arrays
464
466
return "direct"
465
467
466
468
if dpnp .issubdtype (rdtype , dpnp .integer ):
@@ -470,12 +472,13 @@ def _choose_conv_method(a, v, rdtype):
470
472
471
473
default_float = dpnp .default_float_type (a .sycl_device )
472
474
if max_value > 2 ** numpy .finfo (default_float ).nmant - 1 :
475
+ # can't represent the result in the default float type
473
476
return "direct"
474
477
475
478
if dpnp .issubdtype (rdtype , dpnp .number ):
476
479
return "fft"
477
480
478
- raise ValueError (f"Unsupported dtype: { rdtype } " )
481
+ raise ValueError (f"Unsupported dtype: { rdtype } " ) # pragma: no cover
479
482
480
483
481
484
def _run_native_sliding_dot_product1d (a , v , l_pad , r_pad , rdtype ):
@@ -485,7 +488,7 @@ def _run_native_sliding_dot_product1d(a, v, l_pad, r_pad, rdtype):
485
488
supported_types = statistics_ext .sliding_dot_product1d_dtypes ()
486
489
supported_dtype = to_supported_dtypes (rdtype , supported_types , device )
487
490
488
- if supported_dtype is None :
491
+ if supported_dtype is None : # pragma: no cover
489
492
raise ValueError (
490
493
f"function does not support input types "
491
494
f"({ a .dtype .name } , { v .dtype .name } ), "
@@ -676,7 +679,7 @@ def correlate(a, v, mode="valid", method="auto"):
676
679
r = _run_native_sliding_dot_product1d (a , v , l_pad , r_pad , rdtype )
677
680
elif method == "fft" :
678
681
r = _convolve_fft (a , v [::- 1 ], l_pad , r_pad , rdtype )
679
- else :
682
+ else : # pragma: no cover
680
683
raise ValueError (f"Unknown method: { method } " )
681
684
682
685
if revert :
0 commit comments