Exemple #1
0
 def test_labels(self):
     thresholds = np.array([1, 2, 3.14])
     self.assertEqual(BinDefinition(thresholds).labels,
                      ["1", "2", "3.14"])
     self.assertEqual(BinDefinition(thresholds, "%.3f").labels,
                      ["1.000", "2.000", "3.140"])
     self.assertEqual(BinDefinition(thresholds, lambda x: f"b{x:g}").labels,
                      ["b1", "b2", "b3.14"])
     self.assertEqual(BinDefinition(thresholds, list("abc")).labels,
                      list("abc"))
Exemple #2
0
 def test_thresholds(self):
     thresholds = np.array([1, 2, 3.14])
     bindef = BinDefinition(thresholds)
     np.testing.assert_equal(bindef.thresholds, thresholds)
     self.assertEqual(bindef.start, 1)
     self.assertEqual(bindef.nbins, 2)
Exemple #3
0
 def test_width_label(self):
     thresholds = np.array([1, 2, 3.14])
     self.assertEqual(BinDefinition(thresholds).width_label, "")
     self.assertEqual(BinDefinition(thresholds, width=3).width_label, "3")
     self.assertEqual(BinDefinition(thresholds, width=3.14).width_label, "3.14")