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

Method work

hyperopt/tests/unit/test_tpe.py:408–432  ·  view source on GitHub ↗
(self, **kwargs)

Source from the content-addressed store, hash-verified

406 return self.LGMM1(samples, **self.LGMM1_kwargs)
407
408 def work(self, **kwargs):
409 self.__dict__.update(kwargs)
410 self.worked = True
411 samples = LGMM1(rng=self.rng, size=(self.n_samples,), **self.LGMM1_kwargs)
412 samples = np.sort(samples)
413 edges = samples[:: self.samples_per_bin]
414 centers = 0.5 * edges[:-1] + 0.5 * edges[1:]
415 print(edges)
416
417 pdf = np.exp(LGMM1_lpdf(centers, **self.LGMM1_kwargs))
418 dx = edges[1:] - edges[:-1]
419 y = 1 / dx / len(dx)
420
421 if self.show:
422 plt.scatter(centers, y)
423 plt.plot(centers, pdf)
424 plt.show()
425 err = (pdf - y) ** 2
426 print(np.max(err))
427 print(np.mean(err))
428 print(np.median(err))
429 if not self.show:
430 assert np.max(err) < 0.1
431 assert np.mean(err) < 0.01
432 assert np.median(err) < 0.01
433
434 def test_basic(self):
435 self.work()

Callers 2

test_basicMethod · 0.95
test_boundedMethod · 0.95

Calls 4

LGMM1Function · 0.90
LGMM1_lpdfFunction · 0.90
maxMethod · 0.80
updateMethod · 0.45

Tested by

no test coverage detected