25
25
from ..utils import assert_all_finite , check_array
26
26
from ..utils .extmath import row_norms
27
27
from ..utils .extmath import _incremental_mean_and_var
28
- from ..utils .fixes import np_version , parse_version
28
+ from ..utils .fixes import linspace
29
29
from ..utils .sparsefuncs_fast import (inplace_csr_row_normalize_l1 ,
30
30
inplace_csr_row_normalize_l2 )
31
31
from ..utils .sparsefuncs import (inplace_column_scale ,
@@ -1916,19 +1916,8 @@ def get_base_knot_positions(X, n_knots=10, knots='uniform'):
1916
1916
# knots == 'uniform':
1917
1917
x_min = np .amin (X , axis = 0 )
1918
1918
x_max = np .amax (X , axis = 0 )
1919
-
1920
- # FIXME: to be removed if min version becomes numpy 1.16
1921
- # start and stop arrays for linspace logspace and geomspace
1922
- # https://github.com/numpy/numpy/pull/12388
1923
- if np_version < parse_version ('1.16' ):
1924
- n_features = X .shape [1 ]
1925
- knots = np .empty ((n_knots , n_features ))
1926
- for j in range (n_features ):
1927
- knots [:, j ] = np .linspace (start = x_min [j ], stop = x_max [j ],
1928
- num = n_knots , endpoint = True )
1929
- else :
1930
- knots = np .linspace (start = x_min , stop = x_max , num = n_knots ,
1931
- endpoint = True )
1919
+ knots = linspace (start = x_min , stop = x_max , num = n_knots ,
1920
+ endpoint = True )
1932
1921
1933
1922
return knots
1934
1923
@@ -2023,18 +2012,12 @@ def fit(self, X, y=None):
2023
2012
# Instead, we reuse the distance of the 2 fist/last knots.
2024
2013
dist_min = base_knots [1 ] - base_knots [0 ]
2025
2014
dist_max = base_knots [- 1 ] - base_knots [- 2 ]
2026
- # FIXME: to be removed if min version becomes numpy 1.16
2027
- # start and stop arrays for linspace logspace and geomspace
2028
- # https://github.com/numpy/numpy/pull/12388
2029
- if np_version < parse_version ('1.16' ):
2030
-
2031
- else :
2032
- knots = np .r_ [np .linspace (base_knots [0 ] - degree * dist_min ,
2033
- base_knots [0 ] - dist_min , num = degree ),
2034
- base_knots ,
2035
- np .linspace (base_knots [- 1 ] + dist_max ,
2036
- base_knots [- 1 ] + degree * dist_max ,
2037
- num = degree )]
2015
+ knots = np .r_ [linspace (base_knots [0 ] - degree * dist_min ,
2016
+ base_knots [0 ] - dist_min , num = degree ),
2017
+ base_knots ,
2018
+ np .linspace (base_knots [- 1 ] + dist_max ,
2019
+ base_knots [- 1 ] + degree * dist_max ,
2020
+ num = degree )]
2038
2021
2039
2022
# With a diagonal coefficient matrix, we get back the spline basis
2040
2023
# elements, i.e. the design matrix of the spline.
0 commit comments