def test_cumulative(self): histo = Histogram(n_bins=5) _ = histo.histogram(self.data) cumulative = list(histo.cumulative(None).values()) assert_items_almost_equal(cumulative, [5.0, 5.0, 7.0, 8.0, 9.0, 10.0]) assert_items_almost_equal(histo.cumulative(maximum=1.0), [0.5, 0.5, 0.7, 0.8, 0.9, 1.0])
def test_cumulative(self): histo = Histogram(n_bins=5) hist = histo.histogram(self.data) cumulative = list(histo.cumulative(None).values()) assert_items_almost_equal(cumulative, [5.0, 5.0, 7.0, 8.0, 9.0, 10.0]) assert_items_almost_equal(histo.cumulative(maximum=1.0), [0.5, 0.5, 0.7, 0.8, 0.9, 1.0])
def test_cumulative_all_zero_warn(self): histo = Histogram(bin_width=0.5, bin_range=(1.0, 3.5)) histo._histogram = collections.Counter({(0,): 0, (1,): 0}) with pytest.warns(UserWarning, match=r"No non-zero"): cumul = histo.cumulative() assert cumul(2.13) == 0 for val in cumul.values(): assert val == 0