self.mean = np.average(y, weights=sample_weight) would work for both.