@@ -447,7 +447,7 @@ def _get_padding(a_size, v_size, mode):
447447 r_pad = v_size - l_pad - 1
448448 elif mode == "full" :
449449 l_pad , r_pad = v_size - 1 , v_size - 1
450- else :
450+ else : # pragma: no cover
451451 raise ValueError (
452452 f"Unknown mode: { mode } . Only 'valid', 'same', 'full' are supported."
453453 )
@@ -458,9 +458,11 @@ def _get_padding(a_size, v_size, mode):
458458def _choose_conv_method (a , v , rdtype ):
459459 assert a .size >= v .size
460460 if rdtype == dpnp .bool :
461+ # to avoid accuracy issues
461462 return "direct"
462463
463464 if v .size < 10 ** 4 or a .size < 10 ** 4 :
465+ # direct method is faster for small arrays
464466 return "direct"
465467
466468 if dpnp .issubdtype (rdtype , dpnp .integer ):
@@ -470,12 +472,13 @@ def _choose_conv_method(a, v, rdtype):
470472
471473 default_float = dpnp .default_float_type (a .sycl_device )
472474 if max_value > 2 ** numpy .finfo (default_float ).nmant - 1 :
475+ # can't represent the result in the default float type
473476 return "direct"
474477
475478 if dpnp .issubdtype (rdtype , dpnp .number ):
476479 return "fft"
477480
478- raise ValueError (f"Unsupported dtype: { rdtype } " )
481+ raise ValueError (f"Unsupported dtype: { rdtype } " ) # pragma: no cover
479482
480483
481484def _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):
485488 supported_types = statistics_ext .sliding_dot_product1d_dtypes ()
486489 supported_dtype = to_supported_dtypes (rdtype , supported_types , device )
487490
488- if supported_dtype is None :
491+ if supported_dtype is None : # pragma: no cover
489492 raise ValueError (
490493 f"function does not support input types "
491494 f"({ a .dtype .name } , { v .dtype .name } ), "
@@ -676,7 +679,7 @@ def correlate(a, v, mode="valid", method="auto"):
676679 r = _run_native_sliding_dot_product1d (a , v , l_pad , r_pad , rdtype )
677680 elif method == "fft" :
678681 r = _convolve_fft (a , v [::- 1 ], l_pad , r_pad , rdtype )
679- else :
682+ else : # pragma: no cover
680683 raise ValueError (f"Unknown method: { method } " )
681684
682685 if revert :
0 commit comments