diff --git a/xeofs/data_container/data_container.py b/xeofs/data_container/data_container.py index dca4e5f..fdd64ee 100644 --- a/xeofs/data_container/data_container.py +++ b/xeofs/data_container/data_container.py @@ -1,7 +1,6 @@ from typing import Dict import dask -from dask.diagnostics.progress import ProgressBar from typing_extensions import Self try: @@ -52,13 +51,9 @@ def deserialize(cls, dt: DataTree) -> Self: container._allow_compute[key] = node.attrs["allow_compute"] return container - def compute(self, verbose=False, **kwargs): + def compute(self, **kwargs): computed_data = {k: v for k, v in self.items() if self._allow_compute[k]} - if verbose: - with ProgressBar(): - (computed_data,) = dask.compute(computed_data, **kwargs) - else: - (computed_data,) = dask.compute(computed_data, **kwargs) + (computed_data,) = dask.compute(computed_data, **kwargs) for k, v in computed_data.items(): self[k] = v diff --git a/xeofs/models/_base_model.py b/xeofs/models/_base_model.py index c7d3fdb..90a2ebb 100644 --- a/xeofs/models/_base_model.py +++ b/xeofs/models/_base_model.py @@ -5,7 +5,6 @@ import dask.base import xarray as xr -from dask.diagnostics.progress import ProgressBar from typing_extensions import Self from .._version import __version__ @@ -54,13 +53,11 @@ def get_serialization_attrs(self) -> dict: """Get the attributes to serialize.""" raise NotImplementedError - def compute(self, verbose: bool = False, **kwargs): + def compute(self, **kwargs): """Compute and load delayed model results. Parameters ---------- - verbose : bool - Whether or not to provide additional information about the computing progress. **kwargs Additional keyword arguments to pass to `dask.compute()`. """ @@ -74,11 +71,7 @@ def compute(self, verbose: bool = False, **kwargs): if data_is_dask(v) and v.attrs.get("allow_compute", True) } - if verbose: - with ProgressBar(): - (data_objs,) = dask.base.compute(data_objs, **kwargs) - else: - (data_objs,) = dask.base.compute(data_objs, **kwargs) + (data_objs,) = dask.base.compute(data_objs, **kwargs) for k, v in data_objs.items(): dt[k] = DataTree(v) diff --git a/xeofs/models/_base_model_cross_set.py b/xeofs/models/_base_model_cross_set.py index 0273eab..c059bef 100644 --- a/xeofs/models/_base_model_cross_set.py +++ b/xeofs/models/_base_model_cross_set.py @@ -1,4 +1,3 @@ -import warnings from abc import abstractmethod from typing import Any, Hashable, Sequence @@ -80,19 +79,11 @@ def __init__( alpha: Sequence[float] | float = 1.0, solver: Sequence[str] | str = "auto", compute: bool = True, - verbose: bool = False, sample_name: str = "sample", feature_name: Sequence[str] | str = "feature", random_state: Generator | int | None = None, solver_kwargs: dict[str, Any] = {}, ): - if verbose: - warnings.warn( - "The 'verbose' parameter is deprecated and will be removed in a future release.", - category=DeprecationWarning, - stacklevel=3, - ) - super().__init__() # Process parameters @@ -134,7 +125,6 @@ def __init__( "sample_name": sample_name, "feature_name": feature_name, "random_state": random_state, - "verbose": verbose, "compute": compute, "solver": solver, } @@ -145,7 +135,6 @@ def __init__( "solver": solver, "random_state": random_state, "compute": compute, - "verbose": False, "solver_kwargs": solver_kwargs, } diff --git a/xeofs/models/_base_model_single_set.py b/xeofs/models/_base_model_single_set.py index 5f893a7..1964323 100644 --- a/xeofs/models/_base_model_single_set.py +++ b/xeofs/models/_base_model_single_set.py @@ -1,4 +1,3 @@ -import warnings from abc import abstractmethod from typing import ( Hashable, @@ -49,8 +48,6 @@ class _BaseModelSingleSet(_BaseModel): If True, four pieces of the fit will be computed sequentially: 1) the preprocessor scaler, 2) optional NaN checks, 3) SVD decomposition, 4) scores and components. - verbose: bool, default=False - Whether to show a progress bar when computing the decomposition. random_state: int | None, default=None Seed for the random number generator. solver: {"auto", "full", "randomized"}, default="auto" @@ -70,18 +67,10 @@ def __init__( sample_name="sample", feature_name="feature", compute=True, - verbose=False, random_state=None, solver="auto", solver_kwargs={}, ): - if verbose: - warnings.warn( - "The 'verbose' parameter is deprecated and will be removed in a future release.", - category=DeprecationWarning, - stacklevel=3, - ) - super().__init__() self.n_modes = n_modes @@ -98,7 +87,6 @@ def __init__( "sample_name": sample_name, "feature_name": feature_name, "random_state": random_state, - "verbose": verbose, "compute": compute, "solver": solver, "solver_kwargs": solver_kwargs, @@ -108,7 +96,6 @@ def __init__( "solver": solver, "random_state": random_state, "compute": compute, - "verbose": verbose, "solver_kwargs": solver_kwargs, } diff --git a/xeofs/models/_np_classes/_sparse_pca.py b/xeofs/models/_np_classes/_sparse_pca.py index a837603..c4e2d86 100644 --- a/xeofs/models/_np_classes/_sparse_pca.py +++ b/xeofs/models/_np_classes/_sparse_pca.py @@ -619,9 +619,6 @@ def compute_rspca( tol : float, (default ``tol = 1e-5``). Stopping tolerance for reconstruction error. - verbose : bool ``{'True', 'False'}``, optional (default ``verbose = True``). - Display progress. - oversample : integer, optional (default: 10) Controls the oversampling of column space. Increasing this parameter may improve numerical accuracy. diff --git a/xeofs/models/_np_classes/_svd.py b/xeofs/models/_np_classes/_svd.py index b6e9329..ce796ad 100644 --- a/xeofs/models/_np_classes/_svd.py +++ b/xeofs/models/_np_classes/_svd.py @@ -54,8 +54,6 @@ class _SVD: and optionally truncated afterwards. random_state : np.random.Generator | int | None, default=None Seed for the random number generator. - verbose: bool, default=False - Whether to show a progress bar when computing the decomposition. solver_kwargs : dict, default={} Additional keyword arguments passed to the SVD solver. """ @@ -67,7 +65,6 @@ def __init__( flip_signs: bool = True, solver: str = "auto", random_state: np.random.Generator | int | None = None, - verbose: bool = False, solver_kwargs: dict = {}, ): sanity_check_n_modes(n_modes) @@ -83,7 +80,6 @@ def __init__( self.n_modes_precompute = n_modes self.init_rank_reduction = init_rank_reduction self.flip_signs = flip_signs - self.verbose = verbose self.solver = solver self.random_state = random_state self.solver_kwargs = solver_kwargs diff --git a/xeofs/models/cpcca.py b/xeofs/models/cpcca.py index 546e6c2..76f8a41 100644 --- a/xeofs/models/cpcca.py +++ b/xeofs/models/cpcca.py @@ -132,7 +132,6 @@ def __init__( pca_init_rank_reduction: Sequence[float] | float = 0.3, check_nans: Sequence[bool] | bool = True, compute: bool = True, - verbose: bool = False, sample_name: str = "sample", feature_name: Sequence[str] | str = "feature", solver: str = "auto", @@ -151,7 +150,6 @@ def __init__( pca_init_rank_reduction=pca_init_rank_reduction, alpha=alpha, compute=compute, - verbose=verbose, sample_name=sample_name, feature_name=feature_name, solver=solver, @@ -1128,7 +1126,6 @@ def __init__( n_pca_modes: Sequence[float | int | str] | float | int | str = 0.999, pca_init_rank_reduction: Sequence[float] | float = 0.3, compute: bool = True, - verbose: bool = True, sample_name: str = "sample", feature_name: Sequence[str] | str = "feature", solver: str = "auto", @@ -1146,7 +1143,6 @@ def __init__( pca_init_rank_reduction=pca_init_rank_reduction, alpha=alpha, compute=compute, - verbose=verbose, sample_name=sample_name, feature_name=feature_name, solver=solver, @@ -1402,7 +1398,6 @@ def __init__( n_pca_modes: Sequence[float | int | str] | float | int | str = 0.999, pca_init_rank_reduction: Sequence[float] | float = 0.3, compute: bool = True, - verbose: bool = True, sample_name: str = "sample", feature_name: Sequence[str] | str = "feature", solver: str = "auto", @@ -1420,7 +1415,6 @@ def __init__( pca_init_rank_reduction=pca_init_rank_reduction, alpha=alpha, compute=compute, - verbose=verbose, sample_name=sample_name, feature_name=feature_name, solver=solver, diff --git a/xeofs/models/decomposer.py b/xeofs/models/decomposer.py index 0b91f9c..462d128 100644 --- a/xeofs/models/decomposer.py +++ b/xeofs/models/decomposer.py @@ -5,7 +5,6 @@ import xarray as xr from dask.array import Array as DaskArray # type: ignore from dask.array.linalg import svd_compressed as dask_svd -from dask.diagnostics.progress import ProgressBar from scipy.sparse.linalg import svds as complex_svd # type: ignore from sklearn.utils.extmath import randomized_svd @@ -38,8 +37,6 @@ class Decomposer: and optionally truncated afterwards. random_state : np.random.Generator | int | None, default=None Seed for the random number generator. - verbose: bool, default=False - Whether to show a progress bar when computing the decomposition. component_dim_name : str, default='mode' Name of the component dimension in the output DataArrays. solver_kwargs : dict, default={} @@ -54,7 +51,6 @@ def __init__( compute: bool = True, solver: str = "auto", random_state: np.random.Generator | int | None = None, - verbose: bool = False, component_dim_name: str = "mode", solver_kwargs: dict = {}, ): @@ -72,7 +68,6 @@ def __init__( self.init_rank_reduction = init_rank_reduction self.flip_signs = flip_signs self.compute = compute - self.verbose = verbose self.solver = solver self.random_state = random_state self.component_dim_name = component_dim_name @@ -299,10 +294,5 @@ def _compute_svd_result(self, U, s, VT): case False: pass case True: - match self.verbose: - case True: - with ProgressBar(): - U, s, VT = dask.compute(U, s, VT) - case False: - U, s, VT = dask.compute(U, s, VT) + U, s, VT = dask.compute(U, s, VT) return U, s, VT diff --git a/xeofs/models/eof.py b/xeofs/models/eof.py index 275d9c8..8fd1e86 100644 --- a/xeofs/models/eof.py +++ b/xeofs/models/eof.py @@ -37,8 +37,6 @@ class EOF(_BaseModelSingleSet): If True, four pieces of the fit will be computed sequentially: 1) the preprocessor scaler, 2) optional NaN checks, 3) SVD decomposition, 4) scores and components. - verbose: bool, default=False - Whether to show a progress bar when computing the decomposition. random_state : Optional[int], default=None Seed for the random number generator. solver: {"auto", "full", "randomized"}, default="auto" @@ -64,7 +62,6 @@ def __init__( sample_name: str = "sample", feature_name: str = "feature", compute: bool = True, - verbose: bool = False, random_state: Optional[int] = None, solver: str = "auto", solver_kwargs: Dict = {}, @@ -79,7 +76,6 @@ def __init__( sample_name=sample_name, feature_name=feature_name, compute=compute, - verbose=verbose, random_state=random_state, solver=solver, solver_kwargs=solver_kwargs, @@ -278,8 +274,6 @@ class ComplexEOF(EOF): computation. If True, four pieces of the fit will be computed sequentially: 1) the preprocessor scaler, 2) optional NaN checks, 3) SVD decomposition, 4) scores and components. - verbose: bool, default=False - Whether to show a progress bar when computing the decomposition. random_state : Optional[int], default=None Seed for the random number generator. solver: {"auto", "full", "randomized"}, default="auto" @@ -318,7 +312,6 @@ def __init__( sample_name: str = "sample", feature_name: str = "feature", compute: bool = True, - verbose: bool = False, random_state: Optional[int] = None, solver: str = "auto", solver_kwargs: Dict = {}, @@ -333,7 +326,6 @@ def __init__( sample_name=sample_name, feature_name=feature_name, compute=compute, - verbose=verbose, random_state=random_state, solver=solver, solver_kwargs=solver_kwargs, @@ -485,8 +477,6 @@ class HilbertEOF(ComplexEOF): If True, four pieces of the fit will be computed sequentially: 1) the preprocessor scaler, 2) optional NaN checks, 3) SVD decomposition, 4) scores and components. - verbose: bool, default=False - Whether to show a progress bar when computing the decomposition. random_state : Optional[int], default=None Seed for the random number generator. solver: {"auto", "full", "randomized"}, default="auto" @@ -522,7 +512,6 @@ def __init__( sample_name: str = "sample", feature_name: str = "feature", compute: bool = True, - verbose: bool = False, random_state: Optional[int] = None, solver: str = "auto", solver_kwargs: Dict = {}, @@ -537,7 +526,6 @@ def __init__( sample_name=sample_name, feature_name=feature_name, compute=compute, - verbose=verbose, random_state=random_state, solver=solver, solver_kwargs=solver_kwargs, diff --git a/xeofs/models/mca.py b/xeofs/models/mca.py index 221361e..d45d118 100644 --- a/xeofs/models/mca.py +++ b/xeofs/models/mca.py @@ -95,7 +95,6 @@ def __init__( n_pca_modes: Sequence[float | int | str] | float | int | str = 0.999, pca_init_rank_reduction: Sequence[float] | float = 0.3, compute: bool = True, - verbose: bool = False, sample_name: str = "sample", feature_name: Sequence[str] | str = "feature", solver: str = "auto", @@ -113,7 +112,6 @@ def __init__( n_pca_modes=n_pca_modes, pca_init_rank_reduction=pca_init_rank_reduction, compute=compute, - verbose=verbose, sample_name=sample_name, feature_name=feature_name, solver=solver, @@ -311,7 +309,6 @@ def __init__( n_pca_modes: Sequence[float | int | str] | float | int | str = 0.999, pca_init_rank_reduction: Sequence[float] | float = 0.3, compute: bool = True, - verbose: bool = False, sample_name: str = "sample", feature_name: Sequence[str] | str = "feature", solver: str = "auto", @@ -329,7 +326,6 @@ def __init__( n_pca_modes=n_pca_modes, pca_init_rank_reduction=pca_init_rank_reduction, compute=compute, - verbose=verbose, sample_name=sample_name, feature_name=feature_name, solver=solver, @@ -438,7 +434,6 @@ def __init__( n_pca_modes: Sequence[float | int | str] | float | int | str = 0.999, pca_init_rank_reduction: Sequence[float] | float = 0.3, compute: bool = True, - verbose: bool = False, sample_name: str = "sample", feature_name: Sequence[str] | str = "feature", solver: str = "auto", @@ -456,7 +451,6 @@ def __init__( n_pca_modes=n_pca_modes, pca_init_rank_reduction=pca_init_rank_reduction, compute=compute, - verbose=verbose, sample_name=sample_name, feature_name=feature_name, solver=solver, diff --git a/xeofs/models/sparse_pca.py b/xeofs/models/sparse_pca.py index 025877c..f628c94 100644 --- a/xeofs/models/sparse_pca.py +++ b/xeofs/models/sparse_pca.py @@ -68,8 +68,6 @@ class SparsePCA(_BaseModelSingleSet): 2) optional NaN checks, 3) SVD decomposition, 4) scores and components. - verbose : bool, default=False - Whether to show a progress bar when computing the decomposition. random_state : Optional[int], default=None Seed for the random number generator. solver : {"auto", "full", "randomized"}, default="randomized" @@ -111,7 +109,6 @@ def __init__( feature_name: str = "feature", check_nans=True, compute: bool = True, - verbose: bool = False, random_state: Optional[int] = None, solver: str = "auto", solver_kwargs: Dict = {}, @@ -126,7 +123,6 @@ def __init__( sample_name=sample_name, feature_name=feature_name, compute=compute, - verbose=verbose, random_state=random_state, solver=solver, solver_kwargs=solver_kwargs, diff --git a/xeofs/models/svd.py b/xeofs/models/svd.py index 7f228a0..09b15f3 100644 --- a/xeofs/models/svd.py +++ b/xeofs/models/svd.py @@ -15,7 +15,6 @@ def __init__( solver: str = "auto", compute: bool = True, random_state: np.random.Generator | int | None = None, - verbose: bool = False, solver_kwargs: dict = {}, sample_name: str = "sample", feature_name: str = "feature", @@ -25,7 +24,6 @@ def __init__( self.flip_signs = flip_signs self.solver = solver self.random_state = random_state - self.verbose = verbose self.solver_kwargs = solver_kwargs self.compute_svd = compute @@ -56,7 +54,6 @@ def fit_transform(self, X: DataArray) -> tuple[DataArray, DataArray, DataArray]: flip_signs=self.flip_signs, solver=self.solver, random_state=self.random_state, - verbose=self.verbose, **self.solver_kwargs, ) U, s, V = xr.apply_ufunc(