diff --git a/examples/dae/ReactionKinetics.py b/examples/dae/ReactionKinetics.py index 0786a19e2c8..2276555a5e2 100644 --- a/examples/dae/ReactionKinetics.py +++ b/examples/dae/ReactionKinetics.py @@ -28,7 +28,7 @@ solver = pyo.SolverFactory('ipopt') -class Reaction(object): +class Reaction: """A simple class to hold the stoichiometry of a single reaction Reaction data is stored in two dictionaries: @@ -84,7 +84,7 @@ def _parseTerm(self, x): return coef, species.strip() -class ReactionNetwork(object): +class ReactionNetwork: """A simple object to hold sets of reactions.""" def __init__(self): diff --git a/examples/pyomo/p-median/solver1.py b/examples/pyomo/p-median/solver1.py index 7d63400aded..bc147b54994 100644 --- a/examples/pyomo/p-median/solver1.py +++ b/examples/pyomo/p-median/solver1.py @@ -17,7 +17,7 @@ @plugin_factory(pyo.SolverFactory) -class MySolver(object): +class MySolver: alias('greedy') # Declare that this is an IOptSolver plugin diff --git a/examples/pyomo/p-median/solver2.py b/examples/pyomo/p-median/solver2.py index f8355d34b23..6b64e1cc078 100644 --- a/examples/pyomo/p-median/solver2.py +++ b/examples/pyomo/p-median/solver2.py @@ -18,7 +18,7 @@ @plugin_factory -class MySolver(object): +class MySolver: alias('random') # Declare that this is an IOptSolver plugin diff --git a/pyomo/common/autoslots.py b/pyomo/common/autoslots.py index 3b5b3b00154..e563544c50e 100644 --- a/pyomo/common/autoslots.py +++ b/pyomo/common/autoslots.py @@ -276,7 +276,7 @@ def encode_as_none(encode, val): else: return val - class Mixin(object): + class Mixin: """Mixin class to configure a class hierarchy to use AutoSlots Inheriting from this class will set up the automatic generation diff --git a/pyomo/common/config.py b/pyomo/common/config.py index 806501d7df9..d012598e000 100644 --- a/pyomo/common/config.py +++ b/pyomo/common/config.py @@ -204,7 +204,7 @@ def NonNegativeFloat(val): return ans -class In(object): +class In: """In(domain, cast=None) Domain validation class admitting a Container of possible values @@ -268,7 +268,7 @@ def domain_name(self): return f'In{_dn}' -class InEnum(object): +class InEnum: """Domain validation class admitting an enum value/name. This will admit any value that is in the specified Enum, including @@ -301,7 +301,7 @@ def domain_name(self): return f'InEnum[{_domain_name(self._domain)}]' -class IsInstance(object): +class IsInstance: """ Domain validator for type checking. @@ -365,7 +365,7 @@ def domain_name(self): return f"IsInstance[{', '.join(class_names)}]" -class ListOf(object): +class ListOf: """Domain validator for lists of a specified type Parameters @@ -411,7 +411,7 @@ def domain_name(self): return f'ListOf[{_dn}]' -class Module(object): +class Module: """Domain validator for modules. Modules can be specified as module objects, by module name, @@ -485,7 +485,7 @@ def __call__(self, module_id): return import_file(path) -class Path(object): +class Path: """ Domain validator for a :py:term:`path-like object `. @@ -594,7 +594,7 @@ def __call__(self, data): return [super(PathList, self).__call__(data)] -class DynamicImplicitDomain(object): +class DynamicImplicitDomain: """Implicit domain that can return a custom domain based on the key. This provides a mechanism for managing plugin-like systems, where @@ -810,7 +810,7 @@ def from_enum_or_string(cls, arg): .. doctest:: - >>> class Base(object): + >>> class Base: ... CONFIG = ConfigDict() ... CONFIG.declare('filename', ConfigValue( ... default='input.txt', @@ -854,7 +854,7 @@ class will still create ``c`` instances that only have the single .. doctest:: - >>> class Solver(object): + >>> class Solver: ... CONFIG = ConfigDict() ... CONFIG.declare('iterlim', ConfigValue( ... default=10, @@ -1211,7 +1211,7 @@ def _value2yaml(prefix, value, obj): return _str.rstrip() -class _UnpickleableDomain(object): +class _UnpickleableDomain: def __init__(self, obj): self._type = type(obj).__name__ self._name = obj.name(True) @@ -1410,7 +1410,7 @@ def _item_body_cb(self, indent, obj): return types.MethodType(_item_body_cb, formatter) -class ConfigFormatter(object): +class ConfigFormatter: def _initialize(self, indent_spacing, width, visibility): self.out = io.StringIO() self.indent_spacing = indent_spacing @@ -1565,7 +1565,7 @@ def add_docstring_list(docstring, configdict, indent_by=4): ) -class document_kwargs_from_configdict(object): +class document_kwargs_from_configdict: """Decorator to append the documentation of a ConfigDict to the docstring This adds the documentation of the specified :py:class:`ConfigDict` @@ -1600,7 +1600,7 @@ class document_kwargs_from_configdict(object): >>> from pyomo.common.config import ( ... ConfigDict, ConfigValue, document_kwargs_from_configdict ... ) - >>> class MyClass(object): + >>> class MyClass: ... CONFIG = ConfigDict() ... CONFIG.declare('iterlim', ConfigValue( ... default=3000, @@ -1676,7 +1676,7 @@ def __call__(self, fcn): return fcn -class UninitializedMixin(object): +class UninitializedMixin: """Mixin class to support delayed data initialization. This mixin can be used to create a derived Config class that hides @@ -1743,7 +1743,7 @@ def _data(self, value): self._data = value -class ConfigBase(object): +class ConfigBase: # Note: __getstate__ relies on this field ordering. Do not change. __slots__ = ( '_parent', @@ -1763,7 +1763,7 @@ class ConfigBase(object): # we can tell if an argument is provided (and we can't use None as # None is a valid user-specified argument). Making it a class helps # when Config objects are pickled. - class NoArgument(object): + class NoArgument: pass def __init__( @@ -2293,7 +2293,7 @@ def _setter(self, value): self._data = _data -class MarkImmutable(object): +class MarkImmutable: """ Mark instances of ConfigValue as immutable. diff --git a/pyomo/common/dependencies.py b/pyomo/common/dependencies.py index efd47bf2deb..49114c2c0bb 100644 --- a/pyomo/common/dependencies.py +++ b/pyomo/common/dependencies.py @@ -31,7 +31,7 @@ SUPPRESS_DEPENDENCY_WARNINGS = False -class ModuleUnavailable(object): +class ModuleUnavailable: """Mock object that raises :py:class:`.DeferredImportError` upon attribute access This object is returned by :py:func:`attempt_import()` in lieu of @@ -129,7 +129,7 @@ def generate_import_warning(self, logger='pyomo.common'): self.log_import_warning(logger) -class DeferredImportModule(object): +class DeferredImportModule: """Mock module object to support the deferred import of a module. This object is returned by :py:func:`attempt_import()` in lieu of @@ -281,7 +281,7 @@ def __new__(cls, *args, **kwargs): return UnavailableBase -class _DeferredImportIndicatorBase(object): +class _DeferredImportIndicatorBase: def __and__(self, other): return _DeferredAnd(self, other) @@ -857,7 +857,7 @@ def declare_deferred_modules_as_importable(globals_dict): return declare_modules_as_importable(globals_dict).__exit__(None, None, None) -class declare_modules_as_importable(object): +class declare_modules_as_importable: """Make all :py:class:`ModuleType` and :py:class:`DeferredImportModules` importable through the ``globals_dict`` context. diff --git a/pyomo/common/deprecation.py b/pyomo/common/deprecation.py index 4f34043d713..a82468a3ede 100644 --- a/pyomo/common/deprecation.py +++ b/pyomo/common/deprecation.py @@ -469,7 +469,7 @@ class RenamedClass(type): Examples -------- >>> from pyomo.common.deprecation import RenamedClass - >>> class NewClass(object): + >>> class NewClass: ... pass >>> class OldClass(metaclass=RenamedClass): ... __renamed__new_class__ = NewClass diff --git a/pyomo/common/download.py b/pyomo/common/download.py index 073ac6f9dad..4c457f9221e 100644 --- a/pyomo/common/download.py +++ b/pyomo/common/download.py @@ -38,7 +38,7 @@ DownloadFactory = pyomo.common.Factory('library downloaders') -class FileDownloader(object): +class FileDownloader: _os_version = None def __init__(self, insecure=False, cacert=None): diff --git a/pyomo/common/env.py b/pyomo/common/env.py index d372b061e51..33551f99139 100644 --- a/pyomo/common/env.py +++ b/pyomo/common/env.py @@ -99,7 +99,7 @@ def _load_dll(name, timeout=10): _load_dll.pool = None -class _RestorableEnvironInterface(object): +class _RestorableEnvironInterface: """Interface to track environment changes and restore state""" def __init__(self, dll): @@ -160,7 +160,7 @@ def __delitem__(self, key): self.dll.putenv_s(key, b'') -class _OSEnviron(object): +class _OSEnviron: """Helper class to proxy a "DLL-like" interface to os.environ""" _libname = 'os.environ' @@ -205,7 +205,7 @@ def wputenv_s(self, key, val): os.environ[key] = val -class _MsvcrtDLL(object): +class _MsvcrtDLL: """Helper class to manage the interface with the MSVCRT runtime""" def __init__(self, name): @@ -280,7 +280,7 @@ def get_env_dict(self): return ans -class _Win32DLL(object): +class _Win32DLL: """Helper class to manage the interface with the Win32 runtime""" def __init__(self, name): @@ -381,7 +381,7 @@ def get_env_dict(self): return ans -class CtypesEnviron(object): +class CtypesEnviron: """A context manager for managing environment variables This class provides a simplified interface for consistently setting diff --git a/pyomo/common/factory.py b/pyomo/common/factory.py index e1cb8543f74..1c744d378fd 100644 --- a/pyomo/common/factory.py +++ b/pyomo/common/factory.py @@ -17,7 +17,7 @@ # ___________________________________________________________________________ -class Factory(object): +class Factory: """ A class that is used to define a factory for objects. diff --git a/pyomo/common/fileutils.py b/pyomo/common/fileutils.py index 4a0b2beb36b..8e706bf4232 100644 --- a/pyomo/common/fileutils.py +++ b/pyomo/common/fileutils.py @@ -505,7 +505,7 @@ def import_file(path, clear_cache=False, infer_package=True, module_name=None): return module -class PathData(object): +class PathData: """An object for storing and managing a :py:class:`PathManager` path""" def __init__(self, manager, name): @@ -610,7 +610,7 @@ def executable(self, value): self.set_path(value) -class PathManager(object): +class PathManager: """The PathManager defines a registry class for path locations The :py:class:`PathManager` defines a class very similar to the diff --git a/pyomo/common/formatting.py b/pyomo/common/formatting.py index 71798565417..710116a98fe 100644 --- a/pyomo/common/formatting.py +++ b/pyomo/common/formatting.py @@ -196,7 +196,7 @@ def tabular_writer(ostream, prefix, data, header, row_generator): ) -class StreamIndenter(object): +class StreamIndenter: """ Mock-up of a file-like object that wraps another file-like object and indents all data using the specified string before passing it to diff --git a/pyomo/common/gc_manager.py b/pyomo/common/gc_manager.py index 5745fe1a97e..5610002b871 100644 --- a/pyomo/common/gc_manager.py +++ b/pyomo/common/gc_manager.py @@ -20,7 +20,7 @@ from pyomo.common.multithread import MultiThreadWrapper -class __PauseGCCompanion(object): +class __PauseGCCompanion: def __init__(self): self._stack_depth = 0 @@ -41,7 +41,7 @@ def __init__(self): # the GC will be re-enabled (if it was not initially disabled). It is # safe to nest instances of PauseGC That is, you don't have to worry # if an outer function/method has its own instance of PauseGC. -class PauseGC(object): +class PauseGC: __slots__ = ("reenable_gc", "stack_pointer") def __init__(self): diff --git a/pyomo/common/log.py b/pyomo/common/log.py index 3e2b77729f7..b459cf9c43f 100644 --- a/pyomo/common/log.py +++ b/pyomo/common/log.py @@ -237,7 +237,7 @@ def emit(self, record): self.stream = orig -class Preformatted(object): +class Preformatted: __slots__ = ('msg',) def __init__(self, msg): @@ -250,7 +250,7 @@ def __repr__(self): return f'Preformatted({self.msg!r})' -class _GlobalLogFilter(object): +class _GlobalLogFilter: def __init__(self): self.logger = logging.getLogger() @@ -292,7 +292,7 @@ def __init__(self, base='', stream=None, level=logging.NOTSET, verbosity=None): self.setFormatter(LegacyPyomoFormatter(base=base, verbosity=verbosity)) -class LoggingIntercept(object): +class LoggingIntercept: r"""Context manager for intercepting messages sent to a log stream This class is designed to enable easy testing of log messages. @@ -461,7 +461,7 @@ def redirect_streams(self, redirects): yield _LastResortRedirector(redirects[fd].original_fd) -class _StreamRedirector(object): +class _StreamRedirector: def __init__(self, handler, fd): self.handler = handler self.fd = fd @@ -488,7 +488,7 @@ def __exit__(self, et, ev, tb): self.handler.stream = self.orig_stream -class _LastResortRedirector(object): +class _LastResortRedirector: def __init__(self, fd): self.fd = fd self.local_fd = None diff --git a/pyomo/common/plugin_base.py b/pyomo/common/plugin_base.py index f33bff09026..a54a762b6bf 100644 --- a/pyomo/common/plugin_base.py +++ b/pyomo/common/plugin_base.py @@ -23,7 +23,7 @@ from pyomo.common.deprecation import deprecated, deprecation_warning -class PluginGlobals(object): +class PluginGlobals: @staticmethod @deprecated( "The PluginGlobals environment manager is deprecated: " @@ -254,7 +254,7 @@ class SingletonPlugin(Plugin): __singleton__ = True -class ExtensionPoint(object): +class ExtensionPoint: def __init__(self, interface): assert issubclass(interface, Interface) self._interface = interface @@ -302,7 +302,7 @@ def service(self, key=None, all=False): ) -class PluginFactory(object): +class PluginFactory: def __init__(self, interface): self.interface = interface diff --git a/pyomo/common/sorting.py b/pyomo/common/sorting.py index bb5ea13f55e..65b7dee505a 100644 --- a/pyomo/common/sorting.py +++ b/pyomo/common/sorting.py @@ -10,7 +10,7 @@ # ___________________________________________________________________________ -class _robust_sort_keyfcn(object): +class _robust_sort_keyfcn: """Class for robustly generating sortable keys for arbitrary data. Generates keys (for use with Python `sorted()` that are diff --git a/pyomo/common/tee.py b/pyomo/common/tee.py index 6cc986a1bc5..a5b35e02dd5 100644 --- a/pyomo/common/tee.py +++ b/pyomo/common/tee.py @@ -54,7 +54,7 @@ logger = logging.getLogger(__name__) -class _SignalFlush(object): +class _SignalFlush: def __init__(self, ostream, handle): super().__setattr__('_ostream', ostream) super().__setattr__('_handle', handle) @@ -80,7 +80,7 @@ def writelines(self, data): self.flush() -class _fd_closer(object): +class _fd_closer: """A context manager to handle closing a specified file descriptor Ideally we would use `os.fdopen(... closefd=True)`; however, it @@ -101,7 +101,7 @@ def __exit__(self, et, ev, tb): os.close(self.fd) -class redirect_fd(object): +class redirect_fd: """Redirect a file descriptor to a new file or file descriptor. This context manager will redirect the specified file descriptor to @@ -189,7 +189,7 @@ def __exit__(self, et, ev, tb): os.close(self.original_fd) -class capture_output(object): +class capture_output: """Context manager to capture output sent to sys.stdout and sys.stderr This is a drop-in substitute for PyUtilib's capture_output to @@ -475,7 +475,7 @@ def reset(self): return self.__exit__(None, None, None) -class _StreamHandle(object): +class _StreamHandle: """A stream handler object used by TeeStream This handler holds the two sides of the pipe used to communicate @@ -643,7 +643,7 @@ def writeOutputBuffer(self, ostreams, flush): ) -class TeeStream(object): +class TeeStream: def __init__(self, *ostreams, encoding=None, buffering=-1): self.ostreams = ostreams self.encoding = encoding diff --git a/pyomo/common/tempfiles.py b/pyomo/common/tempfiles.py index 7d8c81cd641..e61802065b7 100644 --- a/pyomo/common/tempfiles.py +++ b/pyomo/common/tempfiles.py @@ -33,7 +33,7 @@ pyutilib_tempfiles, _ = attempt_import('pyutilib.component.config.tempfiles') -class TempfileManagerClass(object): +class TempfileManagerClass: """A class for managing tempfile contexts Pyomo declares a global instance of this class as ``TempfileManager``: diff --git a/pyomo/common/tests/mod.py b/pyomo/common/tests/mod.py index 495aae457df..6c637fb5fd8 100644 --- a/pyomo/common/tests/mod.py +++ b/pyomo/common/tests/mod.py @@ -13,5 +13,5 @@ # This is a simple module used as part of testing import callbacks -class Foo(object): +class Foo: data = 42 diff --git a/pyomo/common/tests/moved.py b/pyomo/common/tests/moved.py index 55912a76213..76e15cf1627 100644 --- a/pyomo/common/tests/moved.py +++ b/pyomo/common/tests/moved.py @@ -13,5 +13,5 @@ # This is a simple module used as part of testing moved_module() -class Bar(object): +class Bar: data = 42 diff --git a/pyomo/common/tests/relo_mod_new.py b/pyomo/common/tests/relo_mod_new.py index d616574aa99..86a8df83055 100644 --- a/pyomo/common/tests/relo_mod_new.py +++ b/pyomo/common/tests/relo_mod_new.py @@ -12,5 +12,5 @@ RELO_ATTR = 42 -class ReloClass(object): +class ReloClass: pass diff --git a/pyomo/common/tests/relocated.py b/pyomo/common/tests/relocated.py index b7572f7db36..3a86337088d 100644 --- a/pyomo/common/tests/relocated.py +++ b/pyomo/common/tests/relocated.py @@ -13,7 +13,7 @@ from pyomo.common.deprecation import relocated_module_attribute -class Bar(object): +class Bar: data = 42 diff --git a/pyomo/common/tests/test_config.py b/pyomo/common/tests/test_config.py index da87e5fe340..dc14284121a 100644 --- a/pyomo/common/tests/test_config.py +++ b/pyomo/common/tests/test_config.py @@ -86,7 +86,7 @@ def _display(obj, *args): return test.getvalue() -class GlobalClass(object): +class GlobalClass: "test class for test_known_types" pass @@ -409,7 +409,7 @@ def test_In(self): c.b = '1' self.assertEqual(c.b, 1) - class Container(object): + class Container: def __init__(self, vals): self._vals = vals @@ -1427,7 +1427,7 @@ def test_display_userdata_add_block_nonDefault(self): ) def test_display_nondata_type(self): - class NOOP(object): + class NOOP: def __getattr__(self, attr): def noop(*args, **kwargs): pass @@ -2898,7 +2898,7 @@ def test_call_options(self): self.assertEqual(mod_copy._visibility, 0) def test_template_nondata(self): - class NOOP(object): + class NOOP: def __getattr__(self, attr): def noop(*args, **kwargs): pass @@ -3014,7 +3014,7 @@ def local_fcn(): def test_known_types(self): def local_fcn(): - class LocalClass(object): + class LocalClass: pass return LocalClass @@ -3097,7 +3097,7 @@ def test_declare_from(self): def test_docstring_decorator(self): @document_kwargs_from_configdict('CONFIG') - class ExampleClass(object): + class ExampleClass: CONFIG = ExampleConfig() @document_kwargs_from_configdict(CONFIG) @@ -3302,7 +3302,7 @@ def domain_name(self): self.assertEqual(cfg.get('type').domain_name(), 'int') def test_deferred_initialization(self): - class Accumulator(object): + class Accumulator: def __init__(self): self.data = [] diff --git a/pyomo/common/tests/test_dependencies.py b/pyomo/common/tests/test_dependencies.py index 2669be4cd12..6aa41c0d89b 100644 --- a/pyomo/common/tests/test_dependencies.py +++ b/pyomo/common/tests/test_dependencies.py @@ -265,7 +265,7 @@ def test_callback_on_import(self): sys.modules.pop('pyomo.common.tests.mod', None) ans = [] - class ImpFinder(object): + class ImpFinder: # This is an "imp" module-style finder (deprecated in Python # 3.4 and removed in Python 3.12, but Google Collab still # defines finders like this) diff --git a/pyomo/common/tests/test_deprecated.py b/pyomo/common/tests/test_deprecated.py index a44f9058a5e..0daefcbdd1a 100644 --- a/pyomo/common/tests/test_deprecated.py +++ b/pyomo/common/tests/test_deprecated.py @@ -74,13 +74,13 @@ def foo(): ): @deprecated() - class foo(object): + class foo: pass # But no exception if the class can infer a version from the # __init__ (or __new__ or __new_member__) @deprecated() - class foo(object): + class foo: @deprecated(version="1.2") def __init__(self): pass @@ -258,7 +258,7 @@ def foo(bar='yeah'): def test_with_class(self): @deprecated(version='test') - class foo(object): + class foo: def __init__(self): logger.warning('yeah') @@ -285,7 +285,7 @@ def __init__(self): ) def test_with_method(self): - class foo(object): + class foo: def __init__(self): pass @@ -316,7 +316,7 @@ def bar(self): ) def test_with_remove_in(self): - class foo(object): + class foo: def __init__(self): pass @@ -348,7 +348,7 @@ def bar(self): ) -class Bar(object): +class Bar: data = 21 @@ -498,7 +498,7 @@ def test_relocated_module(self): class TestRenamedClass(unittest.TestCase): def test_renamed(self): - class NewClass(object): + class NewClass: attr = 'NewClass' class NewClassSubclass(NewClass): @@ -640,7 +640,7 @@ class DeprecatedClassSubSubclass(DeprecatedClassSubclass, otherClass): self.assertEqual(DeprecatedClassSubSubclass.attr, 'DeprecatedClassSubSubclass') def test_renamed_errors(self): - class NewClass(object): + class NewClass: pass with self.assertRaisesRegex( diff --git a/pyomo/common/tests/test_sorting.py b/pyomo/common/tests/test_sorting.py index 5bd3c3399d8..872d08ece7c 100644 --- a/pyomo/common/tests/test_sorting.py +++ b/pyomo/common/tests/test_sorting.py @@ -22,7 +22,7 @@ # The following are custom types used for testing sorted_robust. They # are declared at the module scope to ensure consistent generation of # the class __name__. -class LikeFloat(object): +class LikeFloat: def __init__(self, n): self.n = n @@ -33,7 +33,7 @@ def __gt__(self, other): return self.n > other -class Comparable(object): +class Comparable: def __init__(self, n): self.n = str(n) @@ -44,7 +44,7 @@ def __gt__(self, other): return self.n > other -class ToStr(object): +class ToStr: def __init__(self, n): self.n = str(n) @@ -52,7 +52,7 @@ def __str__(self): return self.n -class NoStr(object): +class NoStr: def __init__(self, n): self.n = str(n) diff --git a/pyomo/common/tests/test_tee.py b/pyomo/common/tests/test_tee.py index 5f3cd98719e..1fd55420991 100644 --- a/pyomo/common/tests/test_tee.py +++ b/pyomo/common/tests/test_tee.py @@ -666,7 +666,7 @@ def test_exit_on_del(self): raise def test_deadlock(self): - class MockStream(object): + class MockStream: def write(self, data): # This test will kill the write before this sleep is # done, so a long sleep won't impact suite run time. @@ -710,7 +710,7 @@ def flush(self): tee._poll_timeout, tee._poll_timeout_deadlock = _save -class BufferTester(object): +class BufferTester: def setUp(self): sys.stdout.flush() sys.stderr.flush() diff --git a/pyomo/common/timing.py b/pyomo/common/timing.py index b08b2bd07dc..ffcbd6fa47e 100644 --- a/pyomo/common/timing.py +++ b/pyomo/common/timing.py @@ -44,7 +44,7 @@ _transform_logger = logging.getLogger('pyomo.common.timing.transformation') -class report_timing(object): +class report_timing: def __init__(self, stream=True, level=logging.INFO): """Set reporting of Pyomo timing information. @@ -99,7 +99,7 @@ def __exit__(self, et, ev, tb): self.reset() -class GeneralTimer(object): +class GeneralTimer: def __init__(self, fmt, data): self.fmt = fmt self.data = data @@ -119,7 +119,7 @@ def __str__(self): return self.fmt % self.data -class ConstructionTimer(object): +class ConstructionTimer: __slots__ = ('obj', 'timer') msg = "%6.*f seconds to construct %s %s%s" in_progress = "ConstructionTimer object for %s %s; %0.3f elapsed seconds" @@ -184,7 +184,7 @@ def __str__(self): ) -class TransformationTimer(object): +class TransformationTimer: __slots__ = ('obj', 'mode', 'timer') msg = "%6.*f seconds to apply Transformation %s%s" in_progress = "TransformationTimer object for %s%s; %0.3f elapsed seconds" @@ -233,7 +233,7 @@ def __str__(self): default_timer = time.perf_counter -class TicTocTimer(object): +class TicTocTimer: """A class to calculate and report elapsed time. Examples: @@ -506,7 +506,7 @@ def _clear_timers_except(timer, to_retain): timer.timers.pop(key) -class _HierarchicalHelper(object): +class _HierarchicalHelper: def __init__(self): self.tic_toc = TicTocTimer() self.timers = dict() @@ -589,7 +589,7 @@ def clear_except(self, *args): _clear_timers_except(self, to_retain) -class HierarchicalTimer(object): +class HierarchicalTimer: """A class for collecting and displaying hierarchical timing information diff --git a/pyomo/common/unittest.py b/pyomo/common/unittest.py index a332e38deee..2e6fbc33088 100644 --- a/pyomo/common/unittest.py +++ b/pyomo/common/unittest.py @@ -687,7 +687,7 @@ def assertExpressionsStructurallyEqual( ) -class BaselineTestDriver(object): +class BaselineTestDriver: """Generic driver for performing baseline tests in bulk This test driver was originally crafted for testing the examples in diff --git a/pyomo/contrib/ampl_function_demo/build.py b/pyomo/contrib/ampl_function_demo/build.py index 10b9667aded..34ae538ce6e 100644 --- a/pyomo/contrib/ampl_function_demo/build.py +++ b/pyomo/contrib/ampl_function_demo/build.py @@ -23,7 +23,7 @@ def build_ampl_function_demo(user_args=[], parallel=None): ) -class AMPLFunctionDemoBuilder(object): +class AMPLFunctionDemoBuilder: def __call__(self, parallel): return build_ampl_function_demo(parallel=parallel) diff --git a/pyomo/contrib/appsi/base.py b/pyomo/contrib/appsi/base.py index 0f7cfda4437..f08c295f07e 100644 --- a/pyomo/contrib/appsi/base.py +++ b/pyomo/contrib/appsi/base.py @@ -379,7 +379,7 @@ def get_reduced_costs( return rc -class Results(object): +class Results: """ Base class for all APPSI solver results @@ -1512,7 +1512,7 @@ def update(self, timer: HierarchicalTimer = None): } -class LegacySolverInterface(object): +class LegacySolverInterface: def solve( self, model: BlockData, diff --git a/pyomo/contrib/appsi/build.py b/pyomo/contrib/appsi/build.py index 3412fb9fc42..e07681ddb1a 100644 --- a/pyomo/contrib/appsi/build.py +++ b/pyomo/contrib/appsi/build.py @@ -108,7 +108,7 @@ def run(self): pybind11.setup_helpers.MACOS = original_pybind11_setup_helpers_macos -class AppsiBuilder(object): +class AppsiBuilder: def __call__(self, parallel): return build_appsi() diff --git a/pyomo/contrib/appsi/solvers/gurobi.py b/pyomo/contrib/appsi/solvers/gurobi.py index 6bf1d39fd5f..123aef6ae25 100644 --- a/pyomo/contrib/appsi/solvers/gurobi.py +++ b/pyomo/contrib/appsi/solvers/gurobi.py @@ -111,7 +111,7 @@ def __init__(self, solver): self.solution_loader = GurobiSolutionLoader(solver=solver) -class _MutableLowerBound(object): +class _MutableLowerBound: def __init__(self, expr): self.var = None self.expr = expr @@ -120,7 +120,7 @@ def update(self): self.var.setAttr('lb', value(self.expr)) -class _MutableUpperBound(object): +class _MutableUpperBound: def __init__(self, expr): self.var = None self.expr = expr @@ -129,7 +129,7 @@ def update(self): self.var.setAttr('ub', value(self.expr)) -class _MutableLinearCoefficient(object): +class _MutableLinearCoefficient: def __init__(self): self.expr = None self.var = None @@ -140,7 +140,7 @@ def update(self): self.gurobi_model.chgCoeff(self.con, self.var, value(self.expr)) -class _MutableRangeConstant(object): +class _MutableRangeConstant: def __init__(self): self.lhs_expr = None self.rhs_expr = None @@ -156,7 +156,7 @@ def update(self): slack.ub = rhs_val - lhs_val -class _MutableConstant(object): +class _MutableConstant: def __init__(self): self.expr = None self.con = None @@ -165,7 +165,7 @@ def update(self): self.con.rhs = value(self.expr) -class _MutableQuadraticConstraint(object): +class _MutableQuadraticConstraint: def __init__( self, gurobi_model, gurobi_con, constant, linear_coefs, quadratic_coefs ): @@ -200,7 +200,7 @@ def get_updated_rhs(self): return value(self.constant.expr) -class _MutableObjective(object): +class _MutableObjective: def __init__(self, gurobi_model, constant, linear_coefs, quadratic_coefs): self.gurobi_model = gurobi_model self.constant = constant @@ -228,7 +228,7 @@ def get_updated_expression(self): return gurobi_expr -class _MutableQuadraticCoefficient(object): +class _MutableQuadraticCoefficient: def __init__(self): self.expr = None self.var1 = None diff --git a/pyomo/contrib/appsi/solvers/highs.py b/pyomo/contrib/appsi/solvers/highs.py index ffeb8023ff2..fc9b750276e 100644 --- a/pyomo/contrib/appsi/solvers/highs.py +++ b/pyomo/contrib/appsi/solvers/highs.py @@ -83,7 +83,7 @@ def __init__(self, solver): self.solution_loader = PersistentSolutionLoader(solver=solver) -class _MutableVarBounds(object): +class _MutableVarBounds: def __init__(self, lower_expr, upper_expr, pyomo_var_id, var_map, highs): self.pyomo_var_id = pyomo_var_id self.lower_expr = lower_expr @@ -98,7 +98,7 @@ def update(self): self.highs.changeColBounds(col_ndx, lb, ub) -class _MutableLinearCoefficient(object): +class _MutableLinearCoefficient: def __init__(self, pyomo_con, pyomo_var_id, con_map, var_map, expr, highs): self.expr = expr self.highs = highs @@ -113,7 +113,7 @@ def update(self): self.highs.changeCoeff(row_ndx, col_ndx, value(self.expr)) -class _MutableObjectiveCoefficient(object): +class _MutableObjectiveCoefficient: def __init__(self, pyomo_var_id, var_map, expr, highs): self.expr = expr self.highs = highs @@ -125,7 +125,7 @@ def update(self): self.highs.changeColCost(col_ndx, value(self.expr)) -class _MutableObjectiveOffset(object): +class _MutableObjectiveOffset: def __init__(self, expr, highs): self.expr = expr self.highs = highs @@ -134,7 +134,7 @@ def update(self): self.highs.changeObjectiveOffset(value(self.expr)) -class _MutableConstraintBounds(object): +class _MutableConstraintBounds: def __init__(self, lower_expr, upper_expr, pyomo_con, con_map, highs): self.lower_expr = lower_expr self.upper_expr = upper_expr diff --git a/pyomo/contrib/appsi/writers/config.py b/pyomo/contrib/appsi/writers/config.py index 8d7d3ffe6b4..0481d4bf301 100644 --- a/pyomo/contrib/appsi/writers/config.py +++ b/pyomo/contrib/appsi/writers/config.py @@ -10,6 +10,6 @@ # ___________________________________________________________________________ -class WriterConfig(object): +class WriterConfig: def __init__(self): self.symbolic_solver_labels = False diff --git a/pyomo/contrib/benders/examples/farmer.py b/pyomo/contrib/benders/examples/farmer.py index d932caa4520..85e9782b519 100644 --- a/pyomo/contrib/benders/examples/farmer.py +++ b/pyomo/contrib/benders/examples/farmer.py @@ -25,7 +25,7 @@ """ -class Farmer(object): +class Farmer: def __init__(self): self.crops = ['WHEAT', 'CORN', 'SUGAR_BEETS'] self.total_acreage = 500 diff --git a/pyomo/contrib/benders/tests/test_benders.py b/pyomo/contrib/benders/tests/test_benders.py index 9e45f383959..86170ed6de9 100644 --- a/pyomo/contrib/benders/tests/test_benders.py +++ b/pyomo/contrib/benders/tests/test_benders.py @@ -29,7 +29,7 @@ class MPITestBenders(unittest.TestCase): @unittest.skipIf(not numpy_available, 'numpy is not available.') @unittest.skipIf(not mip_available, 'MIP solver is not available.') def test_farmer(self): - class Farmer(object): + class Farmer: def __init__(self): self.crops = ['WHEAT', 'CORN', 'SUGAR_BEETS'] self.total_acreage = 500 @@ -252,7 +252,7 @@ def create_subproblem(root): @unittest.skipIf(not numpy_available, 'numpy is not available.') @unittest.skipIf(not mip_available, 'MIP solver is not available.') def test_four_scen_farmer(self): - class FourScenFarmer(object): + class FourScenFarmer: def __init__(self): self.crops = ['WHEAT', 'CORN', 'SUGAR_BEETS'] self.total_acreage = 500 diff --git a/pyomo/contrib/community_detection/detection.py b/pyomo/contrib/community_detection/detection.py index b81e5927407..ef6bb3af77b 100644 --- a/pyomo/contrib/community_detection/detection.py +++ b/pyomo/contrib/community_detection/detection.py @@ -282,7 +282,7 @@ def detect_communities( ) -class CommunityMap(object): +class CommunityMap: """ This class is used to create CommunityMap objects which are returned by the detect_communities function. Instances of this class allow dict-like usage and store relevant information about the given community map, such as the diff --git a/pyomo/contrib/cp/repn/docplex_writer.py b/pyomo/contrib/cp/repn/docplex_writer.py index c8ef259f847..b115af48f37 100644 --- a/pyomo/contrib/cp/repn/docplex_writer.py +++ b/pyomo/contrib/cp/repn/docplex_writer.py @@ -127,65 +127,65 @@ def _finalize_docplex(module, available): # These are things that don't need special handling: -class _GENERAL(object): +class _GENERAL: pass # These are operations that need to be deferred sometimes, usually because of # indirection: -class _START_TIME(object): +class _START_TIME: pass -class _END_TIME(object): +class _END_TIME: pass -class _DEFERRED_ELEMENT_CONSTRAINT(object): +class _DEFERRED_ELEMENT_CONSTRAINT: pass -class _ELEMENT_CONSTRAINT(object): +class _ELEMENT_CONSTRAINT: pass -class _DEFERRED_BEFORE(object): +class _DEFERRED_BEFORE: pass -class _DEFERRED_AFTER(object): +class _DEFERRED_AFTER: pass -class _DEFERRED_AT(object): +class _DEFERRED_AT: pass -class _BEFORE(object): +class _BEFORE: pass -class _AT(object): +class _AT: pass -class _IMPLIES(object): +class _IMPLIES: pass -class _LAND(object): +class _LAND: pass -class _LOR(object): +class _LOR: pass -class _XOR(object): +class _XOR: pass -class _EQUIVALENT_TO(object): +class _EQUIVALENT_TO: pass @@ -1130,7 +1130,7 @@ def collect_valid_components(model, active=True, sort=None, valid=set(), targets @WriterFactory.register( 'docplex_model', 'Generate the corresponding docplex model object' ) -class DocplexWriter(object): +class DocplexWriter: CONFIG = ConfigDict('docplex_model_writer') CONFIG.declare( 'symbolic_solver_labels', @@ -1247,7 +1247,7 @@ def write(self, model, **options): @SolverFactory.register('cp_optimizer', doc='Direct interface to CPLEX CP Optimizer') -class CPOptimizerSolver(object): +class CPOptimizerSolver: CONFIG = ConfigDict("cp_optimizer_solver") CONFIG.declare( 'symbolic_solver_labels', diff --git a/pyomo/contrib/cspline_external/build.py b/pyomo/contrib/cspline_external/build.py index 4fc573d6710..15c1032f6f4 100644 --- a/pyomo/contrib/cspline_external/build.py +++ b/pyomo/contrib/cspline_external/build.py @@ -23,7 +23,7 @@ def build_cspline_external(user_args=[], parallel=None): ) -class ASLCsplineExternalBuilder(object): +class ASLCsplineExternalBuilder: def __call__(self, parallel): return build_cspline_external(parallel=parallel) diff --git a/pyomo/contrib/doe/tests/experiment_class_example_flags.py b/pyomo/contrib/doe/tests/experiment_class_example_flags.py index fc2acb816e5..4fcdff3e482 100644 --- a/pyomo/contrib/doe/tests/experiment_class_example_flags.py +++ b/pyomo/contrib/doe/tests/experiment_class_example_flags.py @@ -45,7 +45,7 @@ def expand_model_components(m, base_components, index_sets): yield val[j] -class BadExperiment(object): +class BadExperiment: def __init__(self): self.model = None diff --git a/pyomo/contrib/fbbt/fbbt.py b/pyomo/contrib/fbbt/fbbt.py index c1f6fd4ad01..053ed129bf5 100644 --- a/pyomo/contrib/fbbt/fbbt.py +++ b/pyomo/contrib/fbbt/fbbt.py @@ -1579,7 +1579,7 @@ def compute_bounds_on_expr(expr, ignore_fixed=False): return lb, ub -class BoundsManager(object): +class BoundsManager: def __init__(self, comp): self._vars = ComponentSet() self._saved_bounds = list() diff --git a/pyomo/contrib/fbbt/interval.py b/pyomo/contrib/fbbt/interval.py index 3d96dd14f36..f987c92c97a 100644 --- a/pyomo/contrib/fbbt/interval.py +++ b/pyomo/contrib/fbbt/interval.py @@ -17,7 +17,7 @@ inf = float('inf') -class _bool_flag(object): +class _bool_flag: def __init__(self, val): self._val = val diff --git a/pyomo/contrib/fbbt/tests/test_fbbt.py b/pyomo/contrib/fbbt/tests/test_fbbt.py index d5a56232537..8c8913fa3e5 100644 --- a/pyomo/contrib/fbbt/tests/test_fbbt.py +++ b/pyomo/contrib/fbbt/tests/test_fbbt.py @@ -33,7 +33,7 @@ class DummyExpr(ProductExpression): pass -class FbbtTestBase(object): +class FbbtTestBase: """ These tests are set up weird, but it is for a good reason. The FBBT code is duplicated in pyomo.contrib.appsi for diff --git a/pyomo/contrib/fbbt/tests/test_interval.py b/pyomo/contrib/fbbt/tests/test_interval.py index c27c3a48491..8ab9e88d79b 100644 --- a/pyomo/contrib/fbbt/tests/test_interval.py +++ b/pyomo/contrib/fbbt/tests/test_interval.py @@ -23,7 +23,7 @@ def isfinite(x): return not (math.isnan(x) or math.isinf(x)) -class IntervalTestBase(object): +class IntervalTestBase: """ These tests are set up weird, but it is for a good reason. The interval arithmetic code is duplicated in pyomo.contrib.appsi for diff --git a/pyomo/contrib/gdpopt/GDPopt.py b/pyomo/contrib/gdpopt/GDPopt.py index dbfdc0ecfc2..96d36447ac4 100644 --- a/pyomo/contrib/gdpopt/GDPopt.py +++ b/pyomo/contrib/gdpopt/GDPopt.py @@ -67,7 +67,7 @@ def _handle_strategy_deprecation(config): doc='The GDPopt decomposition-based ' 'Generalized Disjunctive Programming (GDP) solver', ) -class GDPoptSolver(object): +class GDPoptSolver: """Decomposition solver for Generalized Disjunctive Programming (GDP) problems. diff --git a/pyomo/contrib/gdpopt/oa_algorithm_utils.py b/pyomo/contrib/gdpopt/oa_algorithm_utils.py index d0410dd68b9..d06f48da9af 100644 --- a/pyomo/contrib/gdpopt/oa_algorithm_utils.py +++ b/pyomo/contrib/gdpopt/oa_algorithm_utils.py @@ -16,7 +16,7 @@ from pyomo.opt import TerminationCondition as tc -class _OAAlgorithmMixIn(object): +class _OAAlgorithmMixIn: def _fix_discrete_soln_solve_subproblem_and_add_cuts( self, discrete_prob_util_block, subprob_util_block, config ): diff --git a/pyomo/contrib/gdpopt/solve_subproblem.py b/pyomo/contrib/gdpopt/solve_subproblem.py index efb2cf6336c..bd71a07193d 100644 --- a/pyomo/contrib/gdpopt/solve_subproblem.py +++ b/pyomo/contrib/gdpopt/solve_subproblem.py @@ -240,7 +240,7 @@ def detect_unfixed_discrete_vars(model): return var_set -class preprocess_subproblem(object): +class preprocess_subproblem: def __init__(self, util_block, config): self.util_block = util_block self.config = config diff --git a/pyomo/contrib/gdpopt/util.py b/pyomo/contrib/gdpopt/util.py index 43ca8a6e277..5d63ac8affa 100644 --- a/pyomo/contrib/gdpopt/util.py +++ b/pyomo/contrib/gdpopt/util.py @@ -37,7 +37,7 @@ from pyomo.opt import SolverFactory -class _DoNothing(object): +class _DoNothing: """Do nothing, literally. This class is used in situations of "do something if attribute exists." @@ -56,7 +56,7 @@ def _do_nothing(*args, **kwargs): return _do_nothing -class SuppressInfeasibleWarning(object): +class SuppressInfeasibleWarning: """Suppress the infeasible model warning message from solve(). The "WARNING: Loading a SolverResults object with a warning status" warning @@ -217,7 +217,7 @@ def fix_discrete_var(var, val, config): var.fix(val, skip_validation=True) -class fix_discrete_solution_in_subproblem(object): +class fix_discrete_solution_in_subproblem: def __init__( self, true_disjuncts, diff --git a/pyomo/contrib/incidence_analysis/interface.py b/pyomo/contrib/incidence_analysis/interface.py index 45a783019b7..8467ab69b95 100644 --- a/pyomo/contrib/incidence_analysis/interface.py +++ b/pyomo/contrib/incidence_analysis/interface.py @@ -244,7 +244,7 @@ def get_numeric_incidence_matrix(variables, constraints): return nlp.extract_submatrix_jacobian(variables, constraints) -class IncidenceGraphInterface(object): +class IncidenceGraphInterface: """An interface for applying graph algorithms to Pyomo variables and constraints diff --git a/pyomo/contrib/incidence_analysis/tests/test_incidence.py b/pyomo/contrib/incidence_analysis/tests/test_incidence.py index 1018a77c139..38ad30f2511 100644 --- a/pyomo/contrib/incidence_analysis/tests/test_incidence.py +++ b/pyomo/contrib/incidence_analysis/tests/test_incidence.py @@ -38,7 +38,7 @@ def test_uninitialized_value_error_message(self): pyo.value(1 + m.x[1] * m.x[2]) -class _TestIncidence(object): +class _TestIncidence: """Base class with tests for get_incident_variables that should be independent of the method used @@ -73,7 +73,7 @@ def test_incidence_with_named_expression(self): self.assertEqual(ComponentSet(variables), ComponentSet(m.x[:])) -class _TestIncidenceLinearOnly(object): +class _TestIncidenceLinearOnly: """Tests for methods that support linear_only""" def _get_incident_variables(self, expr): @@ -99,7 +99,7 @@ def test_linear_only(self): self.assertEqual(ComponentSet(variables), ComponentSet([m.x[1], m.x[2]])) -class _TestIncidenceLinearCancellation(object): +class _TestIncidenceLinearCancellation: """Tests for methods that perform linear cancellation""" def _get_incident_variables(self, expr): diff --git a/pyomo/contrib/interior_point/interior_point.py b/pyomo/contrib/interior_point/interior_point.py index f67b3c2cd7f..ca901c84c50 100644 --- a/pyomo/contrib/interior_point/interior_point.py +++ b/pyomo/contrib/interior_point/interior_point.py @@ -39,7 +39,7 @@ class InteriorPointStatus(enum.Enum): error = 1 -class LinearSolveContext(object): +class LinearSolveContext: def __init__( self, interior_point_logger, @@ -76,7 +76,7 @@ def __exit__(self, et, ev, tb): # # Define a method for logging IP_reg_info to the linear solver log # Method can be called within linear_solve_context -class FactorizationContext(object): +class FactorizationContext: def __init__(self, logger): # Any reason to pass in a logging level here? # ^ So the "regularization log" can have its own outlvl @@ -126,7 +126,7 @@ def log_info(self, _iter, reg_iter, num_realloc, coef, neg_eig, status): ) -class InteriorPointSolver(object): +class InteriorPointSolver: """ Class for creating interior point solvers with different options """ diff --git a/pyomo/contrib/mcpp/build.py b/pyomo/contrib/mcpp/build.py index b6975f1a4c1..d0686f29cdb 100644 --- a/pyomo/contrib/mcpp/build.py +++ b/pyomo/contrib/mcpp/build.py @@ -102,7 +102,7 @@ def get_ext_filename(self, ext_name): shutil.rmtree(tmpdir) -class MCPPBuilder(object): +class MCPPBuilder: def __call__(self, parallel): return build_mcpp() diff --git a/pyomo/contrib/mcpp/pyomo_mcpp.py b/pyomo/contrib/mcpp/pyomo_mcpp.py index 5146cb4a0a7..3d0e8de1cfa 100644 --- a/pyomo/contrib/mcpp/pyomo_mcpp.py +++ b/pyomo/contrib/mcpp/pyomo_mcpp.py @@ -384,7 +384,7 @@ def finalizeResult(self, node_result): return node_result -class McCormick(object): +class McCormick: """ This class takes the constructed expression from MCPP_Visitor and allows for MC methods to be performed on pyomo expressions. diff --git a/pyomo/contrib/mindtpy/MindtPy.py b/pyomo/contrib/mindtpy/MindtPy.py index 1a8d807ffaf..a79f03d8979 100644 --- a/pyomo/contrib/mindtpy/MindtPy.py +++ b/pyomo/contrib/mindtpy/MindtPy.py @@ -70,7 +70,7 @@ @SolverFactory.register( 'mindtpy', doc='MindtPy: Mixed-Integer Nonlinear Decomposition Toolbox in Pyomo' ) -class MindtPySolver(object): +class MindtPySolver: """ Decomposition solver for Mixed-Integer Nonlinear Programming (MINLP) problems. diff --git a/pyomo/contrib/mindtpy/algorithm_base_class.py b/pyomo/contrib/mindtpy/algorithm_base_class.py index 53bed15e018..bdabd263072 100644 --- a/pyomo/contrib/mindtpy/algorithm_base_class.py +++ b/pyomo/contrib/mindtpy/algorithm_base_class.py @@ -83,7 +83,7 @@ ) -class _MindtPyAlgorithm(object): +class _MindtPyAlgorithm: def __init__(self, **kwds): """ This is a common init method for all the MindtPy algorithms, so that we diff --git a/pyomo/contrib/mpc/data/dynamic_data_base.py b/pyomo/contrib/mpc/data/dynamic_data_base.py index 095442fc7d3..4115c74c522 100644 --- a/pyomo/contrib/mpc/data/dynamic_data_base.py +++ b/pyomo/contrib/mpc/data/dynamic_data_base.py @@ -38,7 +38,7 @@ def _is_iterable(obj): raise err -class _DynamicDataBase(object): +class _DynamicDataBase: """ A base class for storing data associated with time-indexed variables. diff --git a/pyomo/contrib/mpc/interfaces/model_interface.py b/pyomo/contrib/mpc/interfaces/model_interface.py index a38a31c7b6f..a4934b7528e 100644 --- a/pyomo/contrib/mpc/interfaces/model_interface.py +++ b/pyomo/contrib/mpc/interfaces/model_interface.py @@ -49,7 +49,7 @@ def _to_iterable(item): yield item -class DynamicModelInterface(object): +class DynamicModelInterface: """A helper class for working with dynamic models, e.g. those where many components are indexed by some ordered set referred to as "time." diff --git a/pyomo/contrib/mpc/interfaces/var_linker.py b/pyomo/contrib/mpc/interfaces/var_linker.py index 1f3731163fd..5da4821f22c 100644 --- a/pyomo/contrib/mpc/interfaces/var_linker.py +++ b/pyomo/contrib/mpc/interfaces/var_linker.py @@ -12,7 +12,7 @@ from pyomo.contrib.mpc.interfaces.copy_values import copy_values_at_time -class DynamicVarLinker(object): +class DynamicVarLinker: """ The purpose of this class is so that we do not have to call find_component or construct ComponentUIDs in a loop diff --git a/pyomo/contrib/multistart/multi.py b/pyomo/contrib/multistart/multi.py index 8cdc43143f0..5b15f65c92f 100644 --- a/pyomo/contrib/multistart/multi.py +++ b/pyomo/contrib/multistart/multi.py @@ -30,7 +30,7 @@ @SolverFactory.register('multistart', doc='MultiStart solver for NLPs') @document_kwargs_from_configdict('CONFIG') -class MultiStart(object): +class MultiStart: """Solver wrapper that initializes at multiple starting points. # TODO: also return appropriate duals diff --git a/pyomo/contrib/parmest/parmest.py b/pyomo/contrib/parmest/parmest.py index ea9dfc00640..4f173811b5a 100644 --- a/pyomo/contrib/parmest/parmest.py +++ b/pyomo/contrib/parmest/parmest.py @@ -235,7 +235,7 @@ def SSE(model): return expr -class Estimator(object): +class Estimator: """ Parameter estimation class @@ -1425,7 +1425,7 @@ def group_data(data, groupby_column_name, use_mean=None): return grouped_data -class _DeprecatedSecondStageCostExpr(object): +class _DeprecatedSecondStageCostExpr: """ Class to pass objective expression into the Pyomo model """ @@ -1438,7 +1438,7 @@ def __call__(self, model): return self._ssc_function(model, self._data) -class _DeprecatedEstimator(object): +class _DeprecatedEstimator: """ Parameter estimation class diff --git a/pyomo/contrib/parmest/scenariocreator.py b/pyomo/contrib/parmest/scenariocreator.py index 3be02967a63..82b0b2de588 100644 --- a/pyomo/contrib/parmest/scenariocreator.py +++ b/pyomo/contrib/parmest/scenariocreator.py @@ -19,7 +19,7 @@ logger = logging.getLogger(__name__) -class ScenarioSet(object): +class ScenarioSet: """ Class to hold scenario sets @@ -94,7 +94,7 @@ def write_csv(self, filename): f.write('\n') -class ParmestScen(object): +class ParmestScen: """A little container for scenarios; the Args are the attributes. Args: @@ -113,7 +113,7 @@ def __init__(self, name, ThetaVals, probability): ############################################################ -class ScenarioCreator(object): +class ScenarioCreator: """Create scenarios from parmest. Args: diff --git a/pyomo/contrib/pynumero/algorithms/solvers/cyipopt_solver.py b/pyomo/contrib/pynumero/algorithms/solvers/cyipopt_solver.py index 9464cfa53f8..d7ed9ff35cd 100644 --- a/pyomo/contrib/pynumero/algorithms/solvers/cyipopt_solver.py +++ b/pyomo/contrib/pynumero/algorithms/solvers/cyipopt_solver.py @@ -180,7 +180,7 @@ } -class CyIpoptSolver(object): +class CyIpoptSolver: def __init__(self, problem_interface, options=None): """Create an instance of the CyIpoptSolver. You must provide a problem_interface that corresponds to @@ -243,7 +243,7 @@ def _numpy_vector(val): return ans -class PyomoCyIpoptSolver(object): +class PyomoCyIpoptSolver: CONFIG = ConfigBlock("cyipopt") CONFIG.declare( "tee", diff --git a/pyomo/contrib/pynumero/algorithms/solvers/implicit_functions.py b/pyomo/contrib/pynumero/algorithms/solvers/implicit_functions.py index a0c69507a0b..d16b738b8fc 100644 --- a/pyomo/contrib/pynumero/algorithms/solvers/implicit_functions.py +++ b/pyomo/contrib/pynumero/algorithms/solvers/implicit_functions.py @@ -38,7 +38,7 @@ ) -class NlpSolverBase(object): +class NlpSolverBase: """A base class that solves an NLP object Subclasses should implement this interface for compatibility with @@ -118,7 +118,7 @@ def solve(self, x0=None): return res -class PyomoImplicitFunctionBase(object): +class PyomoImplicitFunctionBase: """A base class defining an API for implicit functions defined using Pyomo components. In particular, this is the API required by ExternalPyomoModel. diff --git a/pyomo/contrib/pynumero/algorithms/solvers/scipy_solvers.py b/pyomo/contrib/pynumero/algorithms/solvers/scipy_solvers.py index a4c28392c24..ba3fb6e30cf 100644 --- a/pyomo/contrib/pynumero/algorithms/solvers/scipy_solvers.py +++ b/pyomo/contrib/pynumero/algorithms/solvers/scipy_solvers.py @@ -255,7 +255,7 @@ def solve(self, x0=None): return results -class PyomoScipySolver(object): +class PyomoScipySolver: def __init__(self, options=None): if options is None: options = {} diff --git a/pyomo/contrib/pynumero/algorithms/solvers/square_solver_base.py b/pyomo/contrib/pynumero/algorithms/solvers/square_solver_base.py index 43f48211d3d..e4b9de6387b 100644 --- a/pyomo/contrib/pynumero/algorithms/solvers/square_solver_base.py +++ b/pyomo/contrib/pynumero/algorithms/solvers/square_solver_base.py @@ -15,7 +15,7 @@ from pyomo.util.subsystems import create_subsystem_block -class SquareNlpSolverBase(object): +class SquareNlpSolverBase: """A base class for NLP solvers that act on a square system of equality constraints. diff --git a/pyomo/contrib/pynumero/algorithms/solvers/tests/test_implicit_functions.py b/pyomo/contrib/pynumero/algorithms/solvers/tests/test_implicit_functions.py index b2e9b9eace7..d2893a7f9f8 100644 --- a/pyomo/contrib/pynumero/algorithms/solvers/tests/test_implicit_functions.py +++ b/pyomo/contrib/pynumero/algorithms/solvers/tests/test_implicit_functions.py @@ -42,7 +42,7 @@ ) -class ImplicitFunction1(object): +class ImplicitFunction1: def __init__(self): self._model = self._make_model() @@ -137,7 +137,7 @@ def _make_model(self): return m -class ImplicitFunctionInputsDontAppear(object): +class ImplicitFunctionInputsDontAppear: """This is an implicit function designed to test the edge case where inputs do not appear in the system defining the implicit function (i.e. the function is constant). diff --git a/pyomo/contrib/pynumero/asl.py b/pyomo/contrib/pynumero/asl.py index cffaaeecc35..e28b8d60240 100644 --- a/pyomo/contrib/pynumero/asl.py +++ b/pyomo/contrib/pynumero/asl.py @@ -239,7 +239,7 @@ def _LoadASLInterface(libname): return ASLib, interface_version -class AmplInterface(object): +class AmplInterface: libname = _NotSet ASLib = None interface_version = None diff --git a/pyomo/contrib/pynumero/build.py b/pyomo/contrib/pynumero/build.py index 015c7246850..94bb9fea148 100644 --- a/pyomo/contrib/pynumero/build.py +++ b/pyomo/contrib/pynumero/build.py @@ -23,7 +23,7 @@ def build_pynumero(user_args=[], parallel=None): ) -class PyNumeroBuilder(object): +class PyNumeroBuilder: def __call__(self, parallel): return build_pynumero(parallel=parallel) diff --git a/pyomo/contrib/pynumero/examples/callback/cyipopt_functor_callback.py b/pyomo/contrib/pynumero/examples/callback/cyipopt_functor_callback.py index 98d2e786b2d..24781b6ef68 100644 --- a/pyomo/contrib/pynumero/examples/callback/cyipopt_functor_callback.py +++ b/pyomo/contrib/pynumero/examples/callback/cyipopt_functor_callback.py @@ -19,7 +19,7 @@ """ -class ResidualsTableCallback(object): +class ResidualsTableCallback: def __init__(self): self._residuals = None diff --git a/pyomo/contrib/pynumero/interfaces/external_grey_box.py b/pyomo/contrib/pynumero/interfaces/external_grey_box.py index c4ed59ee19f..ec0c1b35b29 100644 --- a/pyomo/contrib/pynumero/interfaces/external_grey_box.py +++ b/pyomo/contrib/pynumero/interfaces/external_grey_box.py @@ -89,7 +89,7 @@ """ -class ExternalGreyBoxModel(object): +class ExternalGreyBoxModel: """ This is the base class for building external input output models for use with Pyomo and CyIpopt. See the module documentation above, diff --git a/pyomo/contrib/pynumero/interfaces/pyomo_nlp.py b/pyomo/contrib/pynumero/interfaces/pyomo_nlp.py index 78e8ca5faa5..62696e3b9c9 100644 --- a/pyomo/contrib/pynumero/interfaces/pyomo_nlp.py +++ b/pyomo/contrib/pynumero/interfaces/pyomo_nlp.py @@ -1185,7 +1185,7 @@ def load_state_into_pyomo(self, bound_multipliers=None): ) -class _ExternalGreyBoxModelHelper(object): +class _ExternalGreyBoxModelHelper: def __init__(self, ex_grey_box_block, vardata_to_idx, con_offset): """This helper takes an ExternalGreyBoxModel and provides the residual, Jacobian, and Hessian computation mapped to the correct variable space. diff --git a/pyomo/contrib/pynumero/interfaces/tests/test_external_pyomo_model.py b/pyomo/contrib/pynumero/interfaces/tests/test_external_pyomo_model.py index f446951c643..213fdae2914 100644 --- a/pyomo/contrib/pynumero/interfaces/tests/test_external_pyomo_model.py +++ b/pyomo/contrib/pynumero/interfaces/tests/test_external_pyomo_model.py @@ -47,7 +47,7 @@ raise unittest.SkipTest("Need IPOPT to run ExternalPyomoModel tests") -class SimpleModel1(object): +class SimpleModel1: def make_model(self): m = pyo.ConcreteModel() m.x = pyo.Var(initialize=2.0) @@ -80,7 +80,7 @@ def evaluate_hessian(self, x): return 2 + 0.24 / x**4 -class SimpleModel2(object): +class SimpleModel2: """ The purpose of this model is to exercise each term in the computation of the d2ydx2 Hessian. @@ -113,7 +113,7 @@ def evaluate_hessian(self, x): return 2 + 6 * 0.2 ** (2 / 3) / x**4 -class SimpleModel2by2_1(object): +class SimpleModel2by2_1: """ The purpose of this model is to test second derivative computation when the external model is nonlinear only in x. This exercises @@ -228,7 +228,7 @@ def evaluate_external_hessian(self, x): return [dy0dxdx, dy1dxdx] -class Model2by2(object): +class Model2by2: """ The purpose of this model is to test d2ydx2 Hessian computation when transposes result in a nontrivial modification of Hessian/Jacobian diff --git a/pyomo/contrib/pynumero/interfaces/utils.py b/pyomo/contrib/pynumero/interfaces/utils.py index 01f495eba09..1cfd36d0725 100644 --- a/pyomo/contrib/pynumero/interfaces/utils.py +++ b/pyomo/contrib/pynumero/interfaces/utils.py @@ -143,7 +143,7 @@ def make_lower_triangular_full(lower_triangular_matrix): return coo_matrix((data, (row, col)), shape=lower_triangular_matrix.shape) -class CondensedSparseSummation(object): +class CondensedSparseSummation: def __init__(self, list_of_matrices): """ This class is used to perform a summation of sparse matrices diff --git a/pyomo/contrib/pynumero/linalg/base.py b/pyomo/contrib/pynumero/linalg/base.py index 748a8b86114..210c549a126 100644 --- a/pyomo/contrib/pynumero/linalg/base.py +++ b/pyomo/contrib/pynumero/linalg/base.py @@ -27,7 +27,7 @@ class LinearSolverStatus(enum.Enum): max_iter = 5 -class LinearSolverResults(object): +class LinearSolverResults: def __init__(self, status: Optional[LinearSolverStatus] = None): self.status = status diff --git a/pyomo/contrib/pynumero/linalg/ma27.py b/pyomo/contrib/pynumero/linalg/ma27.py index 7d8cfc00fe3..c2a7cbbd4a3 100644 --- a/pyomo/contrib/pynumero/linalg/ma27.py +++ b/pyomo/contrib/pynumero/linalg/ma27.py @@ -16,7 +16,7 @@ import os -class MA27Interface(object): +class MA27Interface: libname = _NotSet @classmethod diff --git a/pyomo/contrib/pynumero/linalg/ma57.py b/pyomo/contrib/pynumero/linalg/ma57.py index 6f07a8fea90..bd1a0004ef2 100644 --- a/pyomo/contrib/pynumero/linalg/ma57.py +++ b/pyomo/contrib/pynumero/linalg/ma57.py @@ -17,7 +17,7 @@ import os -class MA57Interface(object): +class MA57Interface: libname = _NotSet @classmethod diff --git a/pyomo/contrib/pynumero/sparse/base_block.py b/pyomo/contrib/pynumero/sparse/base_block.py index 293ca34c6f0..42f0ec16549 100644 --- a/pyomo/contrib/pynumero/sparse/base_block.py +++ b/pyomo/contrib/pynumero/sparse/base_block.py @@ -14,7 +14,7 @@ from ..dependencies import numpy as np -class BaseBlockVector(object): +class BaseBlockVector: """Base class for block vectors""" def __init__(self): @@ -132,7 +132,7 @@ def tobytes(self, order='C'): raise NotImplementedError(msg) -class BaseBlockMatrix(object): +class BaseBlockMatrix: """Base class for block matrices""" def __init__(self): diff --git a/pyomo/contrib/pyros/config.py b/pyomo/contrib/pyros/config.py index fde4f35375b..f5d1b0da2d0 100644 --- a/pyomo/contrib/pyros/config.py +++ b/pyomo/contrib/pyros/config.py @@ -154,7 +154,7 @@ def uncertain_param_data_validator(uncertain_obj): ) -class InputDataStandardizer(object): +class InputDataStandardizer: """ Domain validator for an object that is castable to a list of Pyomo component data objects. @@ -246,7 +246,7 @@ class SolverNotResolvable(PyomoException): """ -class SolverResolvable(object): +class SolverResolvable: """ Callable for casting an object (such as a str) to a Pyomo solver. @@ -369,7 +369,7 @@ def domain_name(self): return "str or Solver" -class SolverIterable(object): +class SolverIterable: """ Callable for casting an iterable (such as a list of strs) to a list of Pyomo solvers. diff --git a/pyomo/contrib/pyros/pyros.py b/pyomo/contrib/pyros/pyros.py index 4da7b6672cd..58d34edaf18 100644 --- a/pyomo/contrib/pyros/pyros.py +++ b/pyomo/contrib/pyros/pyros.py @@ -81,7 +81,7 @@ def _get_pyomo_version_info(): doc="Robust optimization (RO) solver implementing " "the generalized robust cutting-set algorithm (GRCS)", ) -class PyROS(object): +class PyROS: ''' PyROS (Pyomo Robust Optimization Solver) implementing a generalized robust cutting-set algorithm (GRCS) diff --git a/pyomo/contrib/pyros/solve_data.py b/pyomo/contrib/pyros/solve_data.py index 03f9a9b1de3..f959ee737d6 100644 --- a/pyomo/contrib/pyros/solve_data.py +++ b/pyomo/contrib/pyros/solve_data.py @@ -14,7 +14,7 @@ """ -class ROSolveResults(object): +class ROSolveResults: """ PyROS solver results object. diff --git a/pyomo/contrib/pyros/tests/test_grcs.py b/pyomo/contrib/pyros/tests/test_grcs.py index 74cc7ad3039..d42b1c28a41 100644 --- a/pyomo/contrib/pyros/tests/test_grcs.py +++ b/pyomo/contrib/pyros/tests/test_grcs.py @@ -113,7 +113,7 @@ # @SolverFactory.register("time_delay_solver") -class TimeDelaySolver(object): +class TimeDelaySolver: """ Solver which puts program to sleep for a specified duration after having been invoked a specified number @@ -4227,7 +4227,7 @@ def test_validate_pyros_inputs_user_var_partitioning_obj_only(self): # @SolverFactory.register("subsolver_error__solver") -class SubsolverErrorSolver(object): +class SubsolverErrorSolver: """ Solver that returns a bad termination condition to purposefully create an SP subsolver error. diff --git a/pyomo/contrib/satsolver/satsolver.py b/pyomo/contrib/satsolver/satsolver.py index 07e5199f401..e8fe2d85b97 100644 --- a/pyomo/contrib/satsolver/satsolver.py +++ b/pyomo/contrib/satsolver/satsolver.py @@ -51,7 +51,7 @@ def satisfiable(model, logger=None): raise ValueError('Unknown result: %s' % result) -class SMTSatSolver(object): +class SMTSatSolver: """ Satisfiability solver that checks constraint feasibility through use of z3 Sat Solver. Object stores expressions and variables in form consistent diff --git a/pyomo/contrib/sensitivity_toolbox/k_aug.py b/pyomo/contrib/sensitivity_toolbox/k_aug.py index 6231514254d..b0bf357038c 100644 --- a/pyomo/contrib/sensitivity_toolbox/k_aug.py +++ b/pyomo/contrib/sensitivity_toolbox/k_aug.py @@ -42,7 +42,7 @@ ] -class InTempDir(object): +class InTempDir: def __init__(self, suffix=None, prefix=None, dir=None): self._suffix = suffix self._prefix = prefix @@ -63,7 +63,7 @@ def __exit__(self, ex_type, ex_val, ex_bt): TempfileManager.pop() -class K_augInterface(object): +class K_augInterface: """ k_aug and dot_sens store information in the user's filesystem, some of which is mandatory for subsequent calls. diff --git a/pyomo/contrib/sensitivity_toolbox/sens.py b/pyomo/contrib/sensitivity_toolbox/sens.py index 22ed7486311..133c9c0b614 100644 --- a/pyomo/contrib/sensitivity_toolbox/sens.py +++ b/pyomo/contrib/sensitivity_toolbox/sens.py @@ -133,7 +133,7 @@ def _add_sensitivity_suffixes(block): block.add_component(name, Suffix(direction=direction)) -class _NotAnIndex(object): +class _NotAnIndex: pass @@ -509,7 +509,7 @@ def line_num(file_name, target): raise Exception(file_name + " does not include " + target) -class SensitivityInterface(object): +class SensitivityInterface: def __init__(self, instance, clone_model=True): """Constructor clones model if necessary and attaches to this object. diff --git a/pyomo/contrib/simplification/build.py b/pyomo/contrib/simplification/build.py index 038bba32904..40ddc81a67d 100644 --- a/pyomo/contrib/simplification/build.py +++ b/pyomo/contrib/simplification/build.py @@ -176,7 +176,7 @@ def run(self): dist.run_command('build_ext') -class GiNaCInterfaceBuilder(object): +class GiNaCInterfaceBuilder: def __call__(self, parallel): return build_ginac_interface(parallel) diff --git a/pyomo/contrib/simplification/simplify.py b/pyomo/contrib/simplification/simplify.py index c59e25138dd..0c184d04cca 100644 --- a/pyomo/contrib/simplification/simplify.py +++ b/pyomo/contrib/simplification/simplify.py @@ -40,7 +40,7 @@ def simplify_with_ginac(expr: NumericExpression, ginac_interface): return ginac_interface.from_ginac(ginac_expr.normal()) -class Simplifier(object): +class Simplifier: class Mode(NamedIntEnum): auto = 0 sympy = 1 diff --git a/pyomo/contrib/trustregion/TRF.py b/pyomo/contrib/trustregion/TRF.py index 53d440845b9..7a444730774 100644 --- a/pyomo/contrib/trustregion/TRF.py +++ b/pyomo/contrib/trustregion/TRF.py @@ -428,7 +428,7 @@ def _trf_config(): 'trustregion', doc='Trust region algorithm "solver" for black box/glass box optimization', ) -class TrustRegionSolver(object): +class TrustRegionSolver: """ The Trust Region Solver is a 'solver' based on the 2016/2018/2020 AiChE papers by Eason (2016/2018), Yoshio (2020), and Biegler. diff --git a/pyomo/contrib/trustregion/interface.py b/pyomo/contrib/trustregion/interface.py index 6f8d74fb997..b075fa85577 100644 --- a/pyomo/contrib/trustregion/interface.py +++ b/pyomo/contrib/trustregion/interface.py @@ -95,7 +95,7 @@ def exitNode(self, node, data): return _output -class TRFInterface(object): +class TRFInterface: """ Pyomo interface for Trust Region algorithm. """ diff --git a/pyomo/contrib/viewer/model_browser.py b/pyomo/contrib/viewer/model_browser.py index 17ae37c1443..2365ae86fe7 100644 --- a/pyomo/contrib/viewer/model_browser.py +++ b/pyomo/contrib/viewer/model_browser.py @@ -50,11 +50,11 @@ # This lets the file be imported when the Qt UI is not available (or # when building docs), but you won't be able to use it -class _ModelBrowserUI(object): +class _ModelBrowserUI: pass -class _ModelBrowser(object): +class _ModelBrowser: pass @@ -179,7 +179,7 @@ def update_model(self): self.datmodel.update_model() -class ComponentDataItem(object): +class ComponentDataItem: """ This is a container for a Pyomo component to be displayed in a model tree view. diff --git a/pyomo/contrib/viewer/model_select.py b/pyomo/contrib/viewer/model_select.py index 39199aa8896..d05e4e4286f 100644 --- a/pyomo/contrib/viewer/model_select.py +++ b/pyomo/contrib/viewer/model_select.py @@ -39,11 +39,11 @@ # This lets the file be imported when the Qt UI is not available (or # when building docs), but you won't be able to use it -class _ModelSelectUI(object): +class _ModelSelectUI: pass -class _ModelSelect(object): +class _ModelSelect: pass diff --git a/pyomo/contrib/viewer/qt.py b/pyomo/contrib/viewer/qt.py index 0456d0299dd..bb5a6d8cc2c 100644 --- a/pyomo/contrib/viewer/qt.py +++ b/pyomo/contrib/viewer/qt.py @@ -53,24 +53,24 @@ if not available: # If Qt is not available, we still want to be able to test as much # as we can, so add some dummy classes that allow for testing - class Qt(object): + class Qt: class ItemDataRole(enum.Enum): EditRole = 1 DisplayRole = 2 ToolTipRole = 3 ForegroundRole = 4 - class QtCore(object): + class QtCore: """ A dummy QtCore class to allow some testing without PyQt """ - class QModelIndex(object): + class QModelIndex: pass Qt = Qt - class QAbstractItemModel(object): + class QAbstractItemModel: """ A dummy QAbstractItemModel class to allow some testing without PyQt """ @@ -78,7 +78,7 @@ class QAbstractItemModel(object): def __init__(*args, **kwargs): pass - class QAbstractTableModel(object): + class QAbstractTableModel: """ A dummy QAbstractTableModel class to allow some testing without PyQt """ @@ -86,14 +86,14 @@ class QAbstractTableModel(object): def __init__(*args, **kwargs): pass - class QItemEditorCreatorBase(object): + class QItemEditorCreatorBase: """ A dummy QItemEditorCreatorBase class to allow some testing without PyQt """ pass - class QItemDelegate(object): + class QItemDelegate: """ A dummy QItemDelegate class to allow some testing without PyQt """ @@ -135,8 +135,8 @@ class QItemDelegate(object): # if we are building the API documentation. if building_documentation(): - class QAbstractItemModel(object): + class QAbstractItemModel: pass - class QAbstractTableModel(object): + class QAbstractTableModel: pass diff --git a/pyomo/contrib/viewer/residual_table.py b/pyomo/contrib/viewer/residual_table.py index 51da9f8a861..11fed841b82 100644 --- a/pyomo/contrib/viewer/residual_table.py +++ b/pyomo/contrib/viewer/residual_table.py @@ -40,11 +40,11 @@ # This lets the file be imported when the Qt UI is not available (or # when building docs), but you won't be able to use it -class _ResidualTableUI(object): +class _ResidualTableUI: pass -class _ResidualTable(object): +class _ResidualTable: pass diff --git a/pyomo/contrib/viewer/tests/test_data_model_tree.py b/pyomo/contrib/viewer/tests/test_data_model_tree.py index b9fd9b8867f..67fbd688b16 100644 --- a/pyomo/contrib/viewer/tests/test_data_model_tree.py +++ b/pyomo/contrib/viewer/tests/test_data_model_tree.py @@ -51,7 +51,7 @@ import pyomo.contrib.viewer.ui as ui else: - class UIData(object): + class UIData: model = None def __init__(*args, **kwargs): diff --git a/pyomo/contrib/viewer/ui.py b/pyomo/contrib/viewer/ui.py index a3eb06d1c29..7cf96848f80 100644 --- a/pyomo/contrib/viewer/ui.py +++ b/pyomo/contrib/viewer/ui.py @@ -53,11 +53,11 @@ def get_ipython(): # This lets the file be imported when the Qt UI is not available (or # when building docs), but you won't be able to use it. Allowing this # will let some basic tests run (and pass) without PyQt -class _MainWindowUI(object): +class _MainWindowUI: pass -class _MainWindow(object): +class _MainWindow: pass diff --git a/pyomo/contrib/viewer/ui_data.py b/pyomo/contrib/viewer/ui_data.py index eecda25f037..0008c21bae6 100644 --- a/pyomo/contrib/viewer/ui_data.py +++ b/pyomo/contrib/viewer/ui_data.py @@ -33,7 +33,7 @@ _log = logging.getLogger(__name__) -class UIDataNoUi(object): +class UIDataNoUi: """ This is the UIData object minus the signals. This is the base class for UIData. The class is split this way for testing when PyQt is not available. diff --git a/pyomo/core/base/PyomoModel.py b/pyomo/core/base/PyomoModel.py index ac11ccdbdcb..c2da52eed5f 100644 --- a/pyomo/core/base/PyomoModel.py +++ b/pyomo/core/base/PyomoModel.py @@ -88,7 +88,7 @@ def __init__(self, *args, **kw): d[item[-1]] = PyomoConfig._option[item] -class ModelSolution(object): +class ModelSolution: def __init__(self): self._metadata = {} self._metadata['status'] = None @@ -147,7 +147,7 @@ def __setstate__(self, state): tmp[id(obj)] = (obj, entry) -class ModelSolutions(object): +class ModelSolutions: def __init__(self, instance): self._instance = weakref_ref(instance) self.clear() diff --git a/pyomo/core/base/block.py b/pyomo/core/base/block.py index a2d98c9d7e8..27e4ce0f6f0 100644 --- a/pyomo/core/base/block.py +++ b/pyomo/core/base/block.py @@ -56,7 +56,7 @@ logger = logging.getLogger('pyomo.core') -class _generic_component_decorator(object): +class _generic_component_decorator: """A generic decorator that wraps Block.__setattr__() Arguments @@ -83,7 +83,7 @@ def __call__(self, rule): return rule -class _component_decorator(object): +class _component_decorator: """A class that wraps the _generic_component_decorator, which remembers and provides the Block and component type to the decorator. @@ -102,7 +102,7 @@ def __call__(self, *args, **kwds): return _generic_component_decorator(self._component, self._block, *args, **kwds) -class SubclassOf(object): +class SubclassOf: """This mocks up a tuple-like interface based on subclass relationship. Instances of this class present a somewhat tuple-like interface for @@ -133,7 +133,7 @@ def __iter__(self): return iter((self,)) -class _DeduplicateInfo(object): +class _DeduplicateInfo: """Class implementing a unique component data object filter This class implements :py:meth:`unique()`, which is an efficient @@ -243,7 +243,7 @@ def _isNotNone(val): return val is not None -class _BlockConstruction(object): +class _BlockConstruction: """ This class holds a "global" dict used when constructing (hierarchical) models. @@ -2401,7 +2401,7 @@ def components_data(block, ctype, sort=None, sort_by_keys=False, sort_by_names=F BlockData._Block_reserved_words = set(dir(Block())) -class ScalarCustomBlockMixin(object): +class ScalarCustomBlockMixin: def __init__(self, *args, **kwargs): # __bases__ for the ScalarCustomBlock is # diff --git a/pyomo/core/base/boolean_var.py b/pyomo/core/base/boolean_var.py index 915ff82c0ba..46536596832 100644 --- a/pyomo/core/base/boolean_var.py +++ b/pyomo/core/base/boolean_var.py @@ -35,7 +35,7 @@ _logical_var_types = {bool, type(None)} -class _DeprecatedImplicitAssociatedBinaryVariable(object): +class _DeprecatedImplicitAssociatedBinaryVariable: __slots__ = ('_boolvar',) def __init__(self, boolvar): diff --git a/pyomo/core/base/componentuid.py b/pyomo/core/base/componentuid.py index 6be935d8fee..ba33647506f 100644 --- a/pyomo/core/base/componentuid.py +++ b/pyomo/core/base/componentuid.py @@ -27,7 +27,7 @@ from pyomo.core.base.reference import Reference -class _NotSpecified(object): +class _NotSpecified: pass @@ -49,7 +49,7 @@ def _context_err(_type): ) -class ComponentUID(object): +class ComponentUID: """ A Component unique identifier diff --git a/pyomo/core/base/config.py b/pyomo/core/base/config.py index ff2cbd7d225..68762c41e5f 100644 --- a/pyomo/core/base/config.py +++ b/pyomo/core/base/config.py @@ -20,7 +20,7 @@ logger = logging.getLogger('pyomo.core') -class _PyomoOptions(object): +class _PyomoOptions: def __init__(self): self._options_stack = [default_pyomo_config()] diff --git a/pyomo/core/base/constraint.py b/pyomo/core/base/constraint.py index d9338ab1f70..96f0afec365 100644 --- a/pyomo/core/base/constraint.py +++ b/pyomo/core/base/constraint.py @@ -959,7 +959,7 @@ class ConstraintList(IndexedConstraint): added an index value is not specified. """ - class End(object): + class End: pass def __init__(self, **kwargs): diff --git a/pyomo/core/base/indexed_component.py b/pyomo/core/base/indexed_component.py index f740dd588c1..8bbcb6fdf55 100644 --- a/pyomo/core/base/indexed_component.py +++ b/pyomo/core/base/indexed_component.py @@ -100,11 +100,11 @@ def normalize_index(x): normalize_index.flatten = True -class _NotFound(object): +class _NotFound: pass -class _NotSpecified(object): +class _NotSpecified: pass @@ -289,7 +289,7 @@ class IndexedComponent(Component): """ - class Skip(object): + class Skip: pass # @@ -1188,7 +1188,7 @@ def deactivate(self): # Ideally, this would inherit from np.lib.mixins.NDArrayOperatorsMixin, # but doing so overrides things like __contains__ in addition to the # operators that we are interested in. -class IndexedComponent_NDArrayMixin(object): +class IndexedComponent_NDArrayMixin: """Support using IndexedComponent with numpy.ndarray This IndexedComponent mixin class adds support for implicitly using diff --git a/pyomo/core/base/indexed_component_slice.py b/pyomo/core/base/indexed_component_slice.py index c0aa0049b47..56833e77002 100644 --- a/pyomo/core/base/indexed_component_slice.py +++ b/pyomo/core/base/indexed_component_slice.py @@ -19,7 +19,7 @@ from pyomo.core.base.global_set import UnindexedComponent_index -class IndexedComponent_slice(object): +class IndexedComponent_slice: """Special class for slicing through hierarchical component trees The basic concept is to interrupt the normal slice generation @@ -382,7 +382,7 @@ def _freeze(info): return info -class _slice_generator(object): +class _slice_generator: """Utility (iterator) for generating the elements of one slice Iterate through the component index and yield the component data @@ -521,11 +521,11 @@ def _advance_iter_check_complete(): # A dummy class that we can use as a named entity below -class _NotIterable(object): +class _NotIterable: pass -class _IndexedComponent_slice_iter(object): +class _IndexedComponent_slice_iter: def __init__( self, component_slice, diff --git a/pyomo/core/base/initializer.py b/pyomo/core/base/initializer.py index 6dd9890c933..ca41bdbdc3f 100644 --- a/pyomo/core/base/initializer.py +++ b/pyomo/core/base/initializer.py @@ -363,7 +363,7 @@ def __call__(self, parent, idx, *args): return self._fcn(parent, *args, idx) -class CountedCallGenerator(object): +class CountedCallGenerator: """Generator implementing the "counted call" initialization scheme This generator implements the older "counted call" scheme, where the diff --git a/pyomo/core/base/label.py b/pyomo/core/base/label.py index 3b53cdb859f..5ebcb19f1de 100644 --- a/pyomo/core/base/label.py +++ b/pyomo/core/base/label.py @@ -23,7 +23,7 @@ # they should be handled in the corresponding solver plugin. -class _CharMapper(object): +class _CharMapper: def __init__(self, preserve, translate, other): """ Arguments:: @@ -89,12 +89,12 @@ def alphanum_label_from_name(name): return str.translate(name, _alphanum_translation_table) -class CuidLabeler(object): +class CuidLabeler: def __call__(self, obj=None): return ComponentUID(obj) -class CounterLabeler(object): +class CounterLabeler: def __init__(self, start=0): self._id = start @@ -103,7 +103,7 @@ def __call__(self, obj=None): return self._id -class NumericLabeler(object): +class NumericLabeler: def __init__(self, prefix, start=0): self.id = start self.prefix = prefix @@ -132,12 +132,12 @@ def remove_obj(self, obj): # (particularly PySP), and I don't know how much depends on the labels # actually being LP-compliant. # -class CNameLabeler(object): +class CNameLabeler: def __call__(self, obj): return obj.getname(True) -class LPFileLabeler(object): +class LPFileLabeler: def __call__(self, obj): return cpxlp_label_from_name(obj.getname(True)) @@ -154,17 +154,17 @@ def remove_obj(self, obj): TextLabeler = LPFileLabeler -class AlphaNumericTextLabeler(object): +class AlphaNumericTextLabeler: def __call__(self, obj): return alphanum_label_from_name(obj.getname(True)) -class NameLabeler(object): +class NameLabeler: def __call__(self, obj): return obj.getname(True) -class ShortNameLabeler(object): +class ShortNameLabeler: def __init__( self, limit, diff --git a/pyomo/core/base/logical_constraint.py b/pyomo/core/base/logical_constraint.py index 62300d61740..3670bfb59f6 100644 --- a/pyomo/core/base/logical_constraint.py +++ b/pyomo/core/base/logical_constraint.py @@ -434,7 +434,7 @@ class LogicalConstraintList(IndexedLogicalConstraint): added an index value is not specified. """ - class End(object): + class End: pass def __init__(self, **kwargs): diff --git a/pyomo/core/base/objective.py b/pyomo/core/base/objective.py index f22a4788bba..feaadd31fbb 100644 --- a/pyomo/core/base/objective.py +++ b/pyomo/core/base/objective.py @@ -561,7 +561,7 @@ class ObjectiveList(IndexedObjective): an index value is not specified. """ - class End(object): + class End: pass def __init__(self, **kwargs): diff --git a/pyomo/core/base/param.py b/pyomo/core/base/param.py index 7944fadc430..2ede91e5bf9 100644 --- a/pyomo/core/base/param.py +++ b/pyomo/core/base/param.py @@ -299,7 +299,7 @@ class Param(IndexedComponent, IndexedComponent_NDArrayMixin): DefaultMutable = False _ComponentDataClass = ParamData - class NoValue(object): + class NoValue: """A dummy type that is pickle-safe that we can use as the default value for Params to indicate that no valid value is present.""" diff --git a/pyomo/core/base/piecewise.py b/pyomo/core/base/piecewise.py index 8654b153f87..0190ee7619b 100644 --- a/pyomo/core/base/piecewise.py +++ b/pyomo/core/base/piecewise.py @@ -277,7 +277,7 @@ class _PiecewiseData(metaclass=RenamedClass): __renamed__version__ = '6.7.2' -class _SimpleSinglePiecewise(object): +class _SimpleSinglePiecewise: """ Called when the piecewise points list has only two points """ @@ -321,7 +321,7 @@ def construct(self, pblock, x_var, y_var): ) -class _SimplifiedPiecewise(object): +class _SimplifiedPiecewise: """ Called when piecewise constraints are simplified due to a lower bounding convex function or an upper bounding concave function @@ -364,7 +364,7 @@ def construct(self, pblock, x_var, y_var): ) -class _SOS2Piecewise(object): +class _SOS2Piecewise: """ Called to generate Piecewise constraint using the SOS2 formulation """ @@ -408,7 +408,7 @@ def SOS2_rule(model): pblock.SOS2_sosconstraint = SOSConstraint(initialize=SOS2_rule, sos=2) -class _DCCPiecewise(object): +class _DCCPiecewise: """ Called to generate Piecewise constraint using the DCC formulation """ @@ -466,7 +466,7 @@ def con3_rule(model, p): pblock.DCC_constraint4 = Constraint(expr=sum(bin_y[p] for p in polytopes) == 1) -class _DLOGPiecewise(object): +class _DLOGPiecewise: """ Called to generate Piecewise constraint using the DLOG formulation """ @@ -568,7 +568,7 @@ def con5_rule(model, l): pblock.DLOG_constraint5 = Constraint(bin_y_index, rule=con5_rule) -class _CCPiecewise(object): +class _CCPiecewise: """ Called to generate Piecewise constraint using the CC formulation """ @@ -624,7 +624,7 @@ def con4_rule(model, v): pblock.CC_constraint5 = Constraint(expr=sum(bin_y[p] for p in polytopes) == 1) -class _LOGPiecewise(object): +class _LOGPiecewise: """ Called to generate Piecewise constraint using the LOG formulation """ @@ -717,7 +717,7 @@ def con5_rule(model, s): pblock.LOG_constraint5 = Constraint(bin_y_index, rule=con5_rule) -class _MCPiecewise(object): +class _MCPiecewise: """ Called to generate Piecewise constraint using the MC formulation """ @@ -774,7 +774,7 @@ def con4_rule(model, p): pblock.MC_constraint5 = Constraint(expr=sum(bin_y[p] for p in polytopes) == 1) -class _INCPiecewise(object): +class _INCPiecewise: """ Called to generate Piecewise constraint using the INC formulation """ @@ -836,7 +836,7 @@ def con4_rule(model, p): pblock.INC_constraint4 = Constraint(polytopes, rule=con4_rule) -class _BIGMPiecewise(object): +class _BIGMPiecewise: """ Called to generate Piecewise constraint using the BIGM formulation """ diff --git a/pyomo/core/base/range.py b/pyomo/core/base/range.py index 98951f16439..c4c5e71b702 100644 --- a/pyomo/core/base/range.py +++ b/pyomo/core/base/range.py @@ -681,7 +681,7 @@ def range_intersection(self, other_ranges): return ans -class NonNumericRange(object): +class NonNumericRange: """A range-like object for representing a single non-numeric value The class name is a bit of a misnomer, as this object does not @@ -758,7 +758,7 @@ def range_intersection(self, other_ranges): return [] -class AnyRange(object): +class AnyRange: """A range object for representing Any sets""" __slots__ = () @@ -803,7 +803,7 @@ def range_intersection(self, other_ranges): return list(other_ranges) -class RangeProduct(object): +class RangeProduct: """A range-like object for representing the cross product of ranges""" __slots__ = ('range_lists',) diff --git a/pyomo/core/base/reference.py b/pyomo/core/base/reference.py index 3f3d71b9137..bed54c37306 100644 --- a/pyomo/core/base/reference.py +++ b/pyomo/core/base/reference.py @@ -44,7 +44,7 @@ ) -class _fill_in_known_wildcards(object): +class _fill_in_known_wildcards: """Variant of "six.advance_iterator" that substitutes wildcard values This object is initialized with a tuple of index values. Calling diff --git a/pyomo/core/base/set.py b/pyomo/core/base/set.py index da405a4ddd9..3c00059e638 100644 --- a/pyomo/core/base/set.py +++ b/pyomo/core/base/set.py @@ -298,7 +298,7 @@ def A_rule(model, i, j): return rule_wrapper(rule, {None: Set.End}) -class UnknownSetDimen(object): +class UnknownSetDimen: pass @@ -517,7 +517,7 @@ def _tuplize(self, _val, parent, index): return (tuple(_val[i : i + d]) for i in range(0, len(_val), d)) -class _NotFound(object): +class _NotFound: "Internal type flag used to indicate if an object is not found in a set" pass @@ -1201,7 +1201,7 @@ class _SetDataBase(metaclass=RenamedClass): __renamed__version__ = '6.7.2' -class _FiniteSetMixin(object): +class _FiniteSetMixin: __slots__ = () def __len__(self): @@ -1607,7 +1607,7 @@ class _FiniteSetData(metaclass=RenamedClass): __renamed__version__ = '6.7.2' -class _ScalarOrderedSetMixin(object): +class _ScalarOrderedSetMixin: # This mixin is required because scalar ordered sets implement # __getitem__() as an alias of at() __slots__ = () @@ -1624,7 +1624,7 @@ def items(self): yield _keys[0], self -class _OrderedSetMixin(object): +class _OrderedSetMixin: __slots__ = () _valid_getitem_keys = {None, (None,), Ellipsis} @@ -1941,7 +1941,7 @@ class _InsertionOrderSetData(metaclass=RenamedClass): __renamed__version__ = '6.7.2' -class _SortedSetMixin(object): +class _SortedSetMixin: """""" __slots__ = () @@ -2117,10 +2117,10 @@ def __hash__(self): class End(metaclass=_SetEndType): pass - class InsertionOrder(object): + class InsertionOrder: pass - class SortedOrder(object): + class SortedOrder: pass _ValidOrderedArguments = {True, False, InsertionOrder, SortedOrder} diff --git a/pyomo/core/base/suffix.py b/pyomo/core/base/suffix.py index fd6b8717eec..86553552eb7 100644 --- a/pyomo/core/base/suffix.py +++ b/pyomo/core/base/suffix.py @@ -409,7 +409,7 @@ class AbstractSuffix(Suffix): pass -class SuffixFinder(object): +class SuffixFinder: def __init__(self, name, default=None, context=None): """This provides an efficient utility for finding suffix values on a (hierarchical) Pyomo model. diff --git a/pyomo/core/base/transformation.py b/pyomo/core/base/transformation.py index d2945d6bb66..7021b417ea1 100644 --- a/pyomo/core/base/transformation.py +++ b/pyomo/core/base/transformation.py @@ -17,11 +17,11 @@ from pyomo.common.timing import TransformationTimer -class TransformationInfo(object): +class TransformationInfo: pass -class TransformationData(object): +class TransformationData: """ This is a container class that supports named data objects. """ @@ -35,7 +35,7 @@ def __getitem__(self, name): return self._data[name] -class Transformation(object): +class Transformation: """ Base class for all model transformations. """ @@ -109,7 +109,7 @@ def _create_using(self, model, **kwds): return instance -class ReverseTransformationToken(object): +class ReverseTransformationToken: """ Class returned by reversible transformations' apply_to methods that can be passed back to the transformation in order to revert its changes diff --git a/pyomo/core/base/units_container.py b/pyomo/core/base/units_container.py index 96f7e85139c..f90c2295c23 100644 --- a/pyomo/core/base/units_container.py +++ b/pyomo/core/base/units_container.py @@ -944,7 +944,7 @@ def finalizeResult(self, result): return result -class PyomoUnitsContainer(object): +class PyomoUnitsContainer: """Class that is used to create and contain units in Pyomo. This is the class that is used to create, contain, and interact diff --git a/pyomo/core/expr/base.py b/pyomo/core/expr/base.py index 390cb447c0d..2a9ca66d29e 100644 --- a/pyomo/core/expr/base.py +++ b/pyomo/core/expr/base.py @@ -394,7 +394,7 @@ def _apply_operation(self, result): ) -class NPV_Mixin(object): +class NPV_Mixin: __slots__ = () def is_potentially_variable(self): @@ -426,7 +426,7 @@ def potentially_variable_base_class(self): return cls[0] -class ExpressionArgs_Mixin(object): +class ExpressionArgs_Mixin: __slots__ = ('_args_',) def __init__(self, args): diff --git a/pyomo/core/expr/numeric_expr.py b/pyomo/core/expr/numeric_expr.py index 99dc4b5b0b5..01fd739c0d3 100644 --- a/pyomo/core/expr/numeric_expr.py +++ b/pyomo/core/expr/numeric_expr.py @@ -161,7 +161,7 @@ def enable_expression_optimizations(zero=None, one=None): _zero_one_optimizations.discard(key) -class mutable_expression(object): +class mutable_expression: """Context manager for mutable sums. This context manager is used to compute a sum while treating the diff --git a/pyomo/core/expr/symbol_map.py b/pyomo/core/expr/symbol_map.py index b0265162974..22929d40494 100644 --- a/pyomo/core/expr/symbol_map.py +++ b/pyomo/core/expr/symbol_map.py @@ -10,7 +10,7 @@ # ___________________________________________________________________________ -class SymbolMap(object): +class SymbolMap: """ A class for tracking assigned labels for modeling components. diff --git a/pyomo/core/expr/sympy_tools.py b/pyomo/core/expr/sympy_tools.py index cd92f9023ff..9eb18415e37 100644 --- a/pyomo/core/expr/sympy_tools.py +++ b/pyomo/core/expr/sympy_tools.py @@ -132,7 +132,7 @@ def _configure_sympy(sympy, available): sympy, sympy_available = attempt_import('sympy', callback=_configure_sympy) -class PyomoSympyBimap(object): +class PyomoSympyBimap: def __init__(self): self.pyomo2sympy = ComponentMap() self.sympy2pyomo = {} diff --git a/pyomo/core/expr/template_expr.py b/pyomo/core/expr/template_expr.py index 90d1a39292b..bab52f81c34 100644 --- a/pyomo/core/expr/template_expr.py +++ b/pyomo/core/expr/template_expr.py @@ -48,7 +48,7 @@ logger = logging.getLogger(__name__) -class _NotSpecified(object): +class _NotSpecified: pass @@ -363,7 +363,7 @@ def _resolve_template(self, args): return self._apply_operation(args) -class _TemplateSumExpression_argList(object): +class _TemplateSumExpression_argList: """A virtual list to represent the expanded SumExpression args This class implements a "virtual args list" for @@ -726,7 +726,7 @@ def resolve_template(expr): resolve_template.visitor = None -class _wildcard_info(object): +class _wildcard_info: __slots__ = ('iter', 'source', 'value', 'original_value', 'objects') def __init__(self, src, obj): @@ -913,7 +913,7 @@ def substitute_template_expression(expr, substituter, *args, **kwargs): return visitor.walk_expression(expr) -class _GetItemIndexer(object): +class _GetItemIndexer: # Note that this class makes the assumption that only one template # ever appears in an expression for a single index @@ -1003,7 +1003,7 @@ def substitute_template_with_value(expr): return resolve_template(expr) -class _set_iterator_template_generator(object): +class _set_iterator_template_generator: """Replacement iterator that returns IndexTemplates In order to generate template expressions, we hijack the normal Set @@ -1047,7 +1047,7 @@ def __next__(self): next = __next__ -class _template_iter_context(object): +class _template_iter_context: """Manage the iteration context when generating templatized rules This class manages the context tracking when generating templatized @@ -1086,8 +1086,8 @@ def sum_template(self, generator): return TemplateSumExpression((expr,), self.npop_cache(final_cache - init_cache)) -class _template_iter_manager(object): - class _iter_wrapper(object): +class _template_iter_manager: + class _iter_wrapper: __slots__ = ('_class', '_iter', '_old_iter') def __init__(self, cls, context): @@ -1104,7 +1104,7 @@ def acquire(self): def release(self): self._class.__iter__ = self._old_iter - class _pause_template_iter_manager(object): + class _pause_template_iter_manager: __slots__ = ('iter_manager',) def __init__(self, iter_manager): diff --git a/pyomo/core/expr/visitor.py b/pyomo/core/expr/visitor.py index 2bb80c82872..c35a08b7237 100644 --- a/pyomo/core/expr/visitor.py +++ b/pyomo/core/expr/visitor.py @@ -78,7 +78,7 @@ class RevertToNonrecursive(Exception): # ------------------------------------------------------- -class StreamBasedExpressionVisitor(object): +class StreamBasedExpressionVisitor: """This class implements a generic stream-based expression walker. This visitor walks an expression tree using a depth-first strategy @@ -684,7 +684,7 @@ def _nonrecursive_walker_loop(self, ptr): "Please use the StreamBasedExpressionVisitor instead.", version='6.9.0', ) -class SimpleExpressionVisitor(object): +class SimpleExpressionVisitor: """ Note: This class is a customization of the PyUtilib :class:`SimpleVisitor @@ -819,7 +819,7 @@ def xbfs_yield_leaves(self, node): dq.append(c) -class ExpressionValueVisitor(object): +class ExpressionValueVisitor: """ Note: This class is a customization of the PyUtilib :class:`ValueVisitor diff --git a/pyomo/core/kernel/base.py b/pyomo/core/kernel/base.py index 60787a2fb70..38be7e661c8 100644 --- a/pyomo/core/kernel/base.py +++ b/pyomo/core/kernel/base.py @@ -28,7 +28,7 @@ def _abstract_readonly_property(**kwds): return p -class _no_ctype(object): +class _no_ctype: """The default argument for methods that accept a ctype.""" pass @@ -162,7 +162,7 @@ def getname( storage key into a string representation. Default is the built-in function str. - relative_to (object): When generating a fully + relative_to : When generating a fully qualified name, generate the name relative to this block. diff --git a/pyomo/core/kernel/constraint.py b/pyomo/core/kernel/constraint.py index 120e3f3df02..35f92af6dfd 100644 --- a/pyomo/core/kernel/constraint.py +++ b/pyomo/core/kernel/constraint.py @@ -174,7 +174,7 @@ def to_bounded_expression(self, evaluate_bounds=False): return self.lower, self.body, self.upper -class _MutableBoundsConstraintMixin(object): +class _MutableBoundsConstraintMixin: """ Use as a base class for IConstraint implementations that allow adjusting the lb, ub, rhs, and equality diff --git a/pyomo/core/kernel/piecewise_library/transforms.py b/pyomo/core/kernel/piecewise_library/transforms.py index cbdbad33380..94aa4b7a34f 100644 --- a/pyomo/core/kernel/piecewise_library/transforms.py +++ b/pyomo/core/kernel/piecewise_library/transforms.py @@ -57,7 +57,7 @@ # wrapper that allows a list containing parameters to be # used with the bisect module -class _shadow_list(object): +class _shadow_list: __slots__ = ("_x",) def __init__(self, x): @@ -214,7 +214,7 @@ def piecewise( ) -class PiecewiseLinearFunction(object): +class PiecewiseLinearFunction: """A piecewise linear function Piecewise linear functions are defined by a list of diff --git a/pyomo/core/kernel/piecewise_library/transforms_nd.py b/pyomo/core/kernel/piecewise_library/transforms_nd.py index 12dd5005441..781cac3f7c0 100644 --- a/pyomo/core/kernel/piecewise_library/transforms_nd.py +++ b/pyomo/core/kernel/piecewise_library/transforms_nd.py @@ -101,7 +101,7 @@ def piecewise_nd(tri, values, input=None, output=None, bound='eq', repn='cc'): return transform(func, input=input, output=output, bound=bound) -class PiecewiseLinearFunctionND(object): +class PiecewiseLinearFunctionND: """A multi-variate piecewise linear function Multi-varite piecewise linear functions are defined by a diff --git a/pyomo/core/kernel/set_types.py b/pyomo/core/kernel/set_types.py index ee5ea677ee8..2a1a0de583e 100644 --- a/pyomo/core/kernel/set_types.py +++ b/pyomo/core/kernel/set_types.py @@ -20,7 +20,7 @@ # # Dummy types used by Kernel as domain flags # -class RealSet(object): +class RealSet: @staticmethod def get_interval(): return (None, None, 0) @@ -38,7 +38,7 @@ def is_binary(): return False -class IntegerSet(object): +class IntegerSet: @staticmethod def get_interval(): return (None, None, 1) @@ -56,7 +56,7 @@ def is_binary(): return False -class BinarySet(object): +class BinarySet: @staticmethod def get_interval(): return (0, 1, 1) diff --git a/pyomo/core/plugins/transform/lp_dual.py b/pyomo/core/plugins/transform/lp_dual.py index e2f0871dbb8..59b9949307e 100644 --- a/pyomo/core/plugins/transform/lp_dual.py +++ b/pyomo/core/plugins/transform/lp_dual.py @@ -47,7 +47,7 @@ def __init__(self): @TransformationFactory.register( 'core.lp_dual', 'Generate the linear programming dual of the given model' ) -class LinearProgrammingDual(object): +class LinearProgrammingDual: CONFIG = ConfigDict("core.lp_dual") CONFIG.declare( 'parameterize_wrt', diff --git a/pyomo/core/staleflag.py b/pyomo/core/staleflag.py index 86e68e0831e..6bf9972b7bb 100644 --- a/pyomo/core/staleflag.py +++ b/pyomo/core/staleflag.py @@ -10,7 +10,7 @@ # ___________________________________________________________________________ -class _StaleFlagManager(object): +class _StaleFlagManager: def __init__(self): self._current = 0 self.mark_all_as_stale() diff --git a/pyomo/core/tests/unit/kernel/test_block.py b/pyomo/core/tests/unit/kernel/test_block.py index 2949a018f5c..8d4daefb498 100644 --- a/pyomo/core/tests/unit/kernel/test_block.py +++ b/pyomo/core/tests/unit/kernel/test_block.py @@ -1341,7 +1341,7 @@ def test_ordering(self): objs.rotate(-1) -class _Test_block_base(object): +class _Test_block_base: _children = None _child_key = None _components_no_descend = None diff --git a/pyomo/core/tests/unit/kernel/test_conic.py b/pyomo/core/tests/unit/kernel/test_conic.py index a5e228bc9e7..c558bc82def 100644 --- a/pyomo/core/tests/unit/kernel/test_conic.py +++ b/pyomo/core/tests/unit/kernel/test_conic.py @@ -40,7 +40,7 @@ ) -class _conic_tester_base(object): +class _conic_tester_base: _object_factory = None def setUp(self): diff --git a/pyomo/core/tests/unit/kernel/test_dict_container.py b/pyomo/core/tests/unit/kernel/test_dict_container.py index 1cacc024099..d0154ffaf2b 100644 --- a/pyomo/core/tests/unit/kernel/test_dict_container.py +++ b/pyomo/core/tests/unit/kernel/test_dict_container.py @@ -36,11 +36,11 @@ _pickle_test_protocol = pickle.HIGHEST_PROTOCOL -class _bad_ctype(object): +class _bad_ctype: ctype = "_this_is_definitely_not_the_ctype_being_tested" -class _TestDictContainerBase(object): +class _TestDictContainerBase: # set by derived class _container_type = None _ctype_factory = None diff --git a/pyomo/core/tests/unit/kernel/test_expression.py b/pyomo/core/tests/unit/kernel/test_expression.py index 7ddbfea4f67..08d7c69e1e6 100644 --- a/pyomo/core/tests/unit/kernel/test_expression.py +++ b/pyomo/core/tests/unit/kernel/test_expression.py @@ -305,7 +305,7 @@ def test_to_string(self): del b.p -class _Test_expression_base(object): +class _Test_expression_base: _ctype_factory = None def test_pprint(self): diff --git a/pyomo/core/tests/unit/kernel/test_list_container.py b/pyomo/core/tests/unit/kernel/test_list_container.py index a4e8ae5054e..d947c96e4a8 100644 --- a/pyomo/core/tests/unit/kernel/test_list_container.py +++ b/pyomo/core/tests/unit/kernel/test_list_container.py @@ -35,11 +35,11 @@ _pickle_test_protocol = pickle.HIGHEST_PROTOCOL -class _bad_ctype(object): +class _bad_ctype: ctype = "_this_is_definitely_not_the_ctype_being_tested" -class _TestListContainerBase(object): +class _TestListContainerBase: # set by derived class _container_type = None _ctype_factory = None diff --git a/pyomo/core/tests/unit/kernel/test_tuple_container.py b/pyomo/core/tests/unit/kernel/test_tuple_container.py index 2190ff5d2f7..eb6f60e0751 100644 --- a/pyomo/core/tests/unit/kernel/test_tuple_container.py +++ b/pyomo/core/tests/unit/kernel/test_tuple_container.py @@ -33,11 +33,11 @@ _pickle_test_protocol = pickle.HIGHEST_PROTOCOL -class _bad_ctype(object): +class _bad_ctype: ctype = "_this_is_definitely_not_the_ctype_being_tested" -class _TestTupleContainerBase(object): +class _TestTupleContainerBase: # set by derived class _container_type = None _ctype_factory = None diff --git a/pyomo/core/tests/unit/test_block.py b/pyomo/core/tests/unit/test_block.py index 55fb5850635..e8e768cfa8c 100644 --- a/pyomo/core/tests/unit/test_block.py +++ b/pyomo/core/tests/unit/test_block.py @@ -474,7 +474,7 @@ def test_mixed_index_type(self): self.assertIs(a, b) -class HierarchicalModel(object): +class HierarchicalModel: def __init__(self): m = self.model = ConcreteModel() m.a1_IDX = Set(initialize=[5, 4], ordered=True) @@ -671,7 +671,7 @@ def a(b, i): ] -class MixedHierarchicalModel(object): +class MixedHierarchicalModel: def __init__(self): m = self.model = ConcreteModel() m.a = Block() @@ -2533,7 +2533,7 @@ def d(b, i): self.assertIs(m.d[i].parent_block(), m) def test_clone_unclonable_attribute(self): - class foo(object): + class foo: def __deepcopy__(bogus): pass diff --git a/pyomo/core/tests/unit/test_component.py b/pyomo/core/tests/unit/test_component.py index 1ac11e92fdf..4f2e4507808 100644 --- a/pyomo/core/tests/unit/test_component.py +++ b/pyomo/core/tests/unit/test_component.py @@ -105,7 +105,7 @@ def test_component_data_pprint(self): def test_is_reference(self): m = ConcreteModel() - class _NotSpecified(object): + class _NotSpecified: pass m.comp = Component(ctype=_NotSpecified) diff --git a/pyomo/core/tests/unit/test_dict_objects.py b/pyomo/core/tests/unit/test_dict_objects.py index 9f8849cc2b5..0c15c5faf86 100644 --- a/pyomo/core/tests/unit/test_dict_objects.py +++ b/pyomo/core/tests/unit/test_dict_objects.py @@ -23,7 +23,7 @@ from pyomo.core.base.expression import ExpressionData -class _TestComponentDictBase(object): +class _TestComponentDictBase: _ctype = None _cdatatype = None diff --git a/pyomo/core/tests/unit/test_disable_methods.py b/pyomo/core/tests/unit/test_disable_methods.py index 67dfed01cae..5be41914a92 100644 --- a/pyomo/core/tests/unit/test_disable_methods.py +++ b/pyomo/core/tests/unit/test_disable_methods.py @@ -17,7 +17,7 @@ from pyomo.common.modeling import NOTSET -class LocalClass(object): +class LocalClass: def __init__(self, name): self._name = name @@ -28,7 +28,7 @@ def __str__(self): local_instance = LocalClass('local') -class _simple(object): +class _simple: def __init__(self, name): self.name = name self._d = 'd' diff --git a/pyomo/core/tests/unit/test_initializer.py b/pyomo/core/tests/unit/test_initializer.py index 4a4f683b33a..041ba69e8a2 100644 --- a/pyomo/core/tests/unit/test_initializer.py +++ b/pyomo/core/tests/unit/test_initializer.py @@ -228,7 +228,7 @@ def bogus(m, i, j): self.assertEqual(next(c), 335) def test_method(self): - class Init(object): + class Init: def a_init(self, m): return 0 @@ -288,7 +288,7 @@ def y_init(self, m, i, j): self.assertEqual(next(c), 40) def test_classmethod(self): - class Init(object): + class Init: @classmethod def a_init(cls, m): return 0 @@ -350,7 +350,7 @@ def y_init(cls, m, i, j): self.assertEqual(next(c), 40) def test_staticmethod(self): - class Init(object): + class Init: @staticmethod def a_init(m): return 0 @@ -446,7 +446,7 @@ def y_init(m, i, j): self.assertEqual(list(a(None, (1, 4))), [4, 2]) def test_generator_method(self): - class Init(object): + class Init: def a_init(self, m): yield 0 yield 3 @@ -506,7 +506,7 @@ def x_init(): self.assertEqual(list(a(None, 1)), [0, 3]) def test_functor(self): - class InitScalar(object): + class InitScalar: def __init__(self, val): self.val = val @@ -519,7 +519,7 @@ def __call__(self, m): self.assertFalse(a.verified) self.assertEqual(a(None, None), 10) - class InitIndexed(object): + class InitIndexed: def __init__(self, val): self.val = val @@ -900,7 +900,7 @@ def a_init(m): self.assertIs(type(a), ParameterizedIndexedCallInitializer) self.assertEqual(a('m', 1, 5), ('m', 5, 1)) - class Functor(object): + class Functor: def __init__(self, i): self.i = i diff --git a/pyomo/core/tests/unit/test_list_objects.py b/pyomo/core/tests/unit/test_list_objects.py index 379808aeb61..ed1742beb9d 100644 --- a/pyomo/core/tests/unit/test_list_objects.py +++ b/pyomo/core/tests/unit/test_list_objects.py @@ -23,7 +23,7 @@ from pyomo.core.base.expression import ExpressionData -class _TestComponentListBase(object): +class _TestComponentListBase: _ctype = None _cdatatype = None diff --git a/pyomo/core/tests/unit/test_numeric_expr.py b/pyomo/core/tests/unit/test_numeric_expr.py index 5e35d4b6513..8a854141c68 100644 --- a/pyomo/core/tests/unit/test_numeric_expr.py +++ b/pyomo/core/tests/unit/test_numeric_expr.py @@ -118,7 +118,7 @@ from pyomo.core.expr.numvalue import NumericValue -class decompose_linear_term_wrapper(object): +class decompose_linear_term_wrapper: def __init__(self, pairs): self.pairs = pairs diff --git a/pyomo/core/tests/unit/test_numeric_expr_api.py b/pyomo/core/tests/unit/test_numeric_expr_api.py index 9c5775432e9..fc0a1e6f121 100644 --- a/pyomo/core/tests/unit/test_numeric_expr_api.py +++ b/pyomo/core/tests/unit/test_numeric_expr_api.py @@ -58,7 +58,7 @@ from pyomo.environ import ConcreteModel, Param, Var, ExternalFunction -class MockExternalFunction(object): +class MockExternalFunction: def evaluate(self, args): (x,) = args return (math.log(x) / math.log(2)) ** 2 diff --git a/pyomo/core/tests/unit/test_numeric_expr_dispatcher.py b/pyomo/core/tests/unit/test_numeric_expr_dispatcher.py index 48e70781022..16e9a48b269 100644 --- a/pyomo/core/tests/unit/test_numeric_expr_dispatcher.py +++ b/pyomo/core/tests/unit/test_numeric_expr_dispatcher.py @@ -59,7 +59,7 @@ logger = logging.getLogger(__name__) -class Base(object): +class Base: class SKIP: pass diff --git a/pyomo/core/tests/unit/test_numvalue.py b/pyomo/core/tests/unit/test_numvalue.py index 1466c7bcb49..bf007a9b844 100644 --- a/pyomo/core/tests/unit/test_numvalue.py +++ b/pyomo/core/tests/unit/test_numvalue.py @@ -44,7 +44,7 @@ from pyomo.common.numeric_types import _native_boolean_types -class MyBogusType(object): +class MyBogusType: def __init__(self, val=0): self.val = float(val) @@ -84,7 +84,7 @@ def test_NumericValue(self): self.assertEqual(is_numeric_data(NumericConstant(1.0)), True) def test_error(self): - class A(object): + class A: pass val = A() @@ -170,7 +170,7 @@ def test_var2(self): self.assertEqual(None, value(m.x, exception=False)) def test_error1(self): - class A(object): + class A: pass val = A() @@ -262,7 +262,7 @@ def test_var1(self): self.assertTrue(1, polynomial_degree(m.x)) def test_error1(self): - class A(object): + class A: pass val = A() @@ -311,7 +311,7 @@ def test_const2(self): self.assertTrue(is_constant(val)) def test_error(self): - class A(object): + class A: pass val = A() @@ -354,7 +354,7 @@ def test_const1(self): self.assertTrue(is_fixed(val)) def test_error(self): - class A(object): + class A: pass val = A() @@ -397,7 +397,7 @@ def test_const1(self): self.assertFalse(is_variable_type(val)) def test_error(self): - class A(object): + class A: pass val = A() @@ -433,7 +433,7 @@ def test_const1(self): self.assertFalse(is_potentially_variable(val)) def test_error(self): - class A(object): + class A: pass val = A() @@ -499,7 +499,7 @@ def test_const1(self): self.assertEqual(1.0, as_numeric(val)) def test_error1(self): - class A(object): + class A: pass val = A() diff --git a/pyomo/core/tests/unit/test_param.py b/pyomo/core/tests/unit/test_param.py index 66fbb742b70..3903a09fef0 100644 --- a/pyomo/core/tests/unit/test_param.py +++ b/pyomo/core/tests/unit/test_param.py @@ -74,7 +74,7 @@ NoValue = Param.NoValue -class ParamTester(object): +class ParamTester: def setUp(self, **kwds): # # Sparse single-index Param, no default diff --git a/pyomo/core/tests/unit/test_range.py b/pyomo/core/tests/unit/test_range.py index cb4399beb22..cb4ed26cbcf 100644 --- a/pyomo/core/tests/unit/test_range.py +++ b/pyomo/core/tests/unit/test_range.py @@ -235,7 +235,7 @@ def test_contains(self): self.assertNotIn({0: -1}, NR(0, None, 0)) self.assertNotIn({1: 1}, NR(0, None, 0)) - class _Unrelated(object): + class _Unrelated: pass self.assertNotIn(_Unrelated(), NR(0, None, 0)) @@ -270,7 +270,7 @@ def __ne__(self, other): self.assertNotIn(_NotCastable(1), NR(0, None, 0)) self.assertNotIn(_NotCastable, NR._types_comparable_to_int) - class _Custom(object): + class _Custom: def __init__(self, val): self.val = val diff --git a/pyomo/core/tests/unit/test_reference.py b/pyomo/core/tests/unit/test_reference.py index adeb0a52caa..50d04b02adb 100644 --- a/pyomo/core/tests/unit/test_reference.py +++ b/pyomo/core/tests/unit/test_reference.py @@ -652,7 +652,7 @@ def test_constructor_error(self): m = ConcreteModel() m.x = Var([1, 2]) - class Foo(object): + class Foo: pass self.assertRaisesRegex( diff --git a/pyomo/core/tests/unit/test_set.py b/pyomo/core/tests/unit/test_set.py index ea4931f9767..f9e01b217fa 100644 --- a/pyomo/core/tests/unit/test_set.py +++ b/pyomo/core/tests/unit/test_set.py @@ -955,7 +955,7 @@ def test_constructor(self): ) self.assertEqual(RangeSet(0, 5, 1), m.I) - class _AlmostNumeric(object): + class _AlmostNumeric: def __init__(self, val): self.val = val @@ -1228,7 +1228,7 @@ def test_equality(self): # It can even work for non-iterable objects (that can't be cast # to set()) - class _NonIterable(object): + class _NonIterable: def __init__(self): self.data = set({1, 3, 5}) @@ -1410,7 +1410,7 @@ def test_isdisjoint(self): # It can even work for non-iterable objects (that can't be cast # to set()) - class _NonIterable(object): + class _NonIterable: def __init__(self): self.data = set({1, 3, 5}) @@ -1453,7 +1453,7 @@ def test_issubset(self): # It can even work for non-iterable objects (that can't be cast # to set()) - class _NonIterable(object): + class _NonIterable: def __init__(self): self.data = set({1, 3, 5}) @@ -1496,7 +1496,7 @@ def test_issuperset(self): # But NOT non-iterable objects: we assume that everything that # does not implement isfinite() is a discrete set. - class _NonIterable(object): + class _NonIterable: def __init__(self): self.data = set({1, 3, 5}) diff --git a/pyomo/core/tests/unit/test_smap.py b/pyomo/core/tests/unit/test_smap.py index 0394f986602..8b1041930fe 100644 --- a/pyomo/core/tests/unit/test_smap.py +++ b/pyomo/core/tests/unit/test_smap.py @@ -154,7 +154,7 @@ def test_error1(self): labeler = TextLabeler() self.assertEqual('x', smap.getSymbol(self.instance.x, labeler)) - class FOO(object): + class FOO: def __call__(self, *args): return 'x' diff --git a/pyomo/core/tests/unit/test_sos_v2.py b/pyomo/core/tests/unit/test_sos_v2.py index 32e10933fb4..49d95d26784 100644 --- a/pyomo/core/tests/unit/test_sos_v2.py +++ b/pyomo/core/tests/unit/test_sos_v2.py @@ -28,7 +28,7 @@ @unittest.skipIf(not solver_available, "The solver is not available.") -class SOSProblem_nonindexed(object): +class SOSProblem_nonindexed: "Test non-indexed SOS using a single pyomo Var component." def verify( @@ -505,7 +505,7 @@ def test(self): @unittest.skipIf(not solver_available, "The solver is not available.") -class SOSProblem_nonindexed_multivar(object): +class SOSProblem_nonindexed_multivar: "Test non-indexed SOS made up of different Var components." def verify(self, model, sos, exp_res, abs_tol, show_output: bool = False): @@ -599,7 +599,7 @@ def test(self): @unittest.skipIf(not solver_available, "The solver is not available.") -class SOSProblem_indexed(object): +class SOSProblem_indexed: "Test indexed SOS using a single pyomo Var component." def verify( @@ -970,7 +970,7 @@ def test(self): @unittest.skipIf(not solver_available, "The solver is not available.") -class SOSProblem_indexedmultivar(object): +class SOSProblem_indexedmultivar: "Test indexed SOS made up of different Var components." def verify(self, model, sos, exp_res, abs_tol, show_output: bool = False): diff --git a/pyomo/core/tests/unit/test_symbolic.py b/pyomo/core/tests/unit/test_symbolic.py index 30bd9120882..862aab080b0 100644 --- a/pyomo/core/tests/unit/test_symbolic.py +++ b/pyomo/core/tests/unit/test_symbolic.py @@ -395,7 +395,7 @@ def test_errors(self): obj_map = PyomoSympyBimap() - class bogus(object): + class bogus: def __init__(self): self.args = (obj_map.getSympySymbol(m.x),) self.func = type(self) diff --git a/pyomo/core/tests/unit/test_units.py b/pyomo/core/tests/unit/test_units.py index 88d40ff81b7..4d5296585db 100644 --- a/pyomo/core/tests/unit/test_units.py +++ b/pyomo/core/tests/unit/test_units.py @@ -1146,7 +1146,7 @@ def test_as_quantity_scalar(self): self.assertIs(q.__class__, bool) self.assertEqual(q, True) - class UnknownPyomoType(object): + class UnknownPyomoType: def is_expression_type(self, expression_system=None): return False diff --git a/pyomo/core/tests/unit/test_visitor.py b/pyomo/core/tests/unit/test_visitor.py index 07c5fb5c03b..49f59f616e0 100644 --- a/pyomo/core/tests/unit/test_visitor.py +++ b/pyomo/core/tests/unit/test_visitor.py @@ -1070,7 +1070,7 @@ def test_npv_abs(self): assertExpressionsEqual(self, e3, abs(m.x)) -class BaseStreamBasedVisitorTests(object): +class BaseStreamBasedVisitorTests: def setUp(self): self.m = m = ConcreteModel() m.x = Var() diff --git a/pyomo/dae/flatten.py b/pyomo/dae/flatten.py index 587013002ae..6c6905cbfbf 100644 --- a/pyomo/dae/flatten.py +++ b/pyomo/dae/flatten.py @@ -43,7 +43,7 @@ def get_slice_for_set(s): return None -class _NotAnIndex(object): +class _NotAnIndex: """ `None` is a valid index, so we use a dummy class to denote a slot that needs to get filled with indices diff --git a/pyomo/dae/tests/test_flatten.py b/pyomo/dae/tests/test_flatten.py index 3825416c341..eaae74962ef 100644 --- a/pyomo/dae/tests/test_flatten.py +++ b/pyomo/dae/tests/test_flatten.py @@ -29,7 +29,7 @@ ) -class _TestFlattenBase(object): +class _TestFlattenBase: """A base class to hold the common _hashRef utility method. We don't just derive from Test... classes directly as this causes tests to run twice. diff --git a/pyomo/dataportal/DataPortal.py b/pyomo/dataportal/DataPortal.py index 5da1ab77835..0d7720c146a 100644 --- a/pyomo/dataportal/DataPortal.py +++ b/pyomo/dataportal/DataPortal.py @@ -16,7 +16,7 @@ logger = logging.getLogger('pyomo.core') -class DataPortal(object): +class DataPortal: """ An object that manages loading and storing data from external data sources. This object interfaces to plugins that manipulate diff --git a/pyomo/dataportal/TableData.py b/pyomo/dataportal/TableData.py index b72bdb9f2ac..75b79c9f5d4 100644 --- a/pyomo/dataportal/TableData.py +++ b/pyomo/dataportal/TableData.py @@ -13,7 +13,7 @@ from pyomo.dataportal.process_data import _process_data -class TableData(object): +class TableData: """ A class used to read/write data from/to a table in an external data source. diff --git a/pyomo/dataportal/factory.py b/pyomo/dataportal/factory.py index 2b8bb1d0d8d..94e4f1b5270 100644 --- a/pyomo/dataportal/factory.py +++ b/pyomo/dataportal/factory.py @@ -16,7 +16,7 @@ logger = logging.getLogger('pyomo.core') -class UnknownDataManager(object): +class UnknownDataManager: def __init__(self, *args, **kwds): # # The 'type' is the class type of the solver instance diff --git a/pyomo/dataportal/plugins/datacommands.py b/pyomo/dataportal/plugins/datacommands.py index b2c020a89a4..79e9b9003bf 100644 --- a/pyomo/dataportal/plugins/datacommands.py +++ b/pyomo/dataportal/plugins/datacommands.py @@ -17,7 +17,7 @@ @DataManagerFactory.register("dat", "Pyomo data command file interface") -class PyomoDataCommands(object): +class PyomoDataCommands: def __init__(self): self._info = [] self.options = Bunch() diff --git a/pyomo/dataportal/plugins/json_dict.py b/pyomo/dataportal/plugins/json_dict.py index 844a2d7017a..d0141e46f07 100644 --- a/pyomo/dataportal/plugins/json_dict.py +++ b/pyomo/dataportal/plugins/json_dict.py @@ -90,7 +90,7 @@ def tuplize(d): @DataManagerFactory.register("json", "JSON file interface") -class JSONDictionary(object): +class JSONDictionary: def __init__(self): self._info = {} self.options = Bunch() @@ -179,7 +179,7 @@ def clear(self): @DataManagerFactory.register("yaml", "YAML file interface") -class YamlDictionary(object): +class YamlDictionary: def __init__(self): self._info = {} self.options = Bunch() diff --git a/pyomo/dataportal/tests/test_dataportal.py b/pyomo/dataportal/tests/test_dataportal.py index f2f1dcff460..3c682c23502 100644 --- a/pyomo/dataportal/tests/test_dataportal.py +++ b/pyomo/dataportal/tests/test_dataportal.py @@ -1561,7 +1561,7 @@ def create_options(self, name): } -class LoadTests(object): +class LoadTests: skiplist = [] # diff --git a/pyomo/duality/tests/test_linear_dual.py b/pyomo/duality/tests/test_linear_dual.py index 7a0d616ee21..40467ab7e92 100644 --- a/pyomo/duality/tests/test_linear_dual.py +++ b/pyomo/duality/tests/test_linear_dual.py @@ -29,7 +29,7 @@ solver = None -class CommonTests(object): +class CommonTests: solve = True def run_bilevel(self, *_args, **kwds): diff --git a/pyomo/environ/tests/test_environ.py b/pyomo/environ/tests/test_environ.py index 49ff6da23fb..de40c979e5f 100644 --- a/pyomo/environ/tests/test_environ.py +++ b/pyomo/environ/tests/test_environ.py @@ -19,7 +19,7 @@ import pyomo.common.unittest as unittest -class ImportData(object): +class ImportData: def __init__(self): self.tpl = {} self.pyomo = {} diff --git a/pyomo/gdp/disjunct.py b/pyomo/gdp/disjunct.py index 311edc77388..fd2f0c5afd6 100644 --- a/pyomo/gdp/disjunct.py +++ b/pyomo/gdp/disjunct.py @@ -384,7 +384,7 @@ def setub(self, arg): # The following should eventually be promoted so that all # IndexedComponents can use it -class _Initializer(object): +class _Initializer: """A simple function to process an argument to a Component constructor. This checks the incoming initializer type and maps it to a static diff --git a/pyomo/gdp/plugins/bigm_mixin.py b/pyomo/gdp/plugins/bigm_mixin.py index 4899551f918..df0ff2f6eeb 100644 --- a/pyomo/gdp/plugins/bigm_mixin.py +++ b/pyomo/gdp/plugins/bigm_mixin.py @@ -90,7 +90,7 @@ def _warn_for_unused_bigM_args(bigM, used_args, logger): logger.warning(warning_msg) -class _BigM_MixIn(object): +class _BigM_MixIn: def _get_bigM_arg_list(self, bigm_args, block): # Gather what we know about blocks from args exactly once. We'll still # check for constraints in the moment, but if that fails, we've diff --git a/pyomo/gdp/util.py b/pyomo/gdp/util.py index 3bfc0833a73..d1fda20a316 100644 --- a/pyomo/gdp/util.py +++ b/pyomo/gdp/util.py @@ -43,15 +43,15 @@ ) -class NORMAL(object): +class NORMAL: pass -class INFEASIBLE(object): +class INFEASIBLE: pass -class NONOPTIMAL(object): +class NONOPTIMAL: pass diff --git a/pyomo/mpec/tests/test_complementarity.py b/pyomo/mpec/tests/test_complementarity.py index 7beb5780bbc..641c071e075 100644 --- a/pyomo/mpec/tests/test_complementarity.py +++ b/pyomo/mpec/tests/test_complementarity.py @@ -42,7 +42,7 @@ currdir = this_file_dir() -class CCTests(object): +class CCTests: @classmethod def setUpClass(cls): import pyomo.environ diff --git a/pyomo/neos/kestrel.py b/pyomo/neos/kestrel.py index 9c1695c1e15..db7aaba61b6 100644 --- a/pyomo/neos/kestrel.py +++ b/pyomo/neos/kestrel.py @@ -35,7 +35,7 @@ _email_re = re.compile(r'([^@]+@[^@]+\.[a-zA-Z0-9]+)$') -class NEOS(object): +class NEOS: # NEOS currently only supports HTTPS access scheme = 'https' host = 'neos-server.org' @@ -79,7 +79,7 @@ def make_connection(self, host): return ProxiedTransport_PY3() -class kestrelAMPL(object): +class kestrelAMPL: def __init__(self): self.setup_connection() diff --git a/pyomo/neos/tests/test_neos.py b/pyomo/neos/tests/test_neos.py index 3ebc6ebb8f3..2a97fd67366 100644 --- a/pyomo/neos/tests/test_neos.py +++ b/pyomo/neos/tests/test_neos.py @@ -107,7 +107,7 @@ def test_check_all_ampl_solvers(self): self.fail(f"RunAllNEOSSolvers missing test for '{solver}'") -class RunAllNEOSSolvers(object): +class RunAllNEOSSolvers: def test_baron(self): self._run('baron') @@ -192,7 +192,7 @@ def test_lgo(self): self._run('lgo') -class DirectDriver(object): +class DirectDriver: def _run(self, opt, constrained=True): m = _model(self.sense) with pyo.SolverManagerFactory('neos') as solver_manager: @@ -213,7 +213,7 @@ def _run(self, opt, constrained=True): self.assertAlmostEqual(pyo.value(m.y), expected_y, delta=1e-5) -class PyomoCommandDriver(object): +class PyomoCommandDriver: def _run(self, opt, constrained=True): expected_y = { (pyo.minimize, True): -1, diff --git a/pyomo/network/foqus_graph.py b/pyomo/network/foqus_graph.py index 6fc9f75d07b..fedf6889c74 100644 --- a/pyomo/network/foqus_graph.py +++ b/pyomo/network/foqus_graph.py @@ -81,7 +81,7 @@ logger = logging.getLogger('pyomo.network') -class FOQUSGraph(object): +class FOQUSGraph: def solve_tear_direct( self, G, order, function, tears, outEdges, iterLim, tol, tol_type, report_diffs ): diff --git a/pyomo/opt/base/problem.py b/pyomo/opt/base/problem.py index 7b1b9e8f9f6..3415e2f9bce 100644 --- a/pyomo/opt/base/problem.py +++ b/pyomo/opt/base/problem.py @@ -15,7 +15,7 @@ WriterFactory = Factory('problem writer') -class AbstractProblemWriter(object): +class AbstractProblemWriter: """Base class that can write optimization problems.""" def __init__(self, problem_format): # pragma:nocover @@ -36,7 +36,7 @@ def __exit__(self, t, v, traceback): pass -class BranchDirection(object): +class BranchDirection: """Allowed values for MIP variable branching directions in the `direction` Suffix of a model.""" default = 0 diff --git a/pyomo/opt/base/results.py b/pyomo/opt/base/results.py index 8e11d205032..9fe4749b413 100644 --- a/pyomo/opt/base/results.py +++ b/pyomo/opt/base/results.py @@ -15,7 +15,7 @@ ReaderFactory = Factory('problem reader') -class AbstractResultsReader(object): +class AbstractResultsReader: """Base class that can read optimization results.""" def __init__(self, results_format): diff --git a/pyomo/opt/base/solvers.py b/pyomo/opt/base/solvers.py index 767f62d07c2..004359c2ba0 100644 --- a/pyomo/opt/base/solvers.py +++ b/pyomo/opt/base/solvers.py @@ -54,7 +54,7 @@ def _extract_version(x, length=4): return None # (0,0,0,0)[:length] -class UnknownSolver(object): +class UnknownSolver: def __init__(self, *args, **kwds): # super(UnknownSolver,self).__init__(**kwds) @@ -236,7 +236,7 @@ def _raise_ephemeral_error(name, keyword=""): ) -class OptSolver(object): +class OptSolver: """A generic optimization solver""" # diff --git a/pyomo/opt/parallel/manager.py b/pyomo/opt/parallel/manager.py index add77029e4a..a38f1f02144 100644 --- a/pyomo/opt/parallel/manager.py +++ b/pyomo/opt/parallel/manager.py @@ -44,7 +44,7 @@ def __init__(self, *args, **kargs): Exception.__init__(self, *args, **kargs) # pragma:nocover -class ActionHandle(object): +class ActionHandle: id_counter = 0 def __init__(self, error=False, explanation=""): @@ -85,7 +85,7 @@ def __str__(self): FailedActionHandle = ActionHandle(error=True) -class AsynchronousActionManager(object): +class AsynchronousActionManager: @staticmethod def _flatten(*args): ahs = set() diff --git a/pyomo/opt/problem/ampl.py b/pyomo/opt/problem/ampl.py index a7bfcade2d3..1c42eb9cb54 100644 --- a/pyomo/opt/problem/ampl.py +++ b/pyomo/opt/problem/ampl.py @@ -19,7 +19,7 @@ from pyomo.opt.base import ProblemFormat, convert_problem, guess_format -class AmplModel(object): +class AmplModel: """ A class that provides a wrapper for AMPL models. """ diff --git a/pyomo/opt/results/container.py b/pyomo/opt/results/container.py index 57cbf8a594e..4df454ea507 100644 --- a/pyomo/opt/results/container.py +++ b/pyomo/opt/results/container.py @@ -37,7 +37,7 @@ def __str__(self): strict = False -class UndefinedData(object): +class UndefinedData: singleton = {} def __new__(cls, name='undefined'): @@ -61,7 +61,7 @@ def __str__(self): ignore = UndefinedData('ignore') -class ScalarData(object): +class ScalarData: def __init__( self, value=undefined, @@ -175,7 +175,7 @@ def load(self, repn): # # This class manages a list of MapContainer objects. # -class ListContainer(object): +class ListContainer: def __init__(self, cls): self._cls = cls self._list = [] diff --git a/pyomo/opt/tests/base/test_convert.py b/pyomo/opt/tests/base/test_convert.py index fd23ac3719e..8c2b13181e4 100644 --- a/pyomo/opt/tests/base/test_convert.py +++ b/pyomo/opt/tests/base/test_convert.py @@ -28,7 +28,7 @@ old_tempdir = TempfileManager.tempdir -class MockArg(object): +class MockArg: def __init__(self): pass diff --git a/pyomo/repn/ampl.py b/pyomo/repn/ampl.py index 26bc932fa82..84c0a7e6601 100644 --- a/pyomo/repn/ampl.py +++ b/pyomo/repn/ampl.py @@ -75,7 +75,7 @@ def _create_strict_inequality_map(vars_): } -class TextNLDebugTemplate(object): +class TextNLDebugTemplate: unary = { 'log': 'o43\t#log\n', 'log10': 'o42\t#log10\n', @@ -181,7 +181,7 @@ class TextNLTemplate(TextNLDebugTemplate): _create_strict_inequality_map(vars()) -class NLFragment(object): +class NLFragment: """This is a mock "component" for the nl portion of a named Expression. It is used internally in the writer when requesting symbolic solver @@ -201,7 +201,7 @@ def name(self): return 'nl(' + self._node.name + ')' -class AMPLRepn(object): +class AMPLRepn: """The "compiled" representation of an expression in AMPL NL format. This stores a compiled form of an expression in the AMPL "NL" diff --git a/pyomo/repn/linear.py b/pyomo/repn/linear.py index 6d88cf3e082..17d6ef86881 100644 --- a/pyomo/repn/linear.py +++ b/pyomo/repn/linear.py @@ -85,7 +85,7 @@ def _merge_dict(dest_dict, mult, src_dict): dest_dict[vid] = mult * coef -class LinearRepn(object): +class LinearRepn: __slots__ = ("multiplier", "constant", "linear", "nonlinear") def __init__(self): diff --git a/pyomo/repn/plugins/ampl/ampl_.py b/pyomo/repn/plugins/ampl/ampl_.py index adb9294b2a7..73418e1a512 100644 --- a/pyomo/repn/plugins/ampl/ampl_.py +++ b/pyomo/repn/plugins/ampl/ampl_.py @@ -201,7 +201,7 @@ def _get_bound(exp): raise ValueError("non-fixed bound or weight: " + str(exp)) -class StopWatch(object): +class StopWatch: def __init__(self): self.start = time.time() @@ -212,7 +212,7 @@ def reset(self): self.start = time.time() -class _Counter(object): +class _Counter: def __init__(self, start): self._id = start @@ -222,8 +222,8 @@ def __call__(self, obj): return tmp -class ModelSOS(object): - class AmplSuffix(object): +class ModelSOS: + class AmplSuffix: def __init__(self, name): self.name = name self.ids = [] @@ -310,7 +310,7 @@ def count_constraint(self, soscondata): self.ref.add(ID, weight) -class RepnWrapper(object): +class RepnWrapper: __slots__ = ('repn', 'linear_vars', 'nonlinear_vars') def __init__(self, repn, linear, nonlinear): diff --git a/pyomo/repn/plugins/gams_writer.py b/pyomo/repn/plugins/gams_writer.py index 3da385fb7aa..5d76b63e2af 100644 --- a/pyomo/repn/plugins/gams_writer.py +++ b/pyomo/repn/plugins/gams_writer.py @@ -205,7 +205,7 @@ def expression_to_string(expr, treechecker, smap=None, output_fixed_variables=Fa return expr_str, visitor.is_discontinuous -class Categorizer(object): +class Categorizer: """Class for representing categorized variables. Given a list of variable names and a symbol map, categorizes the variable @@ -252,7 +252,7 @@ def __iter__(self): yield category, var_name -class StorageTreeChecker(object): +class StorageTreeChecker: def __init__(self, model): # blocks are hashable so we can use a normal set self.tree = {model} diff --git a/pyomo/repn/plugins/lp_writer.py b/pyomo/repn/plugins/lp_writer.py index 1bfbbd6a2be..5e6360f0289 100644 --- a/pyomo/repn/plugins/lp_writer.py +++ b/pyomo/repn/plugins/lp_writer.py @@ -61,7 +61,7 @@ # TODO: make a proper base class -class LPWriterInfo(object): +class LPWriterInfo: """Return type for LPWriter.write() Attributes @@ -81,7 +81,7 @@ def __init__(self, symbol_map): 'cpxlp_v2', 'Generate the corresponding CPLEX LP file (version 2).' ) @WriterFactory.register('lp_v2', 'Generate the corresponding LP file (version 2).') -class LPWriter(object): +class LPWriter: CONFIG = ConfigBlock('lpwriter') CONFIG.declare( 'show_section_timing', @@ -242,7 +242,7 @@ def write(self, model, ostream, **options): return _LPWriter_impl(ostream, config).write(model) -class _LPWriter_impl(object): +class _LPWriter_impl: def __init__(self, ostream, config): self.ostream = ostream self.config = config diff --git a/pyomo/repn/plugins/nl_writer.py b/pyomo/repn/plugins/nl_writer.py index f009f76c3d0..a96f29e0f18 100644 --- a/pyomo/repn/plugins/nl_writer.py +++ b/pyomo/repn/plugins/nl_writer.py @@ -86,7 +86,7 @@ # TODO: make a proper base class -class NLWriterInfo(object): +class NLWriterInfo: """Return type for NLWriter.write() Attributes @@ -163,7 +163,7 @@ def __init__( @WriterFactory.register('nl_v2', 'Generate the corresponding AMPL NL file (version 2).') -class NLWriter(object): +class NLWriter: CONFIG = ConfigDict('nlwriter') CONFIG.declare( 'show_section_timing', @@ -389,7 +389,7 @@ def _generate_symbol_map(self, info): return symbol_map -class _SuffixData(object): +class _SuffixData: def __init__(self, name): self.name = name self.obj = {} @@ -492,14 +492,14 @@ def __call__(self, obj): return ans -class _NoScalingFactor(object): +class _NoScalingFactor: scale = False def __call__(self, obj): return 1 -class _NLWriter_impl(object): +class _NLWriter_impl: def __init__(self, ostream, rowstream, colstream, config): self.ostream = ostream self.rowstream = rowstream diff --git a/pyomo/repn/plugins/parameterized_standard_form.py b/pyomo/repn/plugins/parameterized_standard_form.py index 94474172b16..31b41e1b73c 100644 --- a/pyomo/repn/plugins/parameterized_standard_form.py +++ b/pyomo/repn/plugins/parameterized_standard_form.py @@ -95,7 +95,7 @@ def write(self, model, ostream=None, **options): return _ParameterizedLinearStandardFormCompiler_impl(config).write(model) -class _SparseMatrixBase(object): +class _SparseMatrixBase: def __init__(self, matrix_data, shape): (data, indices, indptr) = matrix_data (nrows, ncols) = shape diff --git a/pyomo/repn/plugins/standard_form.py b/pyomo/repn/plugins/standard_form.py index 89fac2d2006..32e1c8a4410 100644 --- a/pyomo/repn/plugins/standard_form.py +++ b/pyomo/repn/plugins/standard_form.py @@ -60,7 +60,7 @@ # TODO: make a proper base class -class LinearStandardFormInfo(object): +class LinearStandardFormInfo: """Return type for LinearStandardFormCompiler.write() Attributes @@ -138,7 +138,7 @@ def b(self): 'compile_standard_form', r'Compile an LP to standard form (:math:`\min c^Tx s.t. Ax \le b)`', ) -class LinearStandardFormCompiler(object): +class LinearStandardFormCompiler: r"""Compiler to convert an LP to the matrix representation of the standard form: @@ -268,7 +268,7 @@ def write(self, model, ostream=None, **options): return _LinearStandardFormCompiler_impl(config).write(model) -class _LinearStandardFormCompiler_impl(object): +class _LinearStandardFormCompiler_impl: # Making these methods class attributes so that others can change the hooks _get_visitor = LinearRepnVisitor _to_vector = None diff --git a/pyomo/repn/quadratic.py b/pyomo/repn/quadratic.py index e9a9269066f..05904db1328 100644 --- a/pyomo/repn/quadratic.py +++ b/pyomo/repn/quadratic.py @@ -39,7 +39,7 @@ _QUADRATIC = linear.ExprType.QUADRATIC -class QuadraticRepn(object): +class QuadraticRepn: __slots__ = ("multiplier", "constant", "linear", "quadratic", "nonlinear") def __init__(self): diff --git a/pyomo/repn/standard_repn.py b/pyomo/repn/standard_repn.py index 3f7abfde8e8..3d541c5eb33 100644 --- a/pyomo/repn/standard_repn.py +++ b/pyomo/repn/standard_repn.py @@ -51,7 +51,7 @@ def isclose_const(a, b, rel_tol=1e-9, abs_tol=0.0): return abs(a - b) <= max(rel_tol * max(abs(a), abs(b)), abs_tol) -class StandardRepn(object): +class StandardRepn: """ This class defines a standard/common representation for Pyomo expressions that provides an efficient interface for writing all models. @@ -421,7 +421,7 @@ def generate_standard_repn( ##----------------------------------------------------------------------- -class ResultsWithQuadratics(object): +class ResultsWithQuadratics: __slot__ = ('const', 'nonl', 'linear', 'quadratic') def __init__(self, constant=0, nonl=0, linear=None, quadratic=None): @@ -447,7 +447,7 @@ def __str__(self): # pragma: nocover ) -class ResultsWithoutQuadratics(object): +class ResultsWithoutQuadratics: __slot__ = ('const', 'nonl', 'linear') def __init__(self, constant=0, nonl=0, linear=None): diff --git a/pyomo/repn/tests/ampl/test_ampl_nl.py b/pyomo/repn/tests/ampl/test_ampl_nl.py index 4c680cd6c15..0f396e96d40 100644 --- a/pyomo/repn/tests/ampl/test_ampl_nl.py +++ b/pyomo/repn/tests/ampl/test_ampl_nl.py @@ -37,7 +37,7 @@ thisdir = this_file_dir() -class _NLWriter_suite(object): +class _NLWriter_suite: @classmethod def setUpClass(cls): cls.context = TempfileManager.new_context() diff --git a/pyomo/repn/tests/ampl/test_nlv2.py b/pyomo/repn/tests/ampl/test_nlv2.py index 932615be119..3624cc45a55 100644 --- a/pyomo/repn/tests/ampl/test_nlv2.py +++ b/pyomo/repn/tests/ampl/test_nlv2.py @@ -51,7 +51,7 @@ nan = float('nan') -class INFO(object): +class INFO: def __init__(self, symbolic=False): self.subexpression_cache = {} self.external_functions = {} diff --git a/pyomo/repn/tests/ampl/test_suffixes.py b/pyomo/repn/tests/ampl/test_suffixes.py index 9e6d395ebfb..8822c55b0da 100644 --- a/pyomo/repn/tests/ampl/test_suffixes.py +++ b/pyomo/repn/tests/ampl/test_suffixes.py @@ -34,7 +34,7 @@ currdir = this_file_dir() -class SuffixTester(object): +class SuffixTester: @classmethod def setUpClass(cls): cls.context = TempfileManager.new_context() diff --git a/pyomo/repn/tests/baron/test_baron.py b/pyomo/repn/tests/baron/test_baron.py index a11c0c528a1..309f09a5a37 100644 --- a/pyomo/repn/tests/baron/test_baron.py +++ b/pyomo/repn/tests/baron/test_baron.py @@ -275,7 +275,7 @@ def test_issue_2819(self): # class TestBaron_writer(unittest.TestCase): -class XTestBaron_writer(object): +class XTestBaron_writer: """These tests verified that the BARON writer complained loudly for variables that were not on the model, not on an active block, or not on a Block ctype. As we are relaxing that requirement throughout diff --git a/pyomo/repn/tests/cpxlp/test_cpxlp.py b/pyomo/repn/tests/cpxlp/test_cpxlp.py index 0d66e750823..a2340bfc124 100644 --- a/pyomo/repn/tests/cpxlp/test_cpxlp.py +++ b/pyomo/repn/tests/cpxlp/test_cpxlp.py @@ -27,7 +27,7 @@ thisdir = this_file_dir() -class _CPXLPOrdering_Suite(object): +class _CPXLPOrdering_Suite: @classmethod def setUpClass(cls): cls.context = TempfileManager.new_context() diff --git a/pyomo/repn/tests/test_plugins.py b/pyomo/repn/tests/test_plugins.py index 76805630f5c..8b2a2ca743a 100644 --- a/pyomo/repn/tests/test_plugins.py +++ b/pyomo/repn/tests/test_plugins.py @@ -26,7 +26,7 @@ def test_active(self): WriterFactory.get_class('lp'), WriterFactory.get_class(f'lp_v{ver}') ) - class TMP(object): + class TMP: pass WriterFactory.register('test_writer')(TMP) diff --git a/pyomo/repn/tests/test_standard.py b/pyomo/repn/tests/test_standard.py index c1912b463e1..21f77caa087 100644 --- a/pyomo/repn/tests/test_standard.py +++ b/pyomo/repn/tests/test_standard.py @@ -4418,7 +4418,7 @@ class Etype(pyomo.kernel.expression): self.assertEqual(str(rep.to_expression()), "(1 + )*") def test_error1(self): - class Foo(object): + class Foo: pass e = Foo() diff --git a/pyomo/repn/tests/test_util.py b/pyomo/repn/tests/test_util.py index 724e52e2899..6554089294c 100644 --- a/pyomo/repn/tests/test_util.py +++ b/pyomo/repn/tests/test_util.py @@ -254,7 +254,7 @@ def test_apply_operation(self): pyomo.repn.util.HALT_ON_EVALUATION_ERROR = _halt def test_complex_number_error(self): - class Visitor(object): + class Visitor: pass visitor = Visitor() @@ -392,7 +392,7 @@ def test_FileDeterminism_to_SortComponents(self): ) def test_initialize_var_map_from_column_order(self): - class MockConfig(object): + class MockConfig: column_order = None file_determinism = FileDeterminism(0) @@ -520,7 +520,7 @@ class MockConfig(object): self.assertEqual(MockConfig.column_order, ref) def test_ordered_active_constraints(self): - class MockConfig(object): + class MockConfig: row_order = None file_determinism = FileDeterminism(0) @@ -737,7 +737,7 @@ def _before_var(visitor, child): def _before_named_expression(visitor, child): return child - class VisitorTester(object): + class VisitorTester: def check_constant(self, value, node): return value diff --git a/pyomo/repn/util.py b/pyomo/repn/util.py index 4a51f87fc78..cf5e5aaeb0d 100644 --- a/pyomo/repn/util.py +++ b/pyomo/repn/util.py @@ -758,7 +758,7 @@ def ordered_active_constraints(model, config): return sorted(constraints, key=lambda x: _row_getter(id(x), _n)) -class VarRecorder(object): +class VarRecorder: def __init__(self, var_map, sorter): self.var_map = var_map self.sorter = sorter @@ -781,7 +781,7 @@ def add(self, var): vm[id(v)] = v -class OrderedVarRecorder(object): +class OrderedVarRecorder: def __init__(self, var_map, var_order, sorter): self.var_map = var_map self.var_order = var_order @@ -808,7 +808,7 @@ def add(self, var): vm[vid] = v -class TemplateVarRecorder(object): +class TemplateVarRecorder: def __init__(self, var_map, var_order, sorter): self.var_map = var_map self._var_order = var_order diff --git a/pyomo/scripting/plugins/build_ext.py b/pyomo/scripting/plugins/build_ext.py index cdf70a3254b..028531ed9ad 100644 --- a/pyomo/scripting/plugins/build_ext.py +++ b/pyomo/scripting/plugins/build_ext.py @@ -16,7 +16,7 @@ from pyomo.scripting.pyomo_parser import add_subparser -class ExtensionBuilder(object): +class ExtensionBuilder: def create_parser(self, parser): return parser diff --git a/pyomo/scripting/plugins/download.py b/pyomo/scripting/plugins/download.py index 80d5d643fa3..f3afc546dee 100644 --- a/pyomo/scripting/plugins/download.py +++ b/pyomo/scripting/plugins/download.py @@ -15,7 +15,7 @@ from pyomo.scripting.pyomo_parser import add_subparser -class GroupDownloader(object): +class GroupDownloader: def __init__(self): self.downloader = FileDownloader() diff --git a/pyomo/scripting/solve_config.py b/pyomo/scripting/solve_config.py index 35f0fbb8dbf..69831a3c6c8 100644 --- a/pyomo/scripting/solve_config.py +++ b/pyomo/scripting/solve_config.py @@ -12,7 +12,7 @@ from pyomo.common.config import ConfigBlock, ConfigList, ConfigValue -class Default_Config(object): +class Default_Config: def config_block(self, init=False): config, blocks = minlp_config_block(init=init) return config, blocks diff --git a/pyomo/scripting/util.py b/pyomo/scripting/util.py index 35b5c090bd5..00f517ef2ad 100644 --- a/pyomo/scripting/util.py +++ b/pyomo/scripting/util.py @@ -912,7 +912,7 @@ def configure_loggers(options=None, shutdown=False): configure_loggers.fileLogger = None -class PyomoCommandLogContext(object): +class PyomoCommandLogContext: """Context manager to setup/restore logging for the Pyomo command""" def __init__(self, options): diff --git a/pyomo/solvers/mockmip.py b/pyomo/solvers/mockmip.py index 626c289baf3..1a00c833a0d 100644 --- a/pyomo/solvers/mockmip.py +++ b/pyomo/solvers/mockmip.py @@ -17,7 +17,7 @@ from pyomo.opt.base.solvers import _extract_version -class MockMIP(object): +class MockMIP: """Methods used to create a mock MIP solver used for testing""" def __init__(self, mockdir): diff --git a/pyomo/solvers/plugins/converter/ampl.py b/pyomo/solvers/plugins/converter/ampl.py index 69a0eea382f..b2338917b5d 100644 --- a/pyomo/solvers/plugins/converter/ampl.py +++ b/pyomo/solvers/plugins/converter/ampl.py @@ -20,7 +20,7 @@ @ProblemConverterFactory.register('ampl') -class AmplMIPConverter(object): +class AmplMIPConverter: def can_convert(self, from_type, to_type): """Returns true if this object supports the specified conversion""" # diff --git a/pyomo/solvers/plugins/converter/glpsol.py b/pyomo/solvers/plugins/converter/glpsol.py index b0da85e0e13..33792d5ed1d 100644 --- a/pyomo/solvers/plugins/converter/glpsol.py +++ b/pyomo/solvers/plugins/converter/glpsol.py @@ -20,7 +20,7 @@ @ProblemConverterFactory.register('glpsol') -class GlpsolMIPConverter(object): +class GlpsolMIPConverter: def can_convert(self, from_type, to_type): """Returns true if this object supports the specified conversion""" # diff --git a/pyomo/solvers/plugins/converter/model.py b/pyomo/solvers/plugins/converter/model.py index d06c9dd2a3b..40c1003cda6 100644 --- a/pyomo/solvers/plugins/converter/model.py +++ b/pyomo/solvers/plugins/converter/model.py @@ -20,7 +20,7 @@ @ProblemConverterFactory.register('pyomo') -class PyomoMIPConverter(object): +class PyomoMIPConverter: pico_converter = PicoMIPConverter() def can_convert(self, from_type, to_type): diff --git a/pyomo/solvers/plugins/converter/pico.py b/pyomo/solvers/plugins/converter/pico.py index bb5a8955693..74c500dcd41 100644 --- a/pyomo/solvers/plugins/converter/pico.py +++ b/pyomo/solvers/plugins/converter/pico.py @@ -19,7 +19,7 @@ from pyomo.opt.base import ProblemFormat, ConverterError -class PicoMIPConverter(object): +class PicoMIPConverter: def can_convert(self, from_type, to_type): """Returns true if this object supports the specified conversion""" # diff --git a/pyomo/solvers/plugins/solvers/CPLEX.py b/pyomo/solvers/plugins/solvers/CPLEX.py index f684525bac9..7e959899aed 100644 --- a/pyomo/solvers/plugins/solvers/CPLEX.py +++ b/pyomo/solvers/plugins/solvers/CPLEX.py @@ -132,7 +132,7 @@ def __new__(cls, *args, **kwds): return opt -class ORDFileSchema(object): +class ORDFileSchema: HEADER = "* ENCODING=ISO-8859-1\nNAME Priority Order\n" FOOTER = "ENDATA\n" diff --git a/pyomo/solvers/plugins/solvers/GAMS.py b/pyomo/solvers/plugins/solvers/GAMS.py index 40c40921d72..ece8bc5a37c 100644 --- a/pyomo/solvers/plugins/solvers/GAMS.py +++ b/pyomo/solvers/plugins/solvers/GAMS.py @@ -46,7 +46,7 @@ logger = logging.getLogger('pyomo.solvers') -class _GAMSSolver(object): +class _GAMSSolver: """Aggregate of common methods for GAMS interfaces""" def __init__(self, **kwds): diff --git a/pyomo/solvers/plugins/solvers/cplex_direct.py b/pyomo/solvers/plugins/solvers/cplex_direct.py index 31ad292676c..61615265fb6 100644 --- a/pyomo/solvers/plugins/solvers/cplex_direct.py +++ b/pyomo/solvers/plugins/solvers/cplex_direct.py @@ -39,7 +39,7 @@ class DegreeError(ValueError): pass -class _CplexExpr(object): +class _CplexExpr: def __init__( self, variables, @@ -65,7 +65,7 @@ def _is_numeric(x): return True -class _VariableData(object): +class _VariableData: def __init__(self, solver_model): self._solver_model = solver_model self.lb = [] @@ -85,7 +85,7 @@ def store_in_cplex(self): ) -class _LinearConstraintData(object): +class _LinearConstraintData: def __init__(self, solver_model): self._solver_model = solver_model self.lin_expr = [] diff --git a/pyomo/solvers/plugins/solvers/xpress_direct.py b/pyomo/solvers/plugins/solvers/xpress_direct.py index a3ae6cc5800..f1c5919b0e1 100644 --- a/pyomo/solvers/plugins/solvers/xpress_direct.py +++ b/pyomo/solvers/plugins/solvers/xpress_direct.py @@ -170,7 +170,7 @@ def _addConstraint( ComponentMap.hasher.hashable(xpress.var, False) -class _xpress_importer_class(object): +class _xpress_importer_class: # We want to be able to *update* the message that the deferred # import generates using the stdout recorded during the actual # import. As strings are immutable in Python, we will give this diff --git a/pyomo/solvers/tests/checks/test_cplex.py b/pyomo/solvers/tests/checks/test_cplex.py index 1e06812f7d3..86eccc97263 100644 --- a/pyomo/solvers/tests/checks/test_cplex.py +++ b/pyomo/solvers/tests/checks/test_cplex.py @@ -35,12 +35,12 @@ ) -class _mock_cplex_128(object): +class _mock_cplex_128: def version(self): return (12, 8, 0) -class _mock_cplex_126(object): +class _mock_cplex_126: def version(self): return (12, 6, 0) diff --git a/pyomo/solvers/tests/checks/test_xpress_persistent.py b/pyomo/solvers/tests/checks/test_xpress_persistent.py index ad066af20e0..d5ec3a78d4a 100644 --- a/pyomo/solvers/tests/checks/test_xpress_persistent.py +++ b/pyomo/solvers/tests/checks/test_xpress_persistent.py @@ -375,7 +375,7 @@ def test_nonconvexqp_infeasible(self): ) def test_available(self): - class mock_xpress(object): + class mock_xpress: def __init__(self, importable, initable): self._initable = initable xpd.xpress_available = importable diff --git a/pyomo/solvers/tests/mip/test_convert.py b/pyomo/solvers/tests/mip/test_convert.py index 07529223037..e368bbad6f6 100644 --- a/pyomo/solvers/tests/mip/test_convert.py +++ b/pyomo/solvers/tests/mip/test_convert.py @@ -37,7 +37,7 @@ def filter(line): deleteFiles = True -class MockArg(object): +class MockArg: def __init__(self): pass diff --git a/pyomo/solvers/tests/models/base.py b/pyomo/solvers/tests/models/base.py index 020ae0a044e..4f130da0c8d 100644 --- a/pyomo/solvers/tests/models/base.py +++ b/pyomo/solvers/tests/models/base.py @@ -43,7 +43,7 @@ def register_model(cls): return cls -class _BaseTestModel(object): +class _BaseTestModel: """ This is a base class for test models """ diff --git a/pyomo/solvers/wrappers.py b/pyomo/solvers/wrappers.py index b8c4dba08e3..eca20d8ab7d 100644 --- a/pyomo/solvers/wrappers.py +++ b/pyomo/solvers/wrappers.py @@ -10,6 +10,6 @@ # ___________________________________________________________________________ -class MIPSolverWrapper(object): +class MIPSolverWrapper: def add(self, constraint): # pragma:nocover pass diff --git a/pyomo/util/subsystems.py b/pyomo/util/subsystems.py index 20e2c23fc4d..5b3e9666fa7 100644 --- a/pyomo/util/subsystems.py +++ b/pyomo/util/subsystems.py @@ -164,7 +164,7 @@ def generate_subsystem_blocks(subsystems, include_fixed=False): yield block, list(block.input_vars.values()) -class TemporarySubsystemManager(object): +class TemporarySubsystemManager: """This class is a context manager for cases when we want to temporarily fix or deactivate certain variables or constraints in order to perform some solve or calculation with the resulting diff --git a/scripts/performance/compare.py b/scripts/performance/compare.py index 5ee19dd63d3..e42c46be823 100755 --- a/scripts/performance/compare.py +++ b/scripts/performance/compare.py @@ -31,7 +31,7 @@ # stdev(x)**2 / card(x) + stdev(y)**2 / card(y) ) -class Result(object): +class Result: z_threshold = 1.6448536269514722 # 95% # z_threshold = 1.2815515655446004 # 90% # z_threshold = 0.8416212335729143 # 80% diff --git a/scripts/performance/main.py b/scripts/performance/main.py index 3adc956d925..b8ec14aebe9 100755 --- a/scripts/performance/main.py +++ b/scripts/performance/main.py @@ -75,7 +75,7 @@ def emit(self, record): cat_data[name] = val -class DataRecorder(object): +class DataRecorder: """pytest plugin to add a 'testdata' attribute to all tests This plugin adds an OrderedDict `testdata` attribute to all tests, diff --git a/setup.py b/setup.py index 043b0a637f2..ff5c9274df9 100644 --- a/setup.py +++ b/setup.py @@ -173,7 +173,7 @@ def run(self): print(' '.join(deps)) def _print_deps(self, deplist): - class version_cmp(object): + class version_cmp: ver = tuple(map(int, platform.python_version_tuple()[:2])) def __lt__(self, other):