This file is indexed.

/usr/include/openturns/swig/NumericalMathFunction.i is in libopenturns-dev 0.15-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
// SWIG file NumericalMathFunction.i
// Author : $LastChangedBy: schueller $
// Date : $LastChangedDate: 2011-08-01 13:42:13 +0200 (Mon, 01 Aug 2011) $
// Id : $Id: NumericalMathFunction.i 2060 2011-08-01 11:42:13Z schueller $

%{
#include "NumericalMathFunction.hxx"
#include "PythonNumericalMathEvaluationImplementation.hxx"

namespace OpenTURNS { 

  template <>
  struct traitsPythonType<OpenTURNS::Base::Func::NumericalMathFunction>
  {
    typedef _PyObject_ Type;
  };

  template <>
  inline
  OpenTURNS::Base::Func::NumericalMathFunction
  convert<_PyObject_,OpenTURNS::Base::Func::NumericalMathFunction>(PyObject * pyObj)
  {
   if (!PyCallable_Check( pyObj )) {
     throw OT::Base::Common::InvalidArgumentException(HERE) << "Argument is not a callable object (function or class)";
   }

   return OpenTURNS::Base::Func::NumericalMathFunction(new OpenTURNS::Base::Func::NumericalMathFunctionImplementation(new OpenTURNS::Base::Func::PythonNumericalMathEvaluationImplementation(pyObj) ) );

  }

} /* namespace OpenTURNS */

%}

%pythoncode %{

class OpenTURNSPythonFunction :

  def __init__(self, n=0, p=0) :
    # Warning: these names are used in PythonNumericalMathEvaluationImplementation class. Synchronize the files if changed
    self.descIn  = []
    self.descOut = []
    self.n = n
    self.p = p
    pass

  def setInputDescription(self, descIn):
    if (len(descIn) != self.n):
      raise ValueError, "Input description size does NOT match input dimension"
    self.descIn  = descIn
    pass

  def setOutputDescription(self, descOut):
    if (len(descOut) != self.p):
      raise ValueError, "Output description size does NOT match output dimension"
    self.descOut  = descOut
    pass

  def getInputDimension(self) :
    return self.n

  def getOutputDimension(self) :
    return self.p

  def __str__(self):
    return "OpenTURNSPythonFunction( %s #%d ) -> %s #%d" % (self.descIn, self.n, self.descOut, self.p)

  def __repr__(self):
    return self.__str__()

  def __call__(self, X) :
    #print "X =", X, "type(X) =", type(X)
    import types
    #import openturns.typ, openturns.statistics
    Y = None
    if ( isinstance( X, typ.NumericalPoint ) ):
      #print "IDM : typ.NumericalPoint"
      Y = self._exec( X )
    elif ( isinstance( X, statistics.NumericalSample ) ):
      #print "IDM : typ.NumericalSample"
      Y = self._exec_sample( X )
    else :
      try:
        #print "IDM : try tuple -> NumericalPoint"
        pt = typ.NumericalPoint( X )
        #print "IDM : tuple -> NumericalPoint"
      except TypeError:
        try:
          #print "IDM : try tuple -> NumericalSample"
          ns = statistics.NumericalSample( X )
          #print "IDM : tuple -> NumericalSample"
        except TypeError:
          #print "IDM : type(X) =", type(X)
          #print "IDM : X =", X
          raise TypeError, "Expect a NumericalPoint or a NumericalSample as argument"
        else :
          Y = self._exec_sample( ns )
      else :
        Y = self._exec( pt )
    return Y

  def _exec(self, X) :
    if ( not hasattr( self, "f" ) ):
      raise RuntimeError, "You must define a method f(X) -> Y, where X and Y are NumericalPoint objects"
    import warnings
    warnings.warn("usage of method named 'f' is now deprecated. Rename it to '_exec' instead", DeprecationWarning )
    return self.f( X )

  def f(self, X) :
    raise RuntimeError, "You must define a method f(X) -> Y, where X and Y are NumericalPoint objects"

  def _exec_sample(self, X) :
    #print "IDM: _exec_sample"
    res = list()
    for point in X:
        res.append( self._exec( point ) )
    return res

%}

%template(NumericalMathFunctionImplementationTypedInterfaceObject)           OpenTURNS::Base::Common::TypedInterfaceObject<OpenTURNS::Base::Func::NumericalMathFunctionImplementation>;

// Deprecated
%ignore OpenTURNS::Base::Func::NumericalMathFunction::getInputNumericalPointDimension() const;
%ignore OpenTURNS::Base::Func::NumericalMathFunction::getOutputNumericalPointDimension() const;

%include NumericalMathFunction.hxx
//%copyctor NumericalMathFunction;

namespace OpenTURNS { namespace Base { namespace Func {

%extend NumericalMathFunction {

NumericalMathFunction(PyObject * pyObj)
{
 return new OpenTURNS::Base::Func::NumericalMathFunction( OpenTURNS::convert<OpenTURNS::_PyObject_,OpenTURNS::Base::Func::NumericalMathFunction>(pyObj) );
}

NumericalMathFunction(const NumericalMathFunction & other)
{
 return new OpenTURNS::Base::Func::NumericalMathFunction( other );
}

}

}}}