Add docstrings to lemke.py and bimatrix.py - #19
Open
nataliemes wants to merge 2 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
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 toFraction. 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 viautils.tofractionbefore 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 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 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Added NumPy-style docstrings to the public API classes and functions in
lemke.pyandbimatrix.py.Internal helper functions were given shorter docstrings.