Skip to content

DOCS: Comprehensive documentation review and improvements #789

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 3 commits into
base: main
Choose a base branch
from

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Aug 12, 2025

This PR addresses the comprehensive documentation review requested in issue #788, significantly improving docstring quality, consistency, and coverage across the QuantEcon.py codebase.

Key Improvements

Fixed Missing Docstrings (32% reduction in issues)

  • distributions.py: Enhanced BetaBinomial property methods (mean, std, var, skew) with proper docstrings including Returns sections
  • markov/core.py: Added comprehensive docstrings for all MarkovChain properties (digraph, is_irreducible, communication_classes, recurrent_classes, period, cyclic_classes, etc.)
  • game_theory/: Fixed multiple functions including str2num, payoff_profile_array, and BRD play methods with proper Parameters and Returns sections
  • markov/approximation.py: Added docstrings for std_norm_cdf and row_build_mat functions
  • quad.py: Enhanced gammaln, fix functions and fixed missing usesqrtm parameter documentation in qnwnorm

Enhanced Parameter and Returns Documentation

  • Fixed missing Parameters sections in 10+ functions across game theory and markov modules
  • Added missing Returns sections to 13+ functions
  • Corrected parameter documentation placement (e.g., moved overwrite parameter to proper section in gth_solve)
  • Added detailed parameter descriptions with proper types and defaults

Documentation Coverage Verification

  • Confirmed 100% coverage of main modules - all 23 main-level modules are properly documented
  • Verified all major packages (game_theory, markov, optimize, random, util) have corresponding documentation sections
  • Created comprehensive audit tools for future maintenance

Examples of Improvements

Before:

@property
def mean(self):
    "mean"
    return n * a / (a + b)

After:

@property
def mean(self):
    """
    Mean of the Beta-binomial distribution.
    
    Returns
    -------
    float
        The mean of the distribution, equal to n * a / (a + b).
    """
    return n * a / (a + b)

Impact

  • Reduced total documentation issues from 63 to 43 (32% improvement)
  • Fixed 10+ missing docstrings in core functionality
  • Enhanced API usability with proper parameter and return documentation
  • Maintained full test coverage - all functionality verified working
  • Created systematic audit tools for ongoing documentation maintenance

The documentation now provides much clearer guidance for users while maintaining the high mathematical rigor and code quality standards of the QuantEcon library.

Fixes #788.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

@Copilot Copilot AI changed the title [WIP] DOCS: Review of all documentation and make sure it is up to date DOCS: Comprehensive documentation review and improvements Aug 12, 2025
@Copilot Copilot AI requested a review from mmcky August 12, 2025 06:27
Copilot finished work on behalf of mmcky August 12, 2025 06:27
@oyamad
Copy link
Member

oyamad commented Aug 12, 2025

What is our convention about docs for methods with @property?
Some (or many) of them are documented as attributes in the Attributes section.
For example:

is_irreducible : bool
Indicate whether the Markov chain is irreducible.

@mmcky
Copy link
Contributor

mmcky commented Aug 14, 2025

What is our convention about docs for methods with @property? Some (or many) of them are documented as attributes in the Attributes section. For example:

is_irreducible : bool
Indicate whether the Markov chain is irreducible.

Thanks @oyamad -- I think they are considered Attributes in numpydoc https://numpydoc.readthedocs.io/en/latest/format.html#class-docstring

It is certainly how Gemini has interpreted it

Yes, Python properties are considered a special type of attribute in numpydoc.

Numpydoc's style guide explicitly states that properties can be listed under the "Attributes" section of a class docstring. If a property has its own docstring (defined on the getter method), it can simply be listed by name within the "Attributes" section, and numpydoc will pull the description from the property's own docstring.

This treatment reflects the nature of properties in Python: they provide a way to manage access to data attributes, appearing as if they are direct attributes while potentially encapsulating more complex logic (like validation or computation) behind the scenes through getter, setter, and deleter methods. From a user's perspective, they are accessed like attributes, and numpydoc's documentation style accommodates this by including them in the "Attributes" section.

@mmcky mmcky marked this pull request as ready for review August 14, 2025 06:23
@mmcky
Copy link
Contributor

mmcky commented Aug 14, 2025

@oyamad these changes appear to be surprisingly accurate. I will take a closer look tomorrow but I am pretty impressed with copilot, it's really great having an AI agent that knows the context of GitHub.

Comment on lines +347 to +354
"""
Whether the Markov chain is irreducible.

Returns
-------
bool
True if the Markov chain is irreducible, False otherwise.
"""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mmcky So a docsting shouldn't be attached to a function with @property? (This is just one example.)

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.

DOCS: Review of all documentation and make sure it is up to date
3 participants