Repository: scikit-learn/scikit-learn
File: sklearn/linear_model/_stochastic_gradient.py (Python)

Code before:
            order="C",
            accept_large_sparse=False,
            reset=first_call,
        )

        n_samples, n_features = X.shape

        _check_partial_fit_first_call(self, classes)

        n_classes = self.classes_.shape[0]

        # Allocate datastructures from input arguments
        self._expanded_class_weight = compute_class_weight(
            self.class_weight, classes=self.classes_, y=y
        )

        # Skip check that validation weights are not all zero when `early_stopping` is
        # set to True as `_make_validation_split` will raise a more informative error.
        allow_all_zero_weights = True if self.early_stopping else False

        sample_weight = _check_sample_weight(
            sample_weight,
            X,
            dtype=X.dtype,
            allow_all_zero_weights=allow_all_zero_weights,
        )

        if getattr(self, "coef_", None) is None or coef_init is not None:
            self._allocate_parameter_mem(
                n_classes=n_classes,
                n_features=n_features,
                input_dtype=X.dtype,
                coef_init=coef_init,
                intercept_init=intercept_init,
            )
        elif n_features != self.coef_.shape[-1]:
            raise ValueError(
                "Number of features %d does not match previous data %d."
                % (n_features, self.coef_.shape[-1])
            )

        self._loss_function_ = self._get_loss_function(loss)
        if not hasattr(self, "t_"):
            self.t_ = 1.0

        # delegate to concrete training procedure
        if n_classes > 2:
            self._fit_multiclass(
                X,
                y,
                alpha=alpha,

Review comment (suggestion):
```suggestion
        sample_weight = _check_sample_weight(
            sample_weight,
            X,
            dtype=X.dtype,
            allow_all_zero_weights=self.early_stopping,
        )
```

Not sure if this is the best way to handle this but can't think of a better way.

Code after:
            order="C",
            accept_large_sparse=False,
            reset=first_call,
        )

        n_samples, n_features = X.shape

        _check_partial_fit_first_call(self, classes)

        n_classes = self.classes_.shape[0]

        # Allocate datastructures from input arguments
        self._expanded_class_weight = compute_class_weight(
            self.class_weight, classes=self.classes_, y=y
        )

        # Skip check that validation weights are not all zero when `early_stopping` is
        # set to True as `_make_validation_split` will raise a more informative error.
        sample_weight = _check_sample_weight(
            sample_weight,
            X,
            dtype=X.dtype,
            allow_all_zero_weights=self.early_stopping,
        )

        if getattr(self, "coef_", None) is None or coef_init is not None:
            self._allocate_parameter_mem(
                n_classes=n_classes,
                n_features=n_features,
                input_dtype=X.dtype,
                coef_init=coef_init,
                intercept_init=intercept_init,
            )
        elif n_features != self.coef_.shape[-1]:
            raise ValueError(
                "Number of features %d does not match previous data %d."
                % (n_features, self.coef_.shape[-1])
            )

        self._loss_function_ = self._get_loss_function(loss)
        if not hasattr(self, "t_"):
            self.t_ = 1.0

        # delegate to concrete training procedure
        if n_classes > 2:
            self._fit_multiclass(
                X,
                y,
                alpha=alpha,
                learning_rate=learning_rate,
                sample_weight=sample_weight,