コード例 #1
0
#  Under the terms of Contract DE-NA0003525 with National Technology and
#  Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
#  rights in this software.
#  This software is distributed under the 3-clause BSD License.
#  ___________________________________________________________________________

#
# Utility functions
#
import inspect

from pyomo.common.deprecation import relocated_module_attribute
from pyomo.core.base.indexed_component import normalize_index

relocated_module_attribute('disable_methods',
                           'pyomo.core.base.disable_methods.disable_methods',
                           version='6.1')
relocated_module_attribute('Initializer',
                           'pyomo.core.base.initializer.Initializer',
                           version='6.1')
relocated_module_attribute('IndexedCallInitializer',
                           'pyomo.core.base.initializer.Initializer',
                           version='6.1')
relocated_module_attribute('CountedCallInitializer',
                           'pyomo.core.base.initializer.Initializer',
                           version='6.1')


def is_functor(obj):
    """
    Returns true iff obj.__call__ is defined.
コード例 #2
0
                foo().bar()
        # Test that the function produces output
        self.assertIn('yeah', FCN_OUT.getvalue())
        self.assertNotIn('DEPRECATED', FCN_OUT.getvalue())
        # Test that the deprecation warning was logged
        self.assertIn('DEPRECATED: This function has been deprecated',
                      DEP_OUT.getvalue())
        self.assertIn('(deprecated in 1.2, will be removed in 3.4)',
                      DEP_OUT.getvalue())


class Bar(object):
    data = 21


relocated_module_attribute('myFoo', 'pyomo.common.tests.relocated.Bar', 'test')


class TestRelocated(unittest.TestCase):
    def test_relocated_class(self):
        # Before we test multiple relocated objects, verify that it will
        # handle the import of a new module
        warning = "DEPRECATED: the 'myFoo' class has been moved to " \
                  "'pyomo.common.tests.relocated.Bar'"
        OUT = StringIO()
        with LoggingIntercept(OUT, 'pyomo'):
            from pyomo.common.tests.test_deprecated import myFoo
        self.assertEqual(myFoo.data, 42)
        self.assertIn(warning, OUT.getvalue().replace('\n', ' '))

        from pyomo.common.tests import relocated
コード例 #3
0
from pyomo.core.base.block import (SortComponents, TraversalStrategy,
                                   Block, ScalarBlock, active_components,
                                   components, active_components_data,
                                   components_data)
from pyomo.core.base.PyomoModel import (global_option,
                                        ModelSolution,
                                        ModelSolutions, Model, ConcreteModel,
                                        AbstractModel)
from pyomo.core.base.transformation import (
    Transformation,
    TransformationFactory,
)

from pyomo.core.base.instance2dat import instance2dat

# These APIs are deprecated and should be removed in the near future
from pyomo.core.base.set import (
    set_options, RealSet, IntegerSet, BooleanSet,
)

from pyomo.common.deprecation import relocated_module_attribute
relocated_module_attribute(
    'SimpleBlock', 'pyomo.core.base.block.SimpleBlock', version='6.0')
relocated_module_attribute(
    'SimpleVar', 'pyomo.core.base.var.SimpleVar', version='6.0')
relocated_module_attribute(
    'SimpleBooleanVar', 'pyomo.core.base.boolean_var.SimpleBooleanVar',
    version='6.0'
)
del relocated_module_attribute
コード例 #4
0
#  ___________________________________________________________________________
#
#  Pyomo: Python Optimization Modeling Objects
#  Copyright (c) 2008-2022
#  National Technology and Engineering Solutions of Sandia, LLC
#  Under the terms of Contract DE-NA0003525 with National Technology and
#  Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
#  rights in this software.
#  This software is distributed under the 3-clause BSD License.
#  ___________________________________________________________________________
#

from pyomo.common.deprecation import relocated_module_attribute


class Bar(object):
    data = 42


def __getattr__(name):
    if name.startswith('Foo'):
        return name[3:]
    raise AttributeError("module '%s' has no attribute '%s'" %
                         (__name__, name))


relocated_module_attribute('Foo', 'pyomo.common.tests.test_deprecated.Bar',
                           'test')
relocated_module_attribute('Foo_2', 'pyomo.common.tests.relocated.Bar', 'test')
コード例 #5
0
ファイル: reboiler.py プロジェクト: jmorgan29/idaes-pse
#################################################################################
# The Institute for the Design of Advanced Energy Systems Integrated Platform
# Framework (IDAES IP) was produced under the DOE Institute for the
# Design of Advanced Energy Systems (IDAES), and is copyright (c) 2018-2021
# by the software owners: The Regents of the University of California, through
# Lawrence Berkeley National Laboratory,  National Technology & Engineering
# Solutions of Sandia, LLC, Carnegie Mellon University, West Virginia University
# Research Corporation, et al.  All rights reserved.
#
# Please see the files COPYRIGHT.md and LICENSE.md for full copyright and
# license information.
#################################################################################
"""
Deprecation path for renamed Reboiler model.
"""
from pyomo.common.deprecation import relocated_module_attribute

relocated_module_attribute(
    'Reboiler',
    'idaes.generic_models.unit_models.column_models.reboiler.Reboiler',
    version='1.12')
コード例 #6
0
ファイル: component.py プロジェクト: ZedongPeng/pyomo
from pickle import PickleError
from weakref import ref as weakref_ref

import pyomo.common
from pyomo.common.deprecation import deprecated, relocated_module_attribute
from pyomo.common.factory import Factory
from pyomo.common.formatting import tabular_writer, StreamIndenter
from pyomo.common.modeling import NOTSET
from pyomo.common.sorting import sorted_robust
from pyomo.core.pyomoobject import PyomoObject
from pyomo.core.base.component_namer import name_repr, index_repr

logger = logging.getLogger('pyomo.core')

relocated_module_attribute('ComponentUID',
                           'pyomo.core.base.componentuid.ComponentUID',
                           version='5.7.2')

_ref_types = {type(None), weakref_ref}


class ModelComponentFactoryClass(Factory):
    def register(self, doc=None):
        def fn(cls):
            return super(ModelComponentFactoryClass,
                         self).register(cls.__name__, doc)(cls)

        return fn


ModelComponentFactory = ModelComponentFactoryClass('model component')
コード例 #7
0
#  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')

relocated_module_attribute('tabular_writer',
                           'pyomo.common.formatting.tabular_writer',
                           version='6.1')
relocated_module_attribute('sorted_robust',
                           'pyomo.common.sorting.sorted_robust',
                           version='6.1')


def display(obj, ostream=None):
    """ Display data in a Pyomo object"""
    if ostream is None:
        ostream = sys.stdout
    try:
        display_fcn = obj.display
    except AttributeError:
        raise TypeError(
            "Error trying to display values for object of type %s:\n"
コード例 #8
0
ファイル: condenser.py プロジェクト: jmorgan29/idaes-pse
# The Institute for the Design of Advanced Energy Systems Integrated Platform
# Framework (IDAES IP) was produced under the DOE Institute for the
# Design of Advanced Energy Systems (IDAES), and is copyright (c) 2018-2021
# by the software owners: The Regents of the University of California, through
# Lawrence Berkeley National Laboratory,  National Technology & Engineering
# Solutions of Sandia, LLC, Carnegie Mellon University, West Virginia University
# Research Corporation, et al.  All rights reserved.
#
# Please see the files COPYRIGHT.md and LICENSE.md for full copyright and
# license information.
#################################################################################
"""
Deprecation path for renamed Condenser model.
"""
from pyomo.common.deprecation import relocated_module_attribute

relocated_module_attribute(
    'Condenser',
    'idaes.generic_models.unit_models.column_models.condenser.Condenser',
    version='1.12')

relocated_module_attribute(
    'CondenserType',
    'idaes.generic_models.unit_models.column_models.condenser.CondenserType',
    version='1.12')

relocated_module_attribute(
    'TemperatureSpec',
    'idaes.generic_models.unit_models.column_models.condenser.TemperatureSpec',
    version='1.12')
コード例 #9
0
#################################################################################
# The Institute for the Design of Advanced Energy Systems Integrated Platform
# Framework (IDAES IP) was produced under the DOE Institute for the
# Design of Advanced Energy Systems (IDAES), and is copyright (c) 2018-2021
# by the software owners: The Regents of the University of California, through
# Lawrence Berkeley National Laboratory,  National Technology & Engineering
# Solutions of Sandia, LLC, Carnegie Mellon University, West Virginia University
# Research Corporation, et al.  All rights reserved.
#
# Please see the files COPYRIGHT.md and LICENSE.md for full copyright and
# license information.
#################################################################################
"""
Deprecation path for renamed TrayColumn model.
"""
from pyomo.common.deprecation import relocated_module_attribute

relocated_module_attribute(
    'TrayColumn',
    'idaes.generic_models.unit_models.column_models.tray_column.TrayColumn',
    version='1.12')