@@ -275,13 +275,15 @@ def incr_mean_variance_axis0(X, last_mean, last_var, unsigned long last_n):
275
275
@ cython.wraparound (False )
276
276
@ cython.cdivision (True )
277
277
def inplace_csr_row_normalize_l1 (X ):
278
- """ Inplace row normalize using the l1 norm"""
279
- cdef unsigned int n_samples = X.shape[0 ]
280
- cdef unsigned int n_features = X.shape[1 ]
278
+ _inplace_csr_row_normalize_l1(X.data, X.shape, X.indices, X.indptr)
281
279
282
- cdef np.ndarray[DOUBLE, ndim= 1 ] X_data = X.data
283
- cdef np.ndarray[int , ndim= 1 ] X_indices = X.indices
284
- cdef np.ndarray[int , ndim= 1 ] X_indptr = X.indptr
280
+
281
+ def _inplace_csr_row_normalize_l1 (np.ndarray[floating , ndim = 1 ] X_data, shape ,
282
+ np.ndarray[int , ndim = 1 ] X_indices,
283
+ np.ndarray[int , ndim = 1 ] X_indptr):
284
+ """ Inplace row normalize using the l1 norm"""
285
+ cdef unsigned int n_samples = shape[0 ]
286
+ cdef unsigned int n_features = shape[1 ]
285
287
286
288
# the column indices for row i are stored in:
287
289
# indices[indptr[i]:indices[i+1]]
@@ -310,13 +312,16 @@ def inplace_csr_row_normalize_l1(X):
310
312
@ cython.wraparound (False )
311
313
@ cython.cdivision (True )
312
314
def inplace_csr_row_normalize_l2 (X ):
313
- """ Inplace row normalize using the l2 norm"""
314
- cdef unsigned int n_samples = X.shape[0 ]
315
- cdef unsigned int n_features = X.shape[1 ]
315
+ _inplace_csr_row_normalize_l2(X.data, X.shape, X.indices, X.indptr)
316
316
317
- cdef np.ndarray[DOUBLE, ndim= 1 ] X_data = X.data
318
- cdef np.ndarray[int , ndim= 1 ] X_indices = X.indices
319
- cdef np.ndarray[int , ndim= 1 ] X_indptr = X.indptr
317
+
318
+ def _inplace_csr_row_normalize_l2 (np.ndarray[floating , ndim = 1 ] X_data,
319
+ shape ,
320
+ np.ndarray[int , ndim = 1 ] X_indices,
321
+ np.ndarray[int , ndim = 1 ] X_indptr):
322
+ """ Inplace row normalize using the l2 norm"""
323
+ cdef unsigned int n_samples = shape[0 ]
324
+ cdef unsigned int n_features = shape[1 ]
320
325
321
326
cdef unsigned int i
322
327
cdef unsigned int j
0 commit comments