From 9b4fd6f4f2a2a5f3b959cb9397d7923498280b1d Mon Sep 17 00:00:00 2001 From: Miranda Mundt Date: Tue, 9 Apr 2024 15:12:27 -0600 Subject: [PATCH] Add relevant comments --- pyomo/contrib/solver/base.py | 5 ++++- pyomo/contrib/solver/factory.py | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/pyomo/contrib/solver/base.py b/pyomo/contrib/solver/base.py index 8d49344fbcf..736bf8b5a7c 100644 --- a/pyomo/contrib/solver/base.py +++ b/pyomo/contrib/solver/base.py @@ -59,7 +59,10 @@ class SolverBase(abc.ABC): def __init__(self, **kwds) -> None: # We allow the user and/or developer to name the solver something else, - # if they really desire. Otherwise it defaults to the class name (all lowercase) + # if they really desire. + # Otherwise it defaults to the name defined when the solver was registered + # in the SolverFactory or the class name (all lowercase), whichever is + # applicable if "name" in kwds: self.name = kwds.pop('name') elif not hasattr(self, 'name'): diff --git a/pyomo/contrib/solver/factory.py b/pyomo/contrib/solver/factory.py index 71bf81ee15b..d3ca1329af3 100644 --- a/pyomo/contrib/solver/factory.py +++ b/pyomo/contrib/solver/factory.py @@ -31,6 +31,7 @@ class LegacySolver(LegacySolverWrapper, cls): LegacySolver ) + # Preserve the preferred name, as registered in the Factory cls.name = name return cls