diff --git a/src/uhi/numpy_plottable.py b/src/uhi/numpy_plottable.py index d4d4b6a..4d77052 100644 --- a/src/uhi/numpy_plottable.py +++ b/src/uhi/numpy_plottable.py @@ -258,17 +258,17 @@ def variances(self) -> np.ndarray: return self.values() def counts(self) -> np.ndarray: - if self.hasWeights: - sumw = self.values() - return np.divide( # type: ignore - sumw ** 2, - self.variances(), - out=np.zeros_like(sumw, dtype=np.float64), - where=sumw != 0, - ) - else: + if not self.hasWeights: return self.values() + sumw = self.values() + return np.divide( # type: ignore + sumw ** 2, + self.variances(), + out=np.zeros_like(sumw, dtype=np.float64), + where=sumw != 0, + ) + if TYPE_CHECKING: # Verify that the above class is a valid PlottableHistogram