QuantEcon / QuantEcon/QuantEcon.py

Testing a function with randomness

Open
#147 16 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

tests
Dominant language
Python
Stars
2.4k
Forks
2.3k
Avg merge
3d 3h
Merged PRs (30d)
3

Description

I think it would be useful if we have a guideline about how to write a unittest for a function that involves randomness.

There are two approaches:

  1. Use np.random.seed
    (Example: test_quad.py, to match the outcomes to those from the CompEcon toolbox?)
  2. Rely on the law of large numbers
    (Example: test_discrete_rv)

Is there any "principle"?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by comparing the approaches shown in quantecon/tests/test_quad.py and quantecon/tests/test_discrete_rv.py, including the linked test_discrete_rv location. Define and document a principle for testing randomness that addresses seeded outcomes and law-of-large-numbers tests; done means the guideline clearly explains when to use each approach.

Written by the indexing model from the issue text.

Assessment

Tech stack
numpy, python
Domain
documentation, testing-qa
Issue type
Documentation
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.