예제 #1
0
 def test_reverse_cumulative(self):
     histo = Histogram(n_bins=5)
     hist = histo.histogram(self.data)
     rev_cumulative = histo.reverse_cumulative(maximum=None)
     assert_items_almost_equal(rev_cumulative.values(), [10, 5, 5, 3, 2, 1])
     rev_cumulative = histo.reverse_cumulative(maximum=1.0)
     assert_items_almost_equal(rev_cumulative.values(),
                               [1.0, 0.5, 0.5, 0.3, 0.2, 0.1])
예제 #2
0
 def test_reverse_cumulative(self):
     histo = Histogram(n_bins=5)
     hist = histo.histogram(self.data)
     rev_cumulative = histo.reverse_cumulative(maximum=None)
     assert_items_almost_equal(list(rev_cumulative.values()),
                               [10, 5, 5, 3, 2, 1])
     rev_cumulative = histo.reverse_cumulative(maximum=1.0)
     assert_items_almost_equal(list(rev_cumulative.values()),
                               [1.0, 0.5, 0.5, 0.3, 0.2, 0.1])
 def test_reverse_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"):
         rcumul = histo.reverse_cumulative()
     assert rcumul(3.12) == 0
     for val in rcumul.values():
         assert val == 0
 def test_left_bin_error(self):
     histo = Histogram(bin_width=0.5, bin_range=(-1.0, 3.5))
     histo.histogram([3.5])
     assert histo.reverse_cumulative() != 0