|
22 | 22 | from ._base import _BasePCA |
23 | 23 | from ..utils import check_random_state |
24 | 24 | from ..utils._arpack import _init_arpack_v0 |
| 25 | +from ..utils.deprecation import deprecated |
25 | 26 | from ..utils.extmath import fast_logdet, randomized_svd, svd_flip |
26 | 27 | from ..utils.extmath import stable_cumsum |
27 | 28 | from ..utils.validation import check_is_fitted |
@@ -402,6 +403,16 @@ def __init__( |
402 | 403 | self.power_iteration_normalizer = power_iteration_normalizer |
403 | 404 | self.random_state = random_state |
404 | 405 |
|
| 406 | + # TODO(1.4): remove in 1.4 |
| 407 | + # mypy error: Decorated property not supported |
| 408 | + @deprecated( # type: ignore |
| 409 | + "Attribute `n_features_` was deprecated in version 1.2 and will be " |
| 410 | + "removed in 1.4. Use `n_features_in_` instead." |
| 411 | + ) |
| 412 | + @property |
| 413 | + def n_features_(self): |
| 414 | + return self.n_features_in_ |
| 415 | + |
405 | 416 | def fit(self, X, y=None): |
406 | 417 | """Fit the model with X. |
407 | 418 |
|
@@ -552,7 +563,7 @@ def _fit_full(self, X, n_components): |
552 | 563 | else: |
553 | 564 | self.noise_variance_ = 0.0 |
554 | 565 |
|
555 | | - self.n_samples_, self.n_features_ = n_samples, n_features |
| 566 | + self.n_samples_ = n_samples |
556 | 567 | self.components_ = components_[:n_components] |
557 | 568 | self.n_components_ = n_components |
558 | 569 | self.explained_variance_ = explained_variance_[:n_components] |
@@ -614,7 +625,7 @@ def _fit_truncated(self, X, n_components, svd_solver): |
614 | 625 | random_state=random_state, |
615 | 626 | ) |
616 | 627 |
|
617 | | - self.n_samples_, self.n_features_ = n_samples, n_features |
| 628 | + self.n_samples_ = n_samples |
618 | 629 | self.components_ = Vt |
619 | 630 | self.n_components_ = n_components |
620 | 631 |
|
|
0 commit comments