def __init__(self, domain, shape=(), count=None): Terminal.__init__(self) counted_init(self, count=count, countedclass=Constant) self._ufl_domain = as_domain(domain) self._ufl_shape = shape # Repr string is build in such way, that reconstruction # with eval() is possible self._repr = "Constant({}, {}, {})".format(repr(self._ufl_domain), repr(self._ufl_shape), repr(self._count))
def __new__(cls, indices): if not isinstance(indices, tuple): error("Expecting a tuple of indices.") if all(isinstance(ind, FixedIndex) for ind in indices): # Cache multiindices consisting of purely fixed indices # (aka flyweight pattern) key = tuple(ind._value for ind in indices) self = MultiIndex._cache.get(key) if self is not None: return self self = Terminal.__new__(cls) MultiIndex._cache[key] = self else: # Create a new object if we have any free indices (too # many combinations to cache) if not all(isinstance(ind, IndexBase) for ind in indices): error("Expecting only Index and FixedIndex objects.") self = Terminal.__new__(cls) # Initialize here instead of in __init__ to avoid overwriting # self._indices from cached objects self._init(indices) return self
def __init__(self, domain): Terminal.__init__(self) self._domain = as_domain(domain)
def __init__(self, count=None): Terminal.__init__(self) counted_init(self, count, Label)
def _init(self, indices): Terminal.__init__(self) self._indices = indices
def __init__(self): Terminal.__init__(self)