def test_fixed_bandwidth(self): w = d.Kernel(self.points, bandwidth=15.0) for k, v in w[self.known_wi1].items(): np.testing.assert_allclose((k, v), (k, self.known_w1[k])) np.testing.assert_allclose(np.ones((w.n, 1)) * 15, w.bandwidth) w = d.Kernel(self.points, bandwidth=self.known_w2_bws) for k, v in w[self.known_wi2].items(): np.testing.assert_allclose((k, v), (k, self.known_w2[k]), rtol=RTOL) for i in range(w.n): np.testing.assert_allclose(w.bandwidth[i], self.known_w2_bws[i], rtol=RTOL)
def test_adaptive_bandwidth(self): w = d.Kernel(self.points, fixed=False) np.testing.assert_allclose(sorted(w[self.known_wi3].values()), sorted(self.known_w3), rtol=RTOL) bws = w.bandwidth.tolist() np.testing.assert_allclose(bws, self.known_w3_abws, rtol=RTOL) w = d.Kernel(self.points, fixed=False, function='gaussian') for k, v in w[self.known_wi4].items(): np.testing.assert_allclose((k, v), (k, self.known_w4[k]), rtol=RTOL) bws = w.bandwidth.tolist() np.testing.assert_allclose(bws, self.known_w4_abws, rtol=RTOL)
def test_init(self): w = d.Kernel(self.euclidean_kdt) for k, v in w[self.known_wi0].items(): np.testing.assert_allclose(v, self.known_w0[k], rtol=RTOL)