def setUp(self): self.values = np.arange(4) self.dist = Distribution(self.values) self.nans = np.full(5, np.NaN) self.values2d = [(i, i/10) for i in np.linspace(0, 4, 10)] self.bivariate = Bivariate(self.values2d) self.dist_nans = Distribution(self.nans) self.bivariate_nans = Bivariate(np.column_stack([self.nans, self.nans]))
def test_bivariate_kde_contours(self): bivariate = Bivariate(np.random.rand(100, 2)) kde = bivariate_kde(bivariate, n_samples=100, x_range=(0, 1), y_range=(0, 1), contours=True, levels=10) self.assertIsInstance(kde, Contours) self.assertEqual(len(kde.data), 10)
def test_bivariate_kde_contours_filled(self): np.random.seed(1) bivariate = Bivariate(np.random.rand(100, 2)) kde = bivariate_kde(bivariate, n_samples=100, x_range=(0, 1), y_range=(0, 1), contours=True, filled=True, levels=10) self.assertIsInstance(kde, Polygons) self.assertEqual(len(kde.data), 10)