Skip to content

Add doctests and refactor Monte Carlo estimation functions #12703

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

akiels
Copy link

@akiels akiels commented May 1, 2025

Contributes to #9943

This pull request refactors and improves the implementation of the Monte Carlo estimation functions:

  • Refactors functions to return values instead of printing, improving testability.
  • Adds missing type hints.
  • Renames function function_to_integrate to the more descriptive semicircle_function.
  • Clarifies docstrings.
  • Adds doctests for each function:
    • pi_estimator
    • area_under_curve_estimator
    • area_under_line_estimator_check
    • pi_estimator_using_area_under_curve

All doctests pass using python3 -m doctest -v path/to/file.py

akiels added 2 commits May 1, 2025 10:19
- Refactored all functions to return values instead of printing output.

- Added doctests for each fucntion.

- Clarified docstrings.

- Improved code style (typing hints, naming) to align with repo conventions.
Removed __main__ block not used fot script execution.
@alex2998668174
Copy link

alex2998668174 commented May 2, 2025 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants