Skip to content

Add docstrings to lemke.py and bimatrix.py - #19

Open
nataliemes wants to merge 2 commits into
gambitproject:mainfrom
nataliemes:docs/lemke-bimatrix-docstrings
Open

Add docstrings to lemke.py and bimatrix.py#19
nataliemes wants to merge 2 commits into
gambitproject:mainfrom
nataliemes:docs/lemke-bimatrix-docstrings

Conversation

@nataliemes

Copy link
Copy Markdown
Collaborator

Added NumPy-style docstrings to the public API classes and functions in lemke.py and bimatrix.py.
Internal helper functions were given shorter docstrings.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds NumPy-style docstrings across the public API of the LCP solver and bimatrix-game modules to make the library easier to understand and use from interactive help / generated docs.

Changes:

  • Added module/class/function docstrings to lemke.py (LCP + Lemke tableau + callback API).
  • Added module/class/function docstrings to bimatrix.py (payoff matrices, game parsing, equilibrium routines).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/lemke/lemke.py Adds module + public API docstrings for LCP instances, the Lemke tableau, callbacks, and runlemke.
src/lemke/bimatrix.py Adds module + public API docstrings for payoff matrices, bimatrix games, file parsing, and equilibrium helpers.
Suppressed comments (1)

src/lemke/bimatrix.py:152

  • payoffmatrix.addcolumn() appends the column without converting entries to Fraction. If a caller passes floats (allowed by the class docstring / __init__), later LCP construction/pivoting can fail because floats don't expose .numerator/.denominator. Consider converting the appended column entries via utils.tofraction before stacking, consistent with __init__.
    def addcolumn(self, col):
        """Append a column to the matrix and update max/min.

        Parameters
        ----------
        col : array_like
            Column to append; must have length `numrows`.
        """
        self.matrix = np.column_stack([self.matrix, col])
        self.numcolumns += 1
        self.updatemaxmin(0, self.numcolumns - 1)

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/lemke/lemke.py
Comment on lines +23 to +28
M : list of list of fractions.Fraction
Square matrix of shape `(n, n)`.
q : list of fractions.Fraction
Vector of length `n`.
d : list of fractions.Fraction
Covering vector of length `n`.
Comment thread src/lemke/bimatrix.py
Comment on lines 130 to 140
def addrow(self, row):
"""Append a row to the matrix and update max/min.

Parameters
----------
row : array_like
Row to append; must have length `numcolumns`.
"""
self.matrix = np.vstack([self.matrix, row])
self.numrows += 1
self.updatemaxmin(self.numrows - 1, 0)
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