def unary_operator(op):
 valid_ops = {'-'}
 if (op not in valid_ops):
  raise ValueError(('Invalid unary operator %s.' % op))
 @with_doc(("Unary Operator: '%s'" % op))
 @with_name(unary_op_name(op))
 def unary_operator(self):
  if (self.dtype != float64_dtype):
   raise TypeError("Can't apply unary operator {op!r} to instance of {typename!r} with dtype {dtypename!r}.\n{op!r} is only supported for Factors of dtype 'float64'.".format(op=op, typename=type(self).__name__, dtypename=self.dtype.name))
  if isinstance(self, NumericalExpression):
   return NumExprFactor('{op}({expr})'.format(op=op, expr=self._expr), self.inputs, dtype=float64_dtype)
  else:
   return NumExprFactor('{op}x_0'.format(op=op), (self,), dtype=float64_dtype)
 return unary_operator

def unary_operator ( op ) : valid_ops = { '-' } if ( op not in valid_ops ) : raise ValueError ( ( 'Invalid unary operator %s.' % op ) ) @ with_doc ( ( "Unary Operator: '%s'" % op ) ) @ with_name ( unary_op_name ( op ) ) def unary_operator ( self ) : if ( self . dtype != float64_dtype ) : raise TypeError ( "Can't apply unary operator {op!r} to instance of {typename!r} with dtype {dtypename!r}.\n{op!r} is only supported for Factors of dtype 'float64'." . format ( op = op , typename = type ( self ) . __name__ , dtypename = self . dtype . name ) ) if isinstance ( self , NumericalExpression ) : return NumExprFactor ( '{op}({expr})' . format ( op = op , expr = self . _expr ) , self . inputs , dtype = float64_dtype ) else : return NumExprFactor ( '{op}x_0' . format ( op = op ) , ( self , ) , dtype = float64_dtype ) return unary_operator
factory function for making unary operator methods for factors .