From f43a49e105a14d04756e1d510e1fbf8aa5a4e138 Mon Sep 17 00:00:00 2001 From: Miranda Mundt Date: Fri, 16 Feb 2024 14:51:59 -0700 Subject: [PATCH 1/2] Remove __all__ from modules --- pyomo/common/_command.py | 2 -- pyomo/contrib/pynumero/interfaces/ampl_nlp.py | 4 +--- pyomo/contrib/pynumero/interfaces/nlp.py | 3 +-- .../contrib/pynumero/interfaces/pyomo_nlp.py | 3 --- pyomo/contrib/pynumero/sparse/block_matrix.py | 2 -- pyomo/contrib/pynumero/sparse/block_vector.py | 2 -- .../pynumero/sparse/mpi_block_matrix.py | 2 -- .../pynumero/sparse/mpi_block_vector.py | 2 -- pyomo/core/base/PyomoModel.py | 7 ++---- pyomo/core/base/action.py | 5 ++-- pyomo/core/base/block.py | 14 ----------- pyomo/core/base/blockutil.py | 2 -- pyomo/core/base/check.py | 2 -- pyomo/core/base/component_order.py | 3 --- pyomo/core/base/connector.py | 3 --- pyomo/core/base/constraint.py | 10 -------- pyomo/core/base/expression.py | 5 +--- pyomo/core/base/external.py | 2 -- pyomo/core/base/indexed_component.py | 8 +------ pyomo/core/base/instance2dat.py | 2 -- pyomo/core/base/label.py | 11 --------- pyomo/core/base/logical_constraint.py | 3 --- pyomo/core/base/misc.py | 4 ---- pyomo/core/base/objective.py | 10 -------- pyomo/core/base/param.py | 2 -- pyomo/core/base/piecewise.py | 3 --- pyomo/core/base/plugin.py | 24 ------------------- pyomo/core/base/rangeset.py | 2 -- pyomo/core/base/sets.py | 2 -- pyomo/core/base/sos.py | 2 -- pyomo/core/base/suffix.py | 2 -- pyomo/core/base/var.py | 5 ---- pyomo/core/beta/dict_objects.py | 2 -- pyomo/core/beta/list_objects.py | 2 -- pyomo/core/expr/__init__.py | 8 ------- pyomo/core/expr/numvalue.py | 17 ------------- pyomo/core/util.py | 12 ---------- pyomo/dae/contset.py | 1 - pyomo/dae/diffvar.py | 2 -- pyomo/dae/integral.py | 2 -- pyomo/dae/simulator.py | 12 ++++------ pyomo/dataportal/DataPortal.py | 2 -- pyomo/dataportal/TableData.py | 2 -- pyomo/dataportal/factory.py | 2 -- pyomo/dataportal/parse_datacmds.py | 2 -- pyomo/network/arc.py | 2 -- pyomo/network/decomposition.py | 2 -- pyomo/network/port.py | 2 -- pyomo/opt/base/convert.py | 2 -- pyomo/opt/base/formats.py | 5 ---- pyomo/opt/base/problem.py | 2 -- pyomo/opt/base/results.py | 2 -- pyomo/opt/base/solvers.py | 5 +--- pyomo/opt/parallel/async_solver.py | 3 --- pyomo/opt/parallel/local.py | 3 --- pyomo/opt/parallel/manager.py | 10 -------- pyomo/opt/problem/ampl.py | 2 -- pyomo/opt/results/container.py | 17 ++----------- pyomo/opt/results/problem.py | 2 -- pyomo/opt/results/results_.py | 4 +--- pyomo/opt/results/solution.py | 2 -- pyomo/opt/results/solver.py | 8 ------- pyomo/opt/solver/ilmcmd.py | 2 -- pyomo/opt/solver/shellcmd.py | 2 -- pyomo/opt/testing/pyunit.py | 3 --- pyomo/repn/beta/matrix.py | 6 ----- pyomo/repn/plugins/ampl/ampl_.py | 2 -- pyomo/repn/standard_aux.py | 3 --- pyomo/repn/standard_repn.py | 3 --- pyomo/scripting/convert.py | 2 -- pyomo/scripting/pyomo_parser.py | 2 -- pyomo/solvers/plugins/solvers/CBCplugin.py | 2 -- pyomo/solvers/tests/solvers.py | 2 -- pyomo/util/blockutil.py | 2 -- 74 files changed, 16 insertions(+), 307 deletions(-) diff --git a/pyomo/common/_command.py b/pyomo/common/_command.py index 0777155a557..ad521659aa7 100644 --- a/pyomo/common/_command.py +++ b/pyomo/common/_command.py @@ -13,8 +13,6 @@ Management of Pyomo commands """ -__all__ = ['pyomo_command', 'get_pyomo_commands'] - import logging logger = logging.getLogger('pyomo.common') diff --git a/pyomo/contrib/pynumero/interfaces/ampl_nlp.py b/pyomo/contrib/pynumero/interfaces/ampl_nlp.py index c19d252667d..30258b3e685 100644 --- a/pyomo/contrib/pynumero/interfaces/ampl_nlp.py +++ b/pyomo/contrib/pynumero/interfaces/ampl_nlp.py @@ -27,10 +27,8 @@ from pyomo.common.deprecation import deprecated from pyomo.contrib.pynumero.interfaces.nlp import ExtendedNLP -__all__ = ['AslNLP', 'AmplNLP'] - -# ToDo: need to add support for modifying bounds. +# TODO: need to add support for modifying bounds. # support for changing variable bounds seems possible. # support for changing inequality bounds would require more work. (this is less frequent?) # TODO: check performance impacts of caching - memory and computational time. diff --git a/pyomo/contrib/pynumero/interfaces/nlp.py b/pyomo/contrib/pynumero/interfaces/nlp.py index 20b3a5e4938..d6571086429 100644 --- a/pyomo/contrib/pynumero/interfaces/nlp.py +++ b/pyomo/contrib/pynumero/interfaces/nlp.py @@ -50,9 +50,8 @@ .. rubric:: Contents """ -import abc -__all__ = ['NLP'] +import abc class NLP(object, metaclass=abc.ABCMeta): diff --git a/pyomo/contrib/pynumero/interfaces/pyomo_nlp.py b/pyomo/contrib/pynumero/interfaces/pyomo_nlp.py index f9014ab29c0..51edd09311a 100644 --- a/pyomo/contrib/pynumero/interfaces/pyomo_nlp.py +++ b/pyomo/contrib/pynumero/interfaces/pyomo_nlp.py @@ -28,9 +28,6 @@ from .external_grey_box import ExternalGreyBoxBlock -__all__ = ['PyomoNLP'] - - # TODO: There are todos in the code below class PyomoNLP(AslNLP): def __init__(self, pyomo_model, nl_file_options=None): diff --git a/pyomo/contrib/pynumero/sparse/block_matrix.py b/pyomo/contrib/pynumero/sparse/block_matrix.py index ba7ed4f085b..02ad584928b 100644 --- a/pyomo/contrib/pynumero/sparse/block_matrix.py +++ b/pyomo/contrib/pynumero/sparse/block_matrix.py @@ -31,8 +31,6 @@ import logging import warnings -__all__ = ['BlockMatrix', 'NotFullyDefinedBlockMatrixError'] - logger = logging.getLogger(__name__) diff --git a/pyomo/contrib/pynumero/sparse/block_vector.py b/pyomo/contrib/pynumero/sparse/block_vector.py index 2b529736935..b636dd74203 100644 --- a/pyomo/contrib/pynumero/sparse/block_vector.py +++ b/pyomo/contrib/pynumero/sparse/block_vector.py @@ -27,8 +27,6 @@ from ..dependencies import numpy as np from .base_block import BaseBlockVector -__all__ = ['BlockVector', 'NotFullyDefinedBlockVectorError'] - class NotFullyDefinedBlockVectorError(Exception): pass diff --git a/pyomo/contrib/pynumero/sparse/mpi_block_matrix.py b/pyomo/contrib/pynumero/sparse/mpi_block_matrix.py index 28a39b4e2eb..d32adebce0e 100644 --- a/pyomo/contrib/pynumero/sparse/mpi_block_matrix.py +++ b/pyomo/contrib/pynumero/sparse/mpi_block_matrix.py @@ -32,8 +32,6 @@ from scipy.sparse import coo_matrix import operator -__all__ = ['MPIBlockMatrix'] - def assert_block_structure(mat: MPIBlockMatrix): if mat.has_undefined_row_sizes() or mat.has_undefined_col_sizes(): diff --git a/pyomo/contrib/pynumero/sparse/mpi_block_vector.py b/pyomo/contrib/pynumero/sparse/mpi_block_vector.py index be8091c9597..89cf136a5f7 100644 --- a/pyomo/contrib/pynumero/sparse/mpi_block_vector.py +++ b/pyomo/contrib/pynumero/sparse/mpi_block_vector.py @@ -17,8 +17,6 @@ import numpy as np import operator -__all__ = ['MPIBlockVector'] - def assert_block_structure(vec): if vec.has_none: diff --git a/pyomo/core/base/PyomoModel.py b/pyomo/core/base/PyomoModel.py index 759b17c9a79..ba7823c642a 100644 --- a/pyomo/core/base/PyomoModel.py +++ b/pyomo/core/base/PyomoModel.py @@ -9,8 +9,6 @@ # This software is distributed under the 3-clause BSD License. # ___________________________________________________________________________ -__all__ = ['Model', 'ConcreteModel', 'AbstractModel', 'global_option'] - import logging import sys from weakref import ref as weakref_ref @@ -20,7 +18,7 @@ from pyomo.common import timing from pyomo.common.collections import Bunch from pyomo.common.dependencies import pympler, pympler_available -from pyomo.common.deprecation import deprecated, deprecation_warning +from pyomo.common.deprecation import deprecated from pyomo.common.gc_manager import PauseGC from pyomo.common.log import is_debug_set from pyomo.common.numeric_types import value @@ -34,11 +32,10 @@ from pyomo.core.base.block import ScalarBlock from pyomo.core.base.set import Set from pyomo.core.base.componentuid import ComponentUID -from pyomo.core.base.transformation import TransformationFactory from pyomo.core.base.label import CNameLabeler, CuidLabeler from pyomo.dataportal.DataPortal import DataPortal -from pyomo.opt.results import SolverResults, Solution, SolverStatus, UndefinedData +from pyomo.opt.results import Solution, SolverStatus, UndefinedData from contextlib import nullcontext from io import StringIO diff --git a/pyomo/core/base/action.py b/pyomo/core/base/action.py index f929c4b38ff..d24d94fe05a 100644 --- a/pyomo/core/base/action.py +++ b/pyomo/core/base/action.py @@ -9,8 +9,6 @@ # This software is distributed under the 3-clause BSD License. # ___________________________________________________________________________ -__all__ = ['BuildAction'] - import logging import types @@ -24,7 +22,8 @@ @ModelComponentFactory.register( - "A component that performs arbitrary actions during model construction. The action rule is applied to every index value." + "A component that performs arbitrary actions during model construction. " + "The action rule is applied to every index value." ) class BuildAction(IndexedComponent): """A build action, which executes a rule for all valid indices. diff --git a/pyomo/core/base/block.py b/pyomo/core/base/block.py index 190a820fbfe..48353078fca 100644 --- a/pyomo/core/base/block.py +++ b/pyomo/core/base/block.py @@ -9,20 +9,7 @@ # This software is distributed under the 3-clause BSD License. # ___________________________________________________________________________ -__all__ = [ - 'Block', - 'TraversalStrategy', - 'SortComponents', - 'active_components', - 'components', - 'active_components_data', - 'components_data', - 'SimpleBlock', - 'ScalarBlock', -] - import copy -import enum import logging import sys import weakref @@ -41,7 +28,6 @@ from pyomo.common.formatting import StreamIndenter from pyomo.common.gc_manager import PauseGC from pyomo.common.log import is_debug_set -from pyomo.common.sorting import sorted_robust from pyomo.common.timing import ConstructionTimer from pyomo.core.base.component import ( Component, diff --git a/pyomo/core/base/blockutil.py b/pyomo/core/base/blockutil.py index fc763da8b98..d91a5c85ac2 100644 --- a/pyomo/core/base/blockutil.py +++ b/pyomo/core/base/blockutil.py @@ -12,8 +12,6 @@ # the purpose of this file is to collect all utility methods that compute # attributes of blocks, based on their contents. -__all__ = ['has_discrete_variables'] - from pyomo.common import deprecated from pyomo.core.base import Var diff --git a/pyomo/core/base/check.py b/pyomo/core/base/check.py index cbf2a99e7a3..485d1a73b6b 100644 --- a/pyomo/core/base/check.py +++ b/pyomo/core/base/check.py @@ -9,8 +9,6 @@ # This software is distributed under the 3-clause BSD License. # ___________________________________________________________________________ -__all__ = ['BuildCheck'] - import logging import types diff --git a/pyomo/core/base/component_order.py b/pyomo/core/base/component_order.py index 8e69baa0972..9244828cbe5 100644 --- a/pyomo/core/base/component_order.py +++ b/pyomo/core/base/component_order.py @@ -9,9 +9,6 @@ # This software is distributed under the 3-clause BSD License. # ___________________________________________________________________________ - -__all__ = ['items', 'display_items', 'display_name'] - from pyomo.core.base.set import Set, RangeSet from pyomo.core.base.param import Param from pyomo.core.base.var import Var diff --git a/pyomo/core/base/connector.py b/pyomo/core/base/connector.py index 8dfee45236e..435a2c2fccb 100644 --- a/pyomo/core/base/connector.py +++ b/pyomo/core/base/connector.py @@ -9,8 +9,6 @@ # This software is distributed under the 3-clause BSD License. # ___________________________________________________________________________ -__all__ = ['Connector'] - import logging import sys from weakref import ref as weakref_ref @@ -26,7 +24,6 @@ from pyomo.core.base.global_set import UnindexedComponent_index from pyomo.core.base.indexed_component import IndexedComponent from pyomo.core.base.misc import apply_indexed_rule -from pyomo.core.base.transformation import TransformationFactory logger = logging.getLogger('pyomo.core') diff --git a/pyomo/core/base/constraint.py b/pyomo/core/base/constraint.py index 21da457edf6..c67236656be 100644 --- a/pyomo/core/base/constraint.py +++ b/pyomo/core/base/constraint.py @@ -9,18 +9,8 @@ # This software is distributed under the 3-clause BSD License. # ___________________________________________________________________________ -__all__ = [ - 'Constraint', - '_ConstraintData', - 'ConstraintList', - 'simple_constraint_rule', - 'simple_constraintlist_rule', -] - -import io import sys import logging -import math from weakref import ref as weakref_ref from pyomo.common.pyomo_typing import overload diff --git a/pyomo/core/base/expression.py b/pyomo/core/base/expression.py index 3695f95b0be..3ce998b62a4 100644 --- a/pyomo/core/base/expression.py +++ b/pyomo/core/base/expression.py @@ -9,15 +9,13 @@ # This software is distributed under the 3-clause BSD License. # ___________________________________________________________________________ -__all__ = ['Expression', '_ExpressionData'] - import sys import logging from weakref import ref as weakref_ref from pyomo.common.pyomo_typing import overload from pyomo.common.log import is_debug_set -from pyomo.common.deprecation import deprecated, RenamedClass +from pyomo.common.deprecation import RenamedClass from pyomo.common.modeling import NOTSET from pyomo.common.formatting import tabular_writer from pyomo.common.timing import ConstructionTimer @@ -32,7 +30,6 @@ from pyomo.core.base.component import ComponentData, ModelComponentFactory from pyomo.core.base.global_set import UnindexedComponent_index from pyomo.core.base.indexed_component import IndexedComponent, UnindexedComponent_set -from pyomo.core.base.misc import apply_indexed_rule from pyomo.core.expr.numvalue import as_numeric from pyomo.core.base.initializer import Initializer diff --git a/pyomo/core/base/external.py b/pyomo/core/base/external.py index c1f7ef32a80..3c0038d745d 100644 --- a/pyomo/core/base/external.py +++ b/pyomo/core/base/external.py @@ -43,8 +43,6 @@ from pyomo.core.base.component import Component from pyomo.core.base.units_container import units -__all__ = ('ExternalFunction',) - logger = logging.getLogger('pyomo.core') nan = float('nan') diff --git a/pyomo/core/base/indexed_component.py b/pyomo/core/base/indexed_component.py index e87cafa0606..abb29580960 100644 --- a/pyomo/core/base/indexed_component.py +++ b/pyomo/core/base/indexed_component.py @@ -9,16 +9,11 @@ # This software is distributed under the 3-clause BSD License. # ___________________________________________________________________________ -__all__ = ['IndexedComponent', 'ActiveIndexedComponent'] - -import enum import inspect import logging import sys import textwrap -from copy import deepcopy - import pyomo.core.expr as EXPR import pyomo.core.base as BASE from pyomo.core.base.indexed_component_slice import IndexedComponent_slice @@ -32,9 +27,8 @@ from pyomo.common import DeveloperError from pyomo.common.autoslots import fast_deepcopy from pyomo.common.collections import ComponentSet -from pyomo.common.dependencies import numpy as np, numpy_available from pyomo.common.deprecation import deprecated, deprecation_warning -from pyomo.common.errors import DeveloperError, TemplateExpressionError +from pyomo.common.errors import TemplateExpressionError from pyomo.common.modeling import NOTSET from pyomo.common.numeric_types import native_types from pyomo.common.sorting import sorted_robust diff --git a/pyomo/core/base/instance2dat.py b/pyomo/core/base/instance2dat.py index 4dab6435187..5cd690b7ece 100644 --- a/pyomo/core/base/instance2dat.py +++ b/pyomo/core/base/instance2dat.py @@ -9,8 +9,6 @@ # This software is distributed under the 3-clause BSD License. # ___________________________________________________________________________ -__all__ = ['instance2dat'] - import types from pyomo.core.base import Set, Param, value diff --git a/pyomo/core/base/label.py b/pyomo/core/base/label.py index 4ed61773a7e..e22c1283138 100644 --- a/pyomo/core/base/label.py +++ b/pyomo/core/base/label.py @@ -9,17 +9,6 @@ # This software is distributed under the 3-clause BSD License. # ___________________________________________________________________________ -__all__ = [ - 'CounterLabeler', - 'NumericLabeler', - 'CNameLabeler', - 'TextLabeler', - 'AlphaNumericTextLabeler', - 'NameLabeler', - 'CuidLabeler', - 'ShortNameLabeler', -] - import re from pyomo.common.deprecation import deprecated diff --git a/pyomo/core/base/logical_constraint.py b/pyomo/core/base/logical_constraint.py index 9a6e9d552d0..f32d727931a 100644 --- a/pyomo/core/base/logical_constraint.py +++ b/pyomo/core/base/logical_constraint.py @@ -9,8 +9,6 @@ # This software is distributed under the 3-clause BSD License. # ___________________________________________________________________________ -__all__ = ['LogicalConstraint', '_LogicalConstraintData', 'LogicalConstraintList'] - import inspect import sys import logging @@ -22,7 +20,6 @@ from pyomo.common.modeling import NOTSET from pyomo.common.timing import ConstructionTimer -from pyomo.core.base.constraint import Constraint from pyomo.core.expr.boolean_value import as_boolean, BooleanConstant from pyomo.core.expr.numvalue import native_types, native_logical_types from pyomo.core.base.component import ActiveComponentData, ModelComponentFactory diff --git a/pyomo/core/base/misc.py b/pyomo/core/base/misc.py index 926d4e576f4..456a4531e30 100644 --- a/pyomo/core/base/misc.py +++ b/pyomo/core/base/misc.py @@ -9,14 +9,10 @@ # This software is distributed under the 3-clause BSD License. # ___________________________________________________________________________ -__all__ = ['display'] - import logging import sys -import types from pyomo.common.deprecation import relocated_module_attribute -from pyomo.core.expr import native_numeric_types logger = logging.getLogger('pyomo.core') diff --git a/pyomo/core/base/objective.py b/pyomo/core/base/objective.py index f0e60a00e85..fcc63755f2b 100644 --- a/pyomo/core/base/objective.py +++ b/pyomo/core/base/objective.py @@ -9,16 +9,6 @@ # This software is distributed under the 3-clause BSD License. # ___________________________________________________________________________ -__all__ = ( - 'Objective', - 'simple_objective_rule', - '_ObjectiveData', - 'minimize', - 'maximize', - 'simple_objectivelist_rule', - 'ObjectiveList', -) - import sys import logging from weakref import ref as weakref_ref diff --git a/pyomo/core/base/param.py b/pyomo/core/base/param.py index 88e7ca98de7..03d700140e8 100644 --- a/pyomo/core/base/param.py +++ b/pyomo/core/base/param.py @@ -9,8 +9,6 @@ # This software is distributed under the 3-clause BSD License. # ___________________________________________________________________________ -__all__ = ['Param'] - import sys import types import logging diff --git a/pyomo/core/base/piecewise.py b/pyomo/core/base/piecewise.py index b6ae66ac093..7817a61b2f2 100644 --- a/pyomo/core/base/piecewise.py +++ b/pyomo/core/base/piecewise.py @@ -32,9 +32,6 @@ *) piecewise for functions of the form y = f(x1,x2,...) """ - -__all__ = ['Piecewise'] - import logging import math import itertools diff --git a/pyomo/core/base/plugin.py b/pyomo/core/base/plugin.py index 8c44af2dd61..062e9f9fb85 100644 --- a/pyomo/core/base/plugin.py +++ b/pyomo/core/base/plugin.py @@ -21,30 +21,6 @@ calling_frame=inspect.currentframe().f_back, ) -__all__ = [ - 'pyomo_callback', - 'IPyomoExpression', - 'ExpressionFactory', - 'ExpressionRegistration', - 'IPyomoPresolver', - 'IPyomoPresolveAction', - 'IParamRepresentation', - 'ParamRepresentationFactory', - 'IPyomoScriptPreprocess', - 'IPyomoScriptCreateModel', - 'IPyomoScriptCreateDataPortal', - 'IPyomoScriptModifyInstance', - 'IPyomoScriptPrintModel', - 'IPyomoScriptPrintInstance', - 'IPyomoScriptSaveInstance', - 'IPyomoScriptPrintResults', - 'IPyomoScriptSaveResults', - 'IPyomoScriptPostprocess', - 'ModelComponentFactory', - 'Transformation', - 'TransformationFactory', -] - from pyomo.core.base.component import ModelComponentFactory from pyomo.core.base.transformation import ( Transformation, diff --git a/pyomo/core/base/rangeset.py b/pyomo/core/base/rangeset.py index 27693548c1d..32e41698aab 100644 --- a/pyomo/core/base/rangeset.py +++ b/pyomo/core/base/rangeset.py @@ -9,8 +9,6 @@ # This software is distributed under the 3-clause BSD License. # ___________________________________________________________________________ -__all__ = ['RangeSet'] - from .set import RangeSet from pyomo.common.deprecation import deprecation_warning diff --git a/pyomo/core/base/sets.py b/pyomo/core/base/sets.py index f2ae44be459..ca693cf7d8b 100644 --- a/pyomo/core/base/sets.py +++ b/pyomo/core/base/sets.py @@ -13,8 +13,6 @@ # . rename 'filter' to something else # . confirm that filtering is efficient -__all__ = ['Set', 'set_options', 'simple_set_rule', 'SetOf'] - from .set import ( process_setarg, set_options, diff --git a/pyomo/core/base/sos.py b/pyomo/core/base/sos.py index 32265df6686..6b8586c9b49 100644 --- a/pyomo/core/base/sos.py +++ b/pyomo/core/base/sos.py @@ -9,8 +9,6 @@ # This software is distributed under the 3-clause BSD License. # ___________________________________________________________________________ -__all__ = ['SOSConstraint'] - import sys import logging diff --git a/pyomo/core/base/suffix.py b/pyomo/core/base/suffix.py index 67ab0b74215..0c27eee060f 100644 --- a/pyomo/core/base/suffix.py +++ b/pyomo/core/base/suffix.py @@ -9,8 +9,6 @@ # This software is distributed under the 3-clause BSD License. # ___________________________________________________________________________ -__all__ = ('Suffix', 'active_export_suffix_generator', 'active_import_suffix_generator') - import enum import logging diff --git a/pyomo/core/base/var.py b/pyomo/core/base/var.py index 67b6e1a28d7..d03fd0b677f 100644 --- a/pyomo/core/base/var.py +++ b/pyomo/core/base/var.py @@ -9,8 +9,6 @@ # This software is distributed under the 3-clause BSD License. # ___________________________________________________________________________ -__all__ = ['Var', '_VarData', '_GeneralVarData', 'VarList', 'SimpleVar', 'ScalarVar'] - import logging import sys from pyomo.common.pyomo_typing import overload @@ -29,7 +27,6 @@ value, is_potentially_variable, native_numeric_types, - native_types, ) from pyomo.core.base.component import ComponentData, ModelComponentFactory from pyomo.core.base.global_set import UnindexedComponent_index @@ -44,7 +41,6 @@ DefaultInitializer, BoundInitializer, ) -from pyomo.core.base.misc import apply_indexed_rule from pyomo.core.base.set import ( Reals, Binary, @@ -54,7 +50,6 @@ integer_global_set_ids, ) from pyomo.core.base.units_container import units -from pyomo.core.base.util import is_functor logger = logging.getLogger('pyomo.core') diff --git a/pyomo/core/beta/dict_objects.py b/pyomo/core/beta/dict_objects.py index a698fcbb717..a8298b08e63 100644 --- a/pyomo/core/beta/dict_objects.py +++ b/pyomo/core/beta/dict_objects.py @@ -9,8 +9,6 @@ # This software is distributed under the 3-clause BSD License. # ___________________________________________________________________________ -__all__ = () - import logging from weakref import ref as weakref_ref diff --git a/pyomo/core/beta/list_objects.py b/pyomo/core/beta/list_objects.py index f2ccf0d37aa..f53997fed17 100644 --- a/pyomo/core/beta/list_objects.py +++ b/pyomo/core/beta/list_objects.py @@ -9,8 +9,6 @@ # This software is distributed under the 3-clause BSD License. # ___________________________________________________________________________ -__all__ = () - import logging from weakref import ref as weakref_ref diff --git a/pyomo/core/expr/__init__.py b/pyomo/core/expr/__init__.py index 5efb5026c65..b0ad2ac4892 100644 --- a/pyomo/core/expr/__init__.py +++ b/pyomo/core/expr/__init__.py @@ -9,14 +9,6 @@ # This software is distributed under the 3-clause BSD License. # ___________________________________________________________________________ -# -# The definition of __all__ is a bit funky here, because we want to -# expose symbols in pyomo.core.expr.current that are not included in -# pyomo.core.expr. The idea is that pyomo.core.expr provides symbols -# that are used by general users, but pyomo.core.expr.current provides -# symbols that are used by developers. -# - from . import ( numvalue, visitor, diff --git a/pyomo/core/expr/numvalue.py b/pyomo/core/expr/numvalue.py index 8cc20648eb4..f3ea76c305c 100644 --- a/pyomo/core/expr/numvalue.py +++ b/pyomo/core/expr/numvalue.py @@ -9,21 +9,6 @@ # This software is distributed under the 3-clause BSD License. # ___________________________________________________________________________ -__all__ = ( - 'value', - 'is_constant', - 'is_fixed', - 'is_variable_type', - 'is_potentially_variable', - 'NumericValue', - 'ZeroConstant', - 'native_numeric_types', - 'native_types', - 'nonpyomo_leaf_types', - 'polynomial_degree', -) - -import collections import sys import logging @@ -34,7 +19,6 @@ ) from pyomo.core.expr.expr_common import ExpressionType from pyomo.core.expr.numeric_expr import NumericValue -import pyomo.common.numeric_types as _numeric_types # TODO: update Pyomo to import these objects from common.numeric_types # (and not from here) @@ -48,7 +32,6 @@ check_if_numeric_type, value, ) -from pyomo.core.pyomoobject import PyomoObject relocated_module_attribute( 'native_boolean_types', diff --git a/pyomo/core/util.py b/pyomo/core/util.py index 4e076c7505b..e4a70aea05a 100644 --- a/pyomo/core/util.py +++ b/pyomo/core/util.py @@ -13,24 +13,12 @@ # Utility functions # -__all__ = [ - 'sum_product', - 'summation', - 'dot_product', - 'sequence', - 'prod', - 'quicksum', - 'target_list', -] - from pyomo.common.deprecation import deprecation_warning from pyomo.core.expr.numvalue import native_numeric_types from pyomo.core.expr.numeric_expr import ( mutable_expression, - nonlinear_expression, NPV_SumExpression, ) -import pyomo.core.expr as EXPR from pyomo.core.base.var import Var from pyomo.core.base.expression import Expression from pyomo.core.base.component import _ComponentBase diff --git a/pyomo/dae/contset.py b/pyomo/dae/contset.py index 94d20723770..9b4f11714df 100644 --- a/pyomo/dae/contset.py +++ b/pyomo/dae/contset.py @@ -17,7 +17,6 @@ from pyomo.core.base.component import ModelComponentFactory logger = logging.getLogger('pyomo.dae') -__all__ = ['ContinuousSet'] @ModelComponentFactory.register( diff --git a/pyomo/dae/diffvar.py b/pyomo/dae/diffvar.py index 6bb3a8b06f0..b921107957f 100644 --- a/pyomo/dae/diffvar.py +++ b/pyomo/dae/diffvar.py @@ -16,8 +16,6 @@ from pyomo.core.base.var import Var from pyomo.dae.contset import ContinuousSet -__all__ = ('DerivativeVar', 'DAE_Error') - def create_access_function(var): """ diff --git a/pyomo/dae/integral.py b/pyomo/dae/integral.py index 34a34fdcd9c..41114296a93 100644 --- a/pyomo/dae/integral.py +++ b/pyomo/dae/integral.py @@ -21,8 +21,6 @@ from pyomo.dae.contset import ContinuousSet from pyomo.dae.diffvar import DAE_Error -__all__ = ('Integral',) - @ModelComponentFactory.register("Integral Expression in a DAE model.") class Integral(Expression): diff --git a/pyomo/dae/simulator.py b/pyomo/dae/simulator.py index f9121dbc0cc..72ba0c7331d 100644 --- a/pyomo/dae/simulator.py +++ b/pyomo/dae/simulator.py @@ -17,20 +17,14 @@ # the U.S. Government retains certain rights in this software. # This software is distributed under the BSD License. # _________________________________________________________________________ -from pyomo.core.base import Constraint, Param, value, Suffix, Block +import logging +from pyomo.core.base import Constraint, Param, value, Suffix, Block from pyomo.dae import ContinuousSet, DerivativeVar from pyomo.dae.diffvar import DAE_Error - import pyomo.core.expr as EXPR from pyomo.core.expr.numvalue import native_numeric_types from pyomo.core.expr.template_expr import IndexTemplate, _GetItemIndexer - -import logging - -__all__ = ('Simulator',) -logger = logging.getLogger('pyomo.core') - from pyomo.common.dependencies import ( numpy as np, numpy_available, @@ -39,6 +33,8 @@ attempt_import, ) +logger = logging.getLogger('pyomo.core') + casadi_intrinsic = {} diff --git a/pyomo/dataportal/DataPortal.py b/pyomo/dataportal/DataPortal.py index 24a9c847d48..457bb1aacee 100644 --- a/pyomo/dataportal/DataPortal.py +++ b/pyomo/dataportal/DataPortal.py @@ -9,8 +9,6 @@ # This software is distributed under the 3-clause BSD License. # ___________________________________________________________________________ -__all__ = ['DataPortal'] - import logging from pyomo.common.log import is_debug_set from pyomo.dataportal.factory import DataManagerFactory, UnknownDataManager diff --git a/pyomo/dataportal/TableData.py b/pyomo/dataportal/TableData.py index b7fb98d596a..f1500d09f9b 100644 --- a/pyomo/dataportal/TableData.py +++ b/pyomo/dataportal/TableData.py @@ -9,8 +9,6 @@ # This software is distributed under the 3-clause BSD License. # ___________________________________________________________________________ -__all__ = ['TableData'] - from pyomo.common.collections import Bunch from pyomo.dataportal.process_data import _process_data diff --git a/pyomo/dataportal/factory.py b/pyomo/dataportal/factory.py index e6424be25c4..479769137e2 100644 --- a/pyomo/dataportal/factory.py +++ b/pyomo/dataportal/factory.py @@ -9,8 +9,6 @@ # This software is distributed under the 3-clause BSD License. # ___________________________________________________________________________ -__all__ = ['DataManagerFactory', 'UnknownDataManager'] - import logging from pyomo.common import Factory from pyomo.common.plugin_base import PluginError diff --git a/pyomo/dataportal/parse_datacmds.py b/pyomo/dataportal/parse_datacmds.py index d9f44405577..60e2f2c0acb 100644 --- a/pyomo/dataportal/parse_datacmds.py +++ b/pyomo/dataportal/parse_datacmds.py @@ -9,8 +9,6 @@ # This software is distributed under the 3-clause BSD License. # ___________________________________________________________________________ -__all__ = ['parse_data_commands'] - import bisect import sys import logging diff --git a/pyomo/network/arc.py b/pyomo/network/arc.py index 1aa2b88edb6..42b7c6ea075 100644 --- a/pyomo/network/arc.py +++ b/pyomo/network/arc.py @@ -9,8 +9,6 @@ # This software is distributed under the 3-clause BSD License. # ___________________________________________________________________________ -__all__ = ['Arc'] - from pyomo.network.port import Port from pyomo.core.base.component import ActiveComponentData, ModelComponentFactory from pyomo.core.base.indexed_component import ( diff --git a/pyomo/network/decomposition.py b/pyomo/network/decomposition.py index da7e8950395..1ffb6a710ff 100644 --- a/pyomo/network/decomposition.py +++ b/pyomo/network/decomposition.py @@ -9,8 +9,6 @@ # This software is distributed under the 3-clause BSD License. # ___________________________________________________________________________ -__all__ = ['SequentialDecomposition'] - from pyomo.network import Port, Arc from pyomo.network.foqus_graph import FOQUSGraph from pyomo.core import ( diff --git a/pyomo/network/port.py b/pyomo/network/port.py index 63ed8b097b1..26822d4fee9 100644 --- a/pyomo/network/port.py +++ b/pyomo/network/port.py @@ -9,8 +9,6 @@ # This software is distributed under the 3-clause BSD License. # ___________________________________________________________________________ -__all__ = ['Port'] - import logging, sys from weakref import ref as weakref_ref diff --git a/pyomo/opt/base/convert.py b/pyomo/opt/base/convert.py index a17d1914801..28ad6727d3e 100644 --- a/pyomo/opt/base/convert.py +++ b/pyomo/opt/base/convert.py @@ -9,8 +9,6 @@ # This software is distributed under the 3-clause BSD License. # ___________________________________________________________________________ -__all__ = ['convert_problem'] - import copy import os diff --git a/pyomo/opt/base/formats.py b/pyomo/opt/base/formats.py index 72c4f5306a7..6e9d3958f48 100644 --- a/pyomo/opt/base/formats.py +++ b/pyomo/opt/base/formats.py @@ -9,11 +9,6 @@ # This software is distributed under the 3-clause BSD License. # ___________________________________________________________________________ -# -# The formats that are supported by Pyomo -# -__all__ = ['ProblemFormat', 'ResultsFormat', 'guess_format'] - import enum diff --git a/pyomo/opt/base/problem.py b/pyomo/opt/base/problem.py index 02748e08b70..804a97e2e4c 100644 --- a/pyomo/opt/base/problem.py +++ b/pyomo/opt/base/problem.py @@ -9,8 +9,6 @@ # This software is distributed under the 3-clause BSD License. # ___________________________________________________________________________ -__all__ = ["AbstractProblemWriter", "WriterFactory", "BranchDirection"] - from pyomo.common import Factory diff --git a/pyomo/opt/base/results.py b/pyomo/opt/base/results.py index 8b00ec3e14e..ea295a66315 100644 --- a/pyomo/opt/base/results.py +++ b/pyomo/opt/base/results.py @@ -9,8 +9,6 @@ # This software is distributed under the 3-clause BSD License. # ___________________________________________________________________________ -__all__ = ['AbstractResultsReader', 'ReaderFactory'] - from pyomo.common import Factory diff --git a/pyomo/opt/base/solvers.py b/pyomo/opt/base/solvers.py index cc49349142e..68e719e3862 100644 --- a/pyomo/opt/base/solvers.py +++ b/pyomo/opt/base/solvers.py @@ -9,8 +9,6 @@ # This software is distributed under the 3-clause BSD License. # ___________________________________________________________________________ -__all__ = ('OptSolver', 'SolverFactory', 'UnknownSolver', 'check_available_solvers') - import re import sys import time @@ -18,12 +16,11 @@ import shlex from pyomo.common import Factory -from pyomo.common.config import ConfigDict from pyomo.common.errors import ApplicationError from pyomo.common.collections import Bunch from pyomo.opt.base.convert import convert_problem -from pyomo.opt.base.formats import ResultsFormat, ProblemFormat +from pyomo.opt.base.formats import ResultsFormat import pyomo.opt.base.results logger = logging.getLogger('pyomo.opt') diff --git a/pyomo/opt/parallel/async_solver.py b/pyomo/opt/parallel/async_solver.py index d74206e4790..74e222e2241 100644 --- a/pyomo/opt/parallel/async_solver.py +++ b/pyomo/opt/parallel/async_solver.py @@ -9,9 +9,6 @@ # This software is distributed under the 3-clause BSD License. # ___________________________________________________________________________ - -__all__ = ['AsynchronousSolverManager', 'SolverManagerFactory'] - from pyomo.common import Factory from pyomo.opt.parallel.manager import AsynchronousActionManager diff --git a/pyomo/opt/parallel/local.py b/pyomo/opt/parallel/local.py index 211adf92e5c..e130ea0407f 100644 --- a/pyomo/opt/parallel/local.py +++ b/pyomo/opt/parallel/local.py @@ -9,9 +9,6 @@ # This software is distributed under the 3-clause BSD License. # ___________________________________________________________________________ - -__all__ = () - import time from pyomo.common.collections import OrderedDict diff --git a/pyomo/opt/parallel/manager.py b/pyomo/opt/parallel/manager.py index faa34d5190f..203c348e119 100644 --- a/pyomo/opt/parallel/manager.py +++ b/pyomo/opt/parallel/manager.py @@ -9,16 +9,6 @@ # This software is distributed under the 3-clause BSD License. # ___________________________________________________________________________ - -__all__ = [ - 'ActionManagerError', - 'ActionHandle', - 'AsynchronousActionManager', - 'ActionStatus', - 'FailedActionHandle', - 'solve_all_instances', -] - import enum diff --git a/pyomo/opt/problem/ampl.py b/pyomo/opt/problem/ampl.py index d128ec94930..ed107cace60 100644 --- a/pyomo/opt/problem/ampl.py +++ b/pyomo/opt/problem/ampl.py @@ -14,8 +14,6 @@ can be optimized with the Acro COLIN optimizers. """ -__all__ = ['AmplModel'] - import os from pyomo.opt.base import ProblemFormat, convert_problem, guess_format diff --git a/pyomo/opt/results/container.py b/pyomo/opt/results/container.py index 1cdf6fe77ce..ec4cb3c1c53 100644 --- a/pyomo/opt/results/container.py +++ b/pyomo/opt/results/container.py @@ -9,25 +9,12 @@ # This software is distributed under the 3-clause BSD License. # ___________________________________________________________________________ -__all__ = [ - 'UndefinedData', - 'undefined', - 'ignore', - 'ScalarData', - 'ListContainer', - 'MapContainer', - 'default_print_options', - 'ScalarType', -] - import copy - -from math import inf -from pyomo.common.collections import Bunch - import enum from io import StringIO +from math import inf +from pyomo.common.collections import Bunch class ScalarType(str, enum.Enum): int = 'int' diff --git a/pyomo/opt/results/problem.py b/pyomo/opt/results/problem.py index d39ba204aaf..98f749f3aeb 100644 --- a/pyomo/opt/results/problem.py +++ b/pyomo/opt/results/problem.py @@ -9,8 +9,6 @@ # This software is distributed under the 3-clause BSD License. # ___________________________________________________________________________ -__all__ = ['ProblemInformation', 'ProblemSense'] - import enum from pyomo.opt.results.container import MapContainer diff --git a/pyomo/opt/results/results_.py b/pyomo/opt/results/results_.py index a9b802e2adb..0a045550517 100644 --- a/pyomo/opt/results/results_.py +++ b/pyomo/opt/results/results_.py @@ -9,8 +9,6 @@ # This software is distributed under the 3-clause BSD License. # ___________________________________________________________________________ -__all__ = ['SolverResults'] - import math import sys import copy @@ -18,7 +16,7 @@ import logging import os.path -from pyomo.common.dependencies import yaml, yaml_load_args, yaml_available +from pyomo.common.dependencies import yaml, yaml_load_args import pyomo.opt from pyomo.opt.results.container import undefined, ignore, ListContainer, MapContainer import pyomo.opt.results.solution diff --git a/pyomo/opt/results/solution.py b/pyomo/opt/results/solution.py index 2862087cf43..6dcd348ea72 100644 --- a/pyomo/opt/results/solution.py +++ b/pyomo/opt/results/solution.py @@ -9,8 +9,6 @@ # This software is distributed under the 3-clause BSD License. # ___________________________________________________________________________ -__all__ = ['SolutionStatus', 'Solution'] - import math import enum from pyomo.opt.results.container import MapContainer, ListContainer, ignore diff --git a/pyomo/opt/results/solver.py b/pyomo/opt/results/solver.py index e2d0cfff605..d4cf46c38a9 100644 --- a/pyomo/opt/results/solver.py +++ b/pyomo/opt/results/solver.py @@ -9,14 +9,6 @@ # This software is distributed under the 3-clause BSD License. # ___________________________________________________________________________ -__all__ = [ - 'SolverInformation', - 'SolverStatus', - 'TerminationCondition', - 'check_optimal_termination', - 'assert_optimal_termination', -] - import enum from pyomo.opt.results.container import MapContainer, ScalarType diff --git a/pyomo/opt/solver/ilmcmd.py b/pyomo/opt/solver/ilmcmd.py index efd1096c20f..c956b2ed42f 100644 --- a/pyomo/opt/solver/ilmcmd.py +++ b/pyomo/opt/solver/ilmcmd.py @@ -9,8 +9,6 @@ # This software is distributed under the 3-clause BSD License. # ___________________________________________________________________________ -__all__ = ['ILMLicensedSystemCallSolver'] - import re import sys import os diff --git a/pyomo/opt/solver/shellcmd.py b/pyomo/opt/solver/shellcmd.py index 58274b572d3..94117779237 100644 --- a/pyomo/opt/solver/shellcmd.py +++ b/pyomo/opt/solver/shellcmd.py @@ -9,8 +9,6 @@ # This software is distributed under the 3-clause BSD License. # ___________________________________________________________________________ -__all__ = ['SystemCallSolver'] - import os import sys import time diff --git a/pyomo/opt/testing/pyunit.py b/pyomo/opt/testing/pyunit.py index 9143714f4e3..bb96806d520 100644 --- a/pyomo/opt/testing/pyunit.py +++ b/pyomo/opt/testing/pyunit.py @@ -9,9 +9,6 @@ # This software is distributed under the 3-clause BSD License. # ___________________________________________________________________________ - -__all__ = ['TestCase'] - import sys import os import re diff --git a/pyomo/repn/beta/matrix.py b/pyomo/repn/beta/matrix.py index 741e54d380c..916b0daf755 100644 --- a/pyomo/repn/beta/matrix.py +++ b/pyomo/repn/beta/matrix.py @@ -9,12 +9,6 @@ # This software is distributed under the 3-clause BSD License. # ___________________________________________________________________________ -__all__ = ( - "_LinearConstraintData", - "MatrixConstraint", - "compile_block_linear_constraints", -) - import time import logging import array diff --git a/pyomo/repn/plugins/ampl/ampl_.py b/pyomo/repn/plugins/ampl/ampl_.py index 4cc55cabd51..f422a085a3c 100644 --- a/pyomo/repn/plugins/ampl/ampl_.py +++ b/pyomo/repn/plugins/ampl/ampl_.py @@ -13,8 +13,6 @@ # AMPL Problem Writer Plugin # -__all__ = ['ProblemWriter_nl'] - import itertools import logging import operator diff --git a/pyomo/repn/standard_aux.py b/pyomo/repn/standard_aux.py index 628914780a6..403320c462c 100644 --- a/pyomo/repn/standard_aux.py +++ b/pyomo/repn/standard_aux.py @@ -10,9 +10,6 @@ # ___________________________________________________________________________ -__all__ = ['compute_standard_repn'] - - from pyomo.repn.standard_repn import ( preprocess_block_constraints, preprocess_block_objectives, diff --git a/pyomo/repn/standard_repn.py b/pyomo/repn/standard_repn.py index c1cca42afe4..8700872f04f 100644 --- a/pyomo/repn/standard_repn.py +++ b/pyomo/repn/standard_repn.py @@ -10,9 +10,6 @@ # ___________________________________________________________________________ -__all__ = ['StandardRepn', 'generate_standard_repn'] - - import sys import logging import itertools diff --git a/pyomo/scripting/convert.py b/pyomo/scripting/convert.py index 997e69ac7c9..20f9ef6d382 100644 --- a/pyomo/scripting/convert.py +++ b/pyomo/scripting/convert.py @@ -9,8 +9,6 @@ # This software is distributed under the 3-clause BSD License. # ___________________________________________________________________________ -__all__ = ['pyomo2lp', 'pyomo2nl', 'pyomo2dakota'] - import os import sys diff --git a/pyomo/scripting/pyomo_parser.py b/pyomo/scripting/pyomo_parser.py index 09998085576..9294d46f85e 100644 --- a/pyomo/scripting/pyomo_parser.py +++ b/pyomo/scripting/pyomo_parser.py @@ -9,8 +9,6 @@ # This software is distributed under the 3-clause BSD License. # ___________________________________________________________________________ -__all__ = ['add_subparser', 'get_parser', 'subparsers'] - import argparse import sys diff --git a/pyomo/solvers/plugins/solvers/CBCplugin.py b/pyomo/solvers/plugins/solvers/CBCplugin.py index 108b142a9e0..eb6c2c2e1bd 100644 --- a/pyomo/solvers/plugins/solvers/CBCplugin.py +++ b/pyomo/solvers/plugins/solvers/CBCplugin.py @@ -9,8 +9,6 @@ # This software is distributed under the 3-clause BSD License. # ___________________________________________________________________________ -__all__ = ['CBC', 'MockCBC'] - import os import re import time diff --git a/pyomo/solvers/tests/solvers.py b/pyomo/solvers/tests/solvers.py index e67df47a0b0..918a801ae37 100644 --- a/pyomo/solvers/tests/solvers.py +++ b/pyomo/solvers/tests/solvers.py @@ -9,8 +9,6 @@ # This software is distributed under the 3-clause BSD License. # ___________________________________________________________________________ -__all__ = ['test_solver_cases'] - import logging from pyomo.common.collections import Bunch diff --git a/pyomo/util/blockutil.py b/pyomo/util/blockutil.py index 56cc4266017..9f043e64ab7 100644 --- a/pyomo/util/blockutil.py +++ b/pyomo/util/blockutil.py @@ -12,8 +12,6 @@ # the purpose of this file is to collect all utility methods that compute # attributes of blocks, based on their contents. -__all__ = ['has_discrete_variables'] - import logging from pyomo.core import Var, Constraint, TraversalStrategy From db5fdf02d7e876ae3bd690ab85c032ebf9b46d26 Mon Sep 17 00:00:00 2001 From: Miranda Mundt Date: Fri, 16 Feb 2024 14:53:59 -0700 Subject: [PATCH 2/2] Fix import; apply black --- pyomo/core/expr/numvalue.py | 1 + pyomo/core/util.py | 5 +---- pyomo/opt/results/container.py | 1 + 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/pyomo/core/expr/numvalue.py b/pyomo/core/expr/numvalue.py index f3ea76c305c..3a4359af2f9 100644 --- a/pyomo/core/expr/numvalue.py +++ b/pyomo/core/expr/numvalue.py @@ -32,6 +32,7 @@ check_if_numeric_type, value, ) +from pyomo.core.pyomoobject import PyomoObject relocated_module_attribute( 'native_boolean_types', diff --git a/pyomo/core/util.py b/pyomo/core/util.py index e4a70aea05a..f337b487cef 100644 --- a/pyomo/core/util.py +++ b/pyomo/core/util.py @@ -15,10 +15,7 @@ from pyomo.common.deprecation import deprecation_warning from pyomo.core.expr.numvalue import native_numeric_types -from pyomo.core.expr.numeric_expr import ( - mutable_expression, - NPV_SumExpression, -) +from pyomo.core.expr.numeric_expr import mutable_expression, NPV_SumExpression from pyomo.core.base.var import Var from pyomo.core.base.expression import Expression from pyomo.core.base.component import _ComponentBase diff --git a/pyomo/opt/results/container.py b/pyomo/opt/results/container.py index ec4cb3c1c53..4bbaf44edf7 100644 --- a/pyomo/opt/results/container.py +++ b/pyomo/opt/results/container.py @@ -16,6 +16,7 @@ from pyomo.common.collections import Bunch + class ScalarType(str, enum.Enum): int = 'int' time = 'time'