@@ -267,7 +267,8 @@ def _extract_one_orthogonal_component(
267267 # sequential filter that will later be replayed on new samples.
268268 score = X @ weight
269269 score_ssq = float (score @ score )
270- block_ssq = max (_ssq (X ), 1.0 )
270+ x_ssq = _ssq (X )
271+ block_ssq = max (x_ssq , 1.0 )
271272 if score_ssq <= tol * block_ssq :
272273 return None
273274
@@ -279,7 +280,7 @@ def _extract_one_orthogonal_component(
279280 if not np .all (np .isfinite (filtered )):
280281 return None
281282 # Refuse components that do not measurably reduce the block sum of squares.
282- if _ssq (filtered ) >= _ssq ( X ) - tol * max ( _ssq ( X ), 1.0 ) :
283+ if _ssq (filtered ) >= x_ssq - tol * block_ssq :
283284 return None
284285
285286 return OrthogonalBlockComponent (
@@ -348,12 +349,12 @@ def _replay_orthogonal_filter(
348349
349350
350351def _stack_columns (
351- values : list [NDArray [np .float64 ]], n_rows : int , n_columns : int
352+ values : list [NDArray [np .float64 ]], n_rows : int
352353) -> NDArray [np .float64 ]:
353354 """Column-stack values or return a correctly shaped empty matrix."""
354355 if values :
355356 return np .column_stack (values )
356- return np .zeros ((n_rows , n_columns ), dtype = np .float64 )
357+ return np .zeros ((n_rows , 0 ), dtype = np .float64 )
357358
358359
359360def _reconstruction_r2 (
@@ -505,12 +506,12 @@ def o2pls_fit(
505506 B_T = _lstsq_map (T , U )
506507 B_U = _lstsq_map (U , T )
507508
508- X_orth_weights = _stack_columns (x_weights , n_x_features , 0 )
509- X_orth_scores = _stack_columns (x_scores , n_samples , 0 )
510- X_orth_loadings = _stack_columns (x_loadings , n_x_features , 0 )
511- Y_orth_weights = _stack_columns (y_weights , n_y_features , 0 )
512- Y_orth_scores = _stack_columns (y_scores , n_samples , 0 )
513- Y_orth_loadings = _stack_columns (y_loadings , n_y_features , 0 )
509+ X_orth_weights = _stack_columns (x_weights , n_x_features )
510+ X_orth_scores = _stack_columns (x_scores , n_samples )
511+ X_orth_loadings = _stack_columns (x_loadings , n_x_features )
512+ Y_orth_weights = _stack_columns (y_weights , n_y_features )
513+ Y_orth_scores = _stack_columns (y_scores , n_samples )
514+ Y_orth_loadings = _stack_columns (y_loadings , n_y_features )
514515
515516 # Reconstruct nominal joint, orthogonal and residual parts in the original
516517 # preprocessed coordinates for diagnostics and estimator attributes.
0 commit comments