|
319 | 319 | >>> L.shape == (1, 100, 9) |
320 | 320 | True |
321 | 321 |
|
| 322 | +.. _CustomModels: |
| 323 | + |
322 | 324 | Implementing Custom Simulators and Models |
323 | 325 | ----------------------------------------- |
324 | 326 |
|
@@ -414,6 +416,33 @@ True |
414 | 416 | >>> D.shape == (2, 10000, 81) |
415 | 417 | True |
416 | 418 |
|
| 419 | +Finally, we mention a useful tool for doing a set of |
| 420 | +tests on the custom model, which make sure its pieces are working as |
| 421 | +expected. These tests look at things like data types and index dimensions of |
| 422 | +various functions. They also plug the outputs of some methods into the inputs |
| 423 | +of other methods, and so forth. Although they can't check the statistical |
| 424 | +soundness of your model, if they all pass, you can be pretty confident |
| 425 | +you won't run into weird indexing bugs in the future. |
| 426 | + |
| 427 | +We just need to pass :func:`~qinfer.tests.test_model` an instance of the |
| 428 | +custom model, a prior that samples valid model parameters, and an array of valid |
| 429 | +``expparams``. |
| 430 | + |
| 431 | +>>> from qinfer.tests import test_model |
| 432 | +>>> from qinfer import UniformDistribution |
| 433 | +>>> prior = UniformDistribution([[0,1],[0,1]]) |
| 434 | +>>> test_model(mcm, prior, expparams) |
| 435 | + |
| 436 | +.. code-block:: None |
| 437 | + :emphasize-lines: 1,2,3,4,5 |
| 438 | + |
| 439 | + ....... |
| 440 | + ---------------------------------------------------------------------- |
| 441 | + Ran 7 tests in 0.013s |
| 442 | +
|
| 443 | + OK |
| 444 | +
|
| 445 | +
|
417 | 446 | .. note:: |
418 | 447 |
|
419 | 448 | Creating ``expparams`` as an empty array and filling it by field name is a |
@@ -456,4 +485,3 @@ which is discussed in more detail in :ref:`perf_testing_guide`. Roughly, |
456 | 485 | this model causes the likeihood functions calculated by its underlying model |
457 | 486 | to be subject to random noise, so that the robustness of an inference algorithm |
458 | 487 | against such noise can be tested. |
459 | | - |
|
0 commit comments