提交 2c2c9ce6 authored 作者: James Bergstra's avatar James Bergstra

whitespace and deleting rotten function in tensor.basic

上级 28d0fee7
...@@ -1081,6 +1081,7 @@ def tensor4(name=None, dtype=None): ...@@ -1081,6 +1081,7 @@ def tensor4(name=None, dtype=None):
tensor4s, ftensor4s, dtensor4s, itensor4s, ltensor4s = _multi(tensor4, ftensor4, dtensor4, tensor4s, ftensor4s, dtensor4s, itensor4s, ltensor4s = _multi(tensor4, ftensor4, dtensor4,
itensor4, ltensor4) itensor4, ltensor4)
class _tensor_py_operators: class _tensor_py_operators:
#UNARY #UNARY
def __abs__(self): return abs_(self) def __abs__(self): return abs_(self)
...@@ -1370,10 +1371,14 @@ class _tensor_py_operators: ...@@ -1370,10 +1371,14 @@ class _tensor_py_operators:
def get_constant_value(self): def get_constant_value(self):
return get_constant_value(self) return get_constant_value(self)
class TensorVariable(_tensor_py_operators, Variable): class TensorVariable(_tensor_py_operators, Variable):
"""Subclass to add the tensor operators to the basic `Variable` class.""" """Subclass to add the tensor operators to the basic `Variable` class."""
TensorType.Variable = TensorVariable TensorType.Variable = TensorVariable
class TensorConstantSignature(tuple): class TensorConstantSignature(tuple):
"""A Signature object for comparing TensorConstant instances """A Signature object for comparing TensorConstant instances
...@@ -1497,7 +1502,8 @@ class TensorValue(_tensor_py_operators, Value): ...@@ -1497,7 +1502,8 @@ class TensorValue(_tensor_py_operators, Value):
Tensor = TensorType Tensor = TensorType
#QUESTION: why are we doing this!?
# This bizarre push-import avoids a circular dependency.
elemwise.as_tensor_variable = as_tensor_variable elemwise.as_tensor_variable = as_tensor_variable
elemwise.TensorType = TensorType elemwise.TensorType = TensorType
elemwise.TensorVariable = TensorVariable elemwise.TensorVariable = TensorVariable
...@@ -1505,29 +1511,10 @@ elemwise.TensorConstant = TensorConstant ...@@ -1505,29 +1511,10 @@ elemwise.TensorConstant = TensorConstant
elemwise.TensorValue = TensorValue elemwise.TensorValue = TensorValue
######################### #########################
# Utilities # Utilities
######################### #########################
def _elemwise(scalar_op, name, doc_prefix=''):
straight = elemwise.Elemwise(scalar_op, name = name)
inplace_scalar_op = scalar_op.__class__(scal.transfer_type(0))
inplace = elemwise.Elemwise(inplace_scalar_op, {0: 0}, name = name+"_inplace")
# don't add the inplace versions, they aren't supposed to be part of the user interface
_constructor_list.append(straight)
# This is here so that gen_oplist can detect which module declared these variables.
straight.__module__ = 'tensor'
inplace.__module__ = 'tensor'
if doc_prefix:
straight.__doc__ = doc_prefix + '\n' + straight.__doc__
return straight, inplace
def _redefine(real_symbol_value, module='tensor'): def _redefine(real_symbol_value, module='tensor'):
"""Replace the value associated with a function symbol. """Replace the value associated with a function symbol.
...@@ -1538,12 +1525,14 @@ def _redefine(real_symbol_value, module='tensor'): ...@@ -1538,12 +1525,14 @@ def _redefine(real_symbol_value, module='tensor'):
return real_symbol_value return real_symbol_value
return decorator return decorator
def _redefine_asRoutine(real_symbol_value): def _redefine_asRoutine(real_symbol_value):
real_symbol_value.__epydoc_asRoutine = True real_symbol_value.__epydoc_asRoutine = True
def decorator(f): def decorator(f):
return real_symbol_value return real_symbol_value
return decorator return decorator
def _scal_elemwise_with_nfunc(nfunc, nin, nout): def _scal_elemwise_with_nfunc(nfunc, nin, nout):
""" """
Replace a symbol definition with an elementwise version of the Replace a symbol definition with an elementwise version of the
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论