@@ -509,17 +509,9 @@ def partial_fit(self, X, y=None):
509509        """ 
510510        self ._check_params ()
511511        first_time  =  not  hasattr (self , 'components_' )
512- 
513-         # In theory reset should be equal to `first_time`, but there are tests 
514-         # checking the input number of feature and they expect a specific 
515-         # string, which is not the same one raised by check_n_features. So we 
516-         # don't check n_features_in_ here for now (it's done with adhoc code in 
517-         # the estimator anyway). 
518-         # TODO: set reset=first_time when addressing reset in 
519-         # predict/transform/etc. 
520-         reset_n_features  =  True 
521-         X  =  self ._check_non_neg_array (X , reset_n_features ,
522-                                       "LatentDirichletAllocation.partial_fit" )
512+         X  =  self ._check_non_neg_array (
513+             X , reset_n_features = first_time ,
514+             whom = "LatentDirichletAllocation.partial_fit" )
523515        n_samples , n_features  =  X .shape 
524516        batch_size  =  self .batch_size 
525517
@@ -663,6 +655,10 @@ def transform(self, X):
663655        doc_topic_distr : ndarray of shape (n_samples, n_components) 
664656            Document topic distribution for X. 
665657        """ 
658+         check_is_fitted (self )
659+         X  =  self ._check_non_neg_array (
660+             X , reset_n_features = False ,
661+             whom = "LatentDirichletAllocation.transform" )
666662        doc_topic_distr  =  self ._unnormalized_transform (X )
667663        doc_topic_distr  /=  doc_topic_distr .sum (axis = 1 )[:, np .newaxis ]
668664        return  doc_topic_distr 
@@ -758,7 +754,8 @@ def score(self, X, y=None):
758754        score : float 
759755            Use approximate bound as score. 
760756        """ 
761-         X  =  self ._check_non_neg_array (X , reset_n_features = True ,
757+         check_is_fitted (self )
758+         X  =  self ._check_non_neg_array (X , reset_n_features = False ,
762759                                      whom = "LatentDirichletAllocation.score" )
763760
764761        doc_topic_distr  =  self ._unnormalized_transform (X )
0 commit comments