QuantEcon / QuantEcon/QuantEcon.py
Testing a function with randomness
Open
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:
- Use
np.random.seed
(Example:test_quad.py, to match the outcomes to those from the CompEcon toolbox?) - Rely on the law of large numbers
(Example:test_discrete_rv)
Is there any "principle"?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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