diff --git a/tests/models/test_decomposer.py b/tests/models/test_decomposer.py index 88812fb..29009d0 100644 --- a/tests/models/test_decomposer.py +++ b/tests/models/test_decomposer.py @@ -229,7 +229,7 @@ def test_raise_warning_for_low_init_rank_reduction(mock_data_array): decomposer = Decomposer( n_modes=target_variance, init_rank_reduction=init_rank_reduction ) - warn_msg = ".*components were computed which explain.*of the variance but.*of explained variance was requested. Consider increasing the `init_rank_reduction`" + warn_msg = "Dataset has .* components, explaining .* of the variance. However, .*explained variance was requested. Please consider increasing `init_rank_reduction`" with pytest.warns(UserWarning, match=warn_msg): decomposer.fit(mock_data_array) @@ -243,7 +243,7 @@ def test_compute_at_least_one_component(mock_data_array): ) # Warning is raised to indicate that the value of init_rank_reduction is too low - warn_msg = "`init_rank_reduction=.*` is too low and results in zero components. One component will be computed instead." + warn_msg = "`init_rank_reduction=.*` is too low resulting in zero components. One component will be computed instead." with pytest.warns(UserWarning, match=warn_msg): decomposer.fit(mock_data_array) diff --git a/xeofs/models/decomposer.py b/xeofs/models/decomposer.py index 05a6302..27ecda6 100644 --- a/xeofs/models/decomposer.py +++ b/xeofs/models/decomposer.py @@ -95,14 +95,14 @@ def fit(self, X, dims=("sample", "feature")): self.n_modes_precompute = int(rank * self.init_rank_reduction) if self.n_modes_precompute < 1: warnings.warn( - f"`init_rank_reduction={self.init_rank_reduction}` is too low and results in zero components. One component will be computed instead." + f"`init_rank_reduction={self.init_rank_reduction}` is too low resulting in zero components. One component will be computed instead." ) self.n_modes_precompute = 1 # TODO(nicrie): perhaps we can just set n_modes to rank if it is larger than rank (possible solution for #158) if self.n_modes_precompute > rank: raise ValueError( - f"n_modes must be smaller or equal to the rank of the data object (rank={rank})" + f"n_modes must be less than or equal to the rank of the dataset (rank = {rank})." ) # Check if data is small enough to use exact SVD @@ -212,7 +212,7 @@ def fit(self, X, dims=("sample", "feature")): ) if n_modes_required > self.n_modes_precompute: warnings.warn( - f"{self.n_modes_precompute} components were computed which explain {total_explained_variance:.2%} of the variance but {self.n_modes:.2%} of explained variance was requested. Consider increasing the `init_rank_reduction`." + f"Dataset has {self.n_modes_precompute} components, explaining {total_explained_variance:.2%} of the variance. However, {self.n_modes:.2%} explained variance was requested. Please consider increasing `init_rank_reduction`." ) n_modes_required = self.n_modes_precompute