From 0c3fc32340acbbe37292328cd7d3237868c7597e Mon Sep 17 00:00:00 2001 From: BalzaniEdoardo Date: Sun, 15 Dec 2024 12:23:09 -0500 Subject: [PATCH] use a generator for unpacking in a mem efficient way --- src/nemos/basis/_transformer_basis.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/nemos/basis/_transformer_basis.py b/src/nemos/basis/_transformer_basis.py index 16c01e20..56c04a06 100644 --- a/src/nemos/basis/_transformer_basis.py +++ b/src/nemos/basis/_transformer_basis.py @@ -99,13 +99,13 @@ def _unpack_inputs(self, X: FeatureMatrix) -> List: """ n_samples = X.shape[0] - out = [ + out = ( np.reshape(X[:, cc : cc + n_input], (n_samples, *bas._input_shape_)) for i, (bas, n_input) in enumerate( zip(self._list_components(), self._n_basis_input_) ) for cc in [sum(self._n_basis_input_[:i])] - ] + ) return out def fit(self, X: FeatureMatrix, y=None):