From eb6b8986f7d9635aaa2bbdc79e0f4326e878090d Mon Sep 17 00:00:00 2001 From: John Siirola Date: Tue, 13 Aug 2024 12:28:43 -0600 Subject: [PATCH] Remove the `_suppress_ctypes` attribute from Block --- pyomo/contrib/cp/interval_var.py | 2 -- pyomo/contrib/piecewise/piecewise_linear_function.py | 2 -- pyomo/core/base/block.py | 12 ------------ pyomo/gdp/disjunct.py | 6 ------ 4 files changed, 22 deletions(-) diff --git a/pyomo/contrib/cp/interval_var.py b/pyomo/contrib/cp/interval_var.py index dec5af74d9f..013fa145b15 100644 --- a/pyomo/contrib/cp/interval_var.py +++ b/pyomo/contrib/cp/interval_var.py @@ -206,8 +206,6 @@ def _getitem_when_not_present(self, index): class ScalarIntervalVar(IntervalVarData, IntervalVar): def __init__(self, *args, **kwds): - self._suppress_ctypes = set() - IntervalVarData.__init__(self, self) IntervalVar.__init__(self, *args, **kwds) self._data[None] = self diff --git a/pyomo/contrib/piecewise/piecewise_linear_function.py b/pyomo/contrib/piecewise/piecewise_linear_function.py index e92edacc756..742eb52d5bb 100644 --- a/pyomo/contrib/piecewise/piecewise_linear_function.py +++ b/pyomo/contrib/piecewise/piecewise_linear_function.py @@ -506,8 +506,6 @@ class ScalarPiecewiseLinearFunction( PiecewiseLinearFunctionData, PiecewiseLinearFunction ): def __init__(self, *args, **kwds): - self._suppress_ctypes = set() - PiecewiseLinearFunctionData.__init__(self, self) PiecewiseLinearFunction.__init__(self, *args, **kwds) self._data[None] = self diff --git a/pyomo/core/base/block.py b/pyomo/core/base/block.py index 653809e0419..526c4c8bb41 100644 --- a/pyomo/core/base/block.py +++ b/pyomo/core/base/block.py @@ -960,13 +960,8 @@ def add_component(self, name, val): % (name, type(val), self.name, type(getattr(self, name))) ) # - # Skip the add_component() logic if this is a - # component type that is suppressed. - # _component = self.parent_component() _type = val.ctype - if _type in _component._suppress_ctypes: - return # # Raise an exception if the component already has a parent. # @@ -1048,12 +1043,6 @@ def add_component(self, name, val): else: self._ctypes[_type] = [_new_idx, _new_idx, 1] # - # Propagate properties to sub-blocks: - # suppressed ctypes - # - if _type is Block: - val._suppress_ctypes |= _component._suppress_ctypes - # # Error, for disabled support implicit rule names # if '_rule' in val.__dict__ and val._rule is None: @@ -2029,7 +2018,6 @@ def __init__( def __init__(self, *args, **kwargs): """Constructor""" - self._suppress_ctypes = set() _rule = kwargs.pop('rule', None) _options = kwargs.pop('options', None) # As concrete applies to the Block at declaration time, we will diff --git a/pyomo/gdp/disjunct.py b/pyomo/gdp/disjunct.py index 637f55cbed1..bfaada8f3de 100644 --- a/pyomo/gdp/disjunct.py +++ b/pyomo/gdp/disjunct.py @@ -502,12 +502,6 @@ def _activate_without_unfixing_indicator(self): class ScalarDisjunct(DisjunctData, Disjunct): def __init__(self, *args, **kwds): - ## FIXME: This is a HACK to get around a chicken-and-egg issue - ## where BlockData creates the indicator_var *before* - ## Block.__init__ declares the _defer_construction flag. - self._defer_construction = True - self._suppress_ctypes = set() - DisjunctData.__init__(self, self) Disjunct.__init__(self, *args, **kwds) self._data[None] = self