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

Code before:
            X,
            y,
            accept_sparse="csr",
            dtype=[np.float64, np.float32],
            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.
        if self.early_stopping:
            allow_all_zero_weights = True
        else:
            allow_all_zero_weights = 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

Review comment (suggestion):
```suggestion
        allow_all_zero_weights = True if self.early_stopping else False
```
We can make this a one liner

Code after:
            X,
            y,
            accept_sparse="csr",
            dtype=[np.float64, np.float32],
            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,