Skip to content

Commit

Permalink
Add optional typing to print_infeasibilities() method, update docstri…
Browse files Browse the repository at this point in the history
…ng for generating better documentation description (#354)
  • Loading branch information
kruksik-dev authored Sep 30, 2024
1 parent eb845d8 commit e11c575
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions linopy/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -1162,12 +1162,24 @@ def compute_infeasibilities(self) -> list[int]:
labels.append(int(line_decoded.split(":")[0][2:]))
return labels

def print_infeasibilities(self, display_max_terms: None = None) -> None:
def print_infeasibilities(self, display_max_terms: int | None = None) -> None:
"""
Print a list of infeasible constraints.
This function requires that the model was solved with `gurobi` and the
termination condition was infeasible.
This function requires that the model was solved using `gurobi`
and the termination condition was infeasible.
Parameters
----------
display_max_terms : int, optional
The maximum number of infeasible terms to display. If `None`,
all infeasible terms will be displayed.
Returns
-------
None
This function does not return anything. It simply prints the
infeasible constraints.
"""
labels = self.compute_infeasibilities()
self.constraints.print_labels(labels, display_max_terms=display_max_terms)
Expand Down

0 comments on commit e11c575

Please sign in to comment.