MCPcopy
hub / github.com/hyperopt/hyperopt / work

Method work

hyperopt/tests/unit/test_tpe.py:234–264  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

232 assert self.worked
233
234 def work(self):
235 self.worked = True
236 kwargs = dict(
237 weights=self.weights,
238 mus=self.mus,
239 sigmas=self.sigmas,
240 low=self.low,
241 high=self.high,
242 q=self.q,
243 )
244 samples = GMM1(rng=self.rng, size=(self.n_samples,), **kwargs)
245 samples = np.sort(samples)
246 edges = samples[:: self.samples_per_bin]
247 # print samples
248
249 pdf = np.exp(GMM1_lpdf(edges[:-1], **kwargs))
250 dx = edges[1:] - edges[:-1]
251 y = 1 / dx / len(dx)
252
253 if self.show:
254 plt.scatter(edges[:-1], y)
255 plt.plot(edges[:-1], pdf)
256 plt.show()
257 err = (pdf - y) ** 2
258 print(np.max(err))
259 print(np.mean(err))
260 print(np.median(err))
261 if not self.show:
262 assert np.max(err) < 0.1
263 assert np.mean(err) < 0.01
264 assert np.median(err) < 0.01
265
266 def test_basic(self):
267 self.work()

Callers 2

test_basicMethod · 0.95
test_boundedMethod · 0.95

Calls 3

GMM1Function · 0.90
GMM1_lpdfFunction · 0.90
maxMethod · 0.80

Tested by

no test coverage detected