def __new__(cls, *args, **kwargs):
if cls in _SymbolCache:
options = kwargs.get('options', {})
newobj = sympy.Function.__new__(cls, *args, **options)
newobj._cached_init()
else:
name = kwargs.get('name')
if len(args) < 1:
args = cls._indices(**kwargs)
# Create the new Function object and invoke __init__
newcls = cls._symbol_type(name)
options = kwargs.get('options', {})
newobj = sympy.Function.__new__(newcls, *args, **options)
newobj.__init__(*args, **kwargs)
# All objects cached on the AbstractFunction /newobj/ keep a reference
# to /newobj/ through the /function/ field. Thus, all indexified
# object will point to /newobj/, the "actual Function".
newobj.function = newobj
# Store new instance in symbol cache
newcls._cache_put(newobj)
return newobj
评论列表
文章目录