@@ -2069,6 +2069,22 @@ def check_classifiers_one_label(name, classifier_orig):
2069
2069
assert_array_equal (classifier .predict (X_test ), y , err_msg = error_string_predict )
2070
2070
2071
2071
2072
+ def _create_memmap_backed_data (numpy_arrays ):
2073
+ # OpenBLAS is known to segfault with unaligned data on the Prescott architecture
2074
+ # See: https://github.com/scipy/scipy/issues/14886
2075
+ has_prescott_openblas = any (
2076
+ True
2077
+ for info in threadpool_info ()
2078
+ if info ["internal_api" ] == "openblas"
2079
+ # Prudently assume Prescott might be the architecture if it is unknown.
2080
+ and info .get ("architecture" , "prescott" ).lower () == "prescott"
2081
+ )
2082
+ return [
2083
+ create_memmap_backed_data (array , aligned = has_prescott_openblas )
2084
+ for array in numpy_arrays
2085
+ ]
2086
+
2087
+
2072
2088
@ignore_warnings # Warnings are raised by decision function
2073
2089
def check_classifiers_train (
2074
2090
name , classifier_orig , readonly_memmap = False , X_dtype = "float64"
@@ -2086,19 +2102,7 @@ def check_classifiers_train(
2086
2102
X_b -= X_b .min ()
2087
2103
2088
2104
if readonly_memmap :
2089
- # OpenBLAS is known to segfault with unaligned data on the Prescott architecture
2090
- # See: https://github.com/scipy/scipy/issues/14886
2091
- has_prescott_openblas = any (
2092
- True
2093
- for info in threadpool_info ()
2094
- if info ["internal_api" ] == "openblas"
2095
- # Prudently assume Prescott might be the architecture if it is unknown.
2096
- and info .get ("architecture" , "prescott" ).lower () == "prescott"
2097
- )
2098
- X_m = create_memmap_backed_data (data = X_m , aligned = has_prescott_openblas )
2099
- y_m = create_memmap_backed_data (data = y_m , aligned = has_prescott_openblas )
2100
- X_b = create_memmap_backed_data (data = X_b , aligned = has_prescott_openblas )
2101
- y_b = create_memmap_backed_data (data = y_b , aligned = has_prescott_openblas )
2105
+ X_m , y_m , X_b , y_b = _create_memmap_backed_data ([X_m , y_m , X_b , y_b ])
2102
2106
2103
2107
problems = [(X_b , y_b )]
2104
2108
tags = _safe_tags (classifier_orig )
@@ -2766,7 +2770,7 @@ def check_regressors_train(
2766
2770
y_ = y
2767
2771
2768
2772
if readonly_memmap :
2769
- X , y , y_ = create_memmap_backed_data ([X , y , y_ ])
2773
+ X , y , y_ = _create_memmap_backed_data ([X , y , y_ ])
2770
2774
2771
2775
if not hasattr (regressor , "alphas" ) and hasattr (regressor , "alpha" ):
2772
2776
# linear regressors need to set alpha, but not generalized CV ones
0 commit comments