def test_correct_ndarray_matrices(self): a1 = np.array([1.0]) a2 = np.array([0.5, 1.0]) a23 = np.array([[0.2, 0.7, 1.0], [0.1, 0.9, 1.0]]) self.assertTrue(qumo.is_pdf(a1)) self.assertTrue(qumo.is_pdf(a2)) self.assertTrue(qumo.is_pdf(a23))
def test_returns_false_when_some_elements_are_negative(self): a2 = [-0.1, 0.2, 1.0] a23 = [[0.0, 0.5, 1.0], [-0.2, 0.4, 1.0]] self.assertFalse(qumo.is_pdf(a2)) self.assertTrue(qumo.is_pdf(a2, atol=0.11)) self.assertFalse(qumo.is_pdf(a23)) self.assertTrue(qumo.is_pdf(a23, atol=0.21))
def test_correct_list_matrices(self): a1 = [1.0] a2 = [0.5, 1.0] a23 = [[0.2, 0.7, 1.0], [0.1, 0.9, 1.0]] self.assertTrue(qumo.is_pdf(a1)) self.assertTrue(qumo.is_pdf(a2)) self.assertTrue(qumo.is_pdf(a23))
def test_returns_false_when_rightmost_element_greater_than_one(self): a = [0.5, 0.6, 1.05] self.assertFalse(qumo.is_pdf(a)) self.assertTrue(qumo.is_pdf(a, atol=0.1))
def test_returns_false_when_not_ascending(self): a = [0.5, 0.4, 1.0] self.assertFalse(qumo.is_pdf(a)) self.assertTrue(qumo.is_pdf(a, atol=0.11))