• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ PythonException函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中PythonException函数的典型用法代码示例。如果您正苦于以下问题:C++ PythonException函数的具体用法?C++ PythonException怎么用?C++ PythonException使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了PythonException函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: getDerivativeSupportItemObjectAttr

EpetraExt::ModelEvaluator::DerivativeSupport
getDerivativeSupportItemObjectAttr(PyObject * object, CONST char * name, int i)
{
    // The DerivativeSupport python class object
    static
    PyObject * classDerivativeSupport = NULL;
    if (!classDerivativeSupport)
    {
        classDerivativeSupport = getClassFromModule(PyTrilinosEpetraExt, "DerivativeSupport");
        if (!classDerivativeSupport) throw PythonException();
    }
    // Get the item from the object attribute
    PyObject * tuple = getTupleObjectAttr(object, name);
    PyObject * item  = PyTuple_GetItem(tuple, i);
    Py_DECREF(tuple);
    if (!item) throw PythonException();
    if (!PyObject_IsInstance(item, classDerivativeSupport))
    {
        PyErr_Format(PyExc_TypeError, "Attribute '%s' is not tuple of DerivativeSupport", name);
        Py_DECREF(item);
        throw PythonException();
    }
    EpetraExt::ModelEvaluator::EDerivativeLinearOp linearOp;
    EpetraExt::ModelEvaluator::EDerivativeMultiVectorOrientation orientation;
    EpetraExt::ModelEvaluator::DerivativeSupport result;
    if (getBoolObjectAttr(item, "linearOp"))
        result.plus(EpetraExt::ModelEvaluator::DERIV_LINEAR_OP);
    if (getBoolObjectAttr(item, "mVByCol"))
        result.plus(EpetraExt::ModelEvaluator::DERIV_MV_BY_COL);
    if (getBoolObjectAttr(item, "transMVByRow"))
        result.plus(EpetraExt::ModelEvaluator::DERIV_TRANS_MV_BY_ROW);
    Py_DECREF(item);
    return result;
}
开发者ID:uppatispr,项目名称:trilinos-official,代码行数:34,代码来源:PyTrilinos_EpetraExt_Util.cpp


示例2: matches

    inline bool matches( PyObject *exception ) const
    {
#if PYTHON_VERSION >= 300
        if ( PyTuple_Check( exception ))
        {
            Py_ssize_t length = PyTuple_Size( exception );

            for ( Py_ssize_t i = 0; i < length; i += 1 )
            {
                PyObject *element = PyTuple_GET_ITEM( exception, i );

                if (unlikely( !PyExceptionClass_Check( element ) ))
                {
                    PyErr_Format( PyExc_TypeError, "catching classes that do not inherit from BaseException is not allowed" );
                    throw PythonException();
                }
            }
        }
        else if (unlikely( !PyExceptionClass_Check( exception ) ))
        {
            PyErr_Format( PyExc_TypeError, "catching classes that do not inherit from BaseException is not allowed" );
            throw PythonException();
        }
#endif

        return
            PyErr_GivenExceptionMatches( this->exception_type, exception ) ||
            PyErr_GivenExceptionMatches( this->exception_value, exception );
    }
开发者ID:linkerlin,项目名称:Nuitka,代码行数:29,代码来源:exceptions.hpp


示例3: getEvaluationObjectAttr

EpetraExt::ModelEvaluator::Evaluation<Epetra_Vector>
getEvaluationObjectAttr(PyObject * object, CONST char * name)
{
    // The Evaluation python object
    static
    PyObject * classEvaluation = NULL;
    if (!classEvaluation)
    {
        classEvaluation = getClassFromModule(PyTrilinosEpetraExt, "Evaluation");
        if (!classEvaluation) throw PythonException();
    }
    PyObject * value = PyObject_GetAttrString(object, name);
    if (!value) throw PythonException();
    if (!PyObject_IsInstance(value, classEvaluation))
    {
        PyErr_Format(PyExc_TypeError, "Attribute '%s' is not of type Evaluation", name);
        Py_DECREF(value);
        throw PythonException();
    }
    // vector attribute
    Teuchos::RCP<Epetra_Vector> vector = getEpetraVectorObjectAttr(value, "vector");
    // type attribute
    EpetraExt::ModelEvaluator::EEvalType type;
    CONST char * typeStr = getStringObjectAttr(value, "type");
    if (strncmp(typeStr, "exact", 5) == 0)
        type = EpetraExt::ModelEvaluator::EVAL_TYPE_EXACT;
    if (strncmp(typeStr, "approx_deriv", 12) == 0)
        type = EpetraExt::ModelEvaluator::EVAL_TYPE_APPROX_DERIV;
    if (strncmp(typeStr, "very_approx_deriv", 17) == 0)
        type = EpetraExt::ModelEvaluator::EVAL_TYPE_VERY_APPROX_DERIV;
    Py_DECREF(value);
    return EpetraExt::ModelEvaluator::Evaluation<Epetra_Vector>(vector, type);
}
开发者ID:uppatispr,项目名称:trilinos-official,代码行数:33,代码来源:PyTrilinos_EpetraExt_Util.cpp


示例4: getDerivativeSupportObjectAttr

EpetraExt::ModelEvaluator::DerivativeSupport
getDerivativeSupportObjectAttr(PyObject * object, CONST char * name)
{
    static
    PyObject * classDerivativeSupport = NULL;
    if (!classDerivativeSupport)
    {
        classDerivativeSupport = getClassFromModule(PyTrilinosEpetraExt, "DerivativeSupport");
        if (!classDerivativeSupport) throw PythonException();
    }
    PyObject * value = PyObject_GetAttrString(object, name);
    if (!value) throw PythonException();
    if (!PyObject_IsInstance(value, classDerivativeSupport))
    {
        PyErr_Format(PyExc_TypeError, "Attribute '%s' is not of type DerivativeSupport", name);
        Py_DECREF(value);
        throw PythonException();
    }
    EpetraExt::ModelEvaluator::EDerivativeLinearOp linearOp;
    EpetraExt::ModelEvaluator::EDerivativeMultiVectorOrientation orientation;
    EpetraExt::ModelEvaluator::DerivativeSupport result;
    if (getBoolObjectAttr(value, "linearOp"))
        result.plus(EpetraExt::ModelEvaluator::DERIV_LINEAR_OP);
    if (getBoolObjectAttr(value, "mVByCol"))
        result.plus(EpetraExt::ModelEvaluator::DERIV_MV_BY_COL);
    if (getBoolObjectAttr(value, "transMVByRow"))
        result.plus(EpetraExt::ModelEvaluator::DERIV_TRANS_MV_BY_ROW);
    Py_DECREF(value);
    return result;
}
开发者ID:uppatispr,项目名称:trilinos-official,代码行数:30,代码来源:PyTrilinos_EpetraExt_Util.cpp


示例5: PyArray_SimpleNew

// =============================================================================
int * Epetra_NumPyMultiVector::getRange(PyObject * range,
					const Epetra_MultiVector & source)
{
  // Handle the default case (range == NULL), which is to return a
  // range of all the Epetra_MultiVector vectors
  if (range == NULL)
  {
    npy_intp dims[ ] = { (npy_intp) source.NumVectors() };
    tmp_range = (PyArrayObject *) PyArray_SimpleNew(1,dims,NPY_INT);
    if (!tmp_range)
    {
      cleanup();
      throw PythonException();
    }
    int * data = (int *) PyArray_DATA(tmp_range);
    for (int i=0; i<dims[0]; i++) data[i] = i;
  }

  // Try to create a contiguous array of integers from the PyObject
  if (!tmp_range)
    tmp_range = (PyArrayObject *)
      PyArray_ContiguousFromObject(range,NPY_INT,1,1);

  // If this fails, clean up and throw a PythonException
  if (!tmp_range)
  {
    cleanup();
    throw PythonException();
  }

  // Obtain the length and return the array of integers
  return (int *) (PyArray_DATA(tmp_range));
}
开发者ID:EllieGong,项目名称:trilinos,代码行数:34,代码来源:Epetra_NumPyMultiVector.cpp


示例6: getConstEpetraVectorItemObjectAttr

Teuchos::RCP< const Epetra_Vector >
getConstEpetraVectorItemObjectAttr(PyObject   * object,
                                   CONST char * name,
                                   int          i)
{
  static swig_type_info * swig_EV_ptr =
    SWIG_TypeQuery("Teuchos::RCP< Epetra_Vector > *");
  void * argp;
  PyObject * tuple = getTupleObjectAttr(object, name);
  PyObject * item  = PyTuple_GetItem(tuple, i);
  Py_DECREF(tuple);
  if (!item) throw PythonException();
  int newmem = 0;
  if (!SWIG_CheckState(SWIG_Python_ConvertPtrAndOwn(item, &argp, swig_EV_ptr, 0, &newmem)))
  {
    PyErr_Format(PyExc_TypeError,
                 "Attribute '%s' is not tuple of type Epetra.Vector",
                 name);
    Py_DECREF(item);
    throw PythonException();
  }
  Teuchos::RCP< const Epetra_Vector > result =
    *reinterpret_cast< Teuchos::RCP< const Epetra_Vector > * >(argp);
  if (newmem)
    delete reinterpret_cast< Teuchos::RCP< const Epetra_Vector > * >(argp);
  Py_DECREF(item);
  return result;
}
开发者ID:abhishek4747,项目名称:trilinos,代码行数:28,代码来源:PyTrilinos_Epetra_Util.cpp


示例7: assert

    PyObject *asObject0() const
    {
        assert( this->storage );

        if ( this->storage->object == NULL )
        {
            PyErr_Format(
                PyExc_UnboundLocalError,
                "free variable '%s' referenced before assignment in enclosing scope",
                Nuitka_String_AsString( this->storage->getVarName() )
            );

            throw PythonException();
        }

        if ( Py_REFCNT( this->storage->object ) == 0 )
        {
            PyErr_Format(
                PyExc_UnboundLocalError,
                "free variable '%s' referenced after its finalization in enclosing scope",
                Nuitka_String_AsString( this->storage->getVarName() )
            );

            throw PythonException();
        }

        return this->storage->object;
    }
开发者ID:TheKK,项目名称:Nuitka,代码行数:28,代码来源:variables_shared.hpp


示例8: PyArray_SimpleNew

// =============================================================================
int * Epetra_NumPyIntVector::getArray(const Epetra_BlockMap & blockMap,
				      PyObject * pyObject)
{
  // Only build the tmp_array if it does not already exist
  if (!tmp_array)
  {
    // Default dimensions
    npy_intp defaultDims[ ] = { blockMap.NumMyPoints() };

    // PyObject argument is a bool
    if (PyBool_Check(pyObject))
    {
      tmp_array = (PyArrayObject *)
	PyArray_SimpleNew(1,defaultDims,NPY_INT);
    }
    // PyObject argument is not a bool ... try to build a contiguous
    // PyArrayObject from it
    else
    {
      tmp_array = (PyArrayObject *)
	PyArray_ContiguousFromObject(pyObject,NPY_INT,0,0);
    }
    // If any PyArray factory functions fail, clean up and throw a
    // PythonException
    if (!tmp_array)
    {
      cleanup();
      throw PythonException();
    }
    int  nd = PyArray_NDIM(tmp_array);
    npy_intp arraySize = PyArray_MultiplyList(PyArray_DIMS(tmp_array),nd);
    if (arraySize != defaultDims[0])
    {
      PyArrayObject * myArray = (PyArrayObject *)
	PyArray_SimpleNew(1,defaultDims,NPY_INT);
      if (!myArray)
      {
	cleanup();
	throw PythonException();
      }
      int * myData  = (int *) PyArray_DATA(myArray);
      int * tmpData = (int *) PyArray_DATA(tmp_array);
      for (int i=0; i<defaultDims[0]; i++)
      {
	myData[i] = tmpData[i];
      }
      Py_XDECREF(tmp_array);
      tmp_array = myArray;
    }
  }
  return (int*)(PyArray_DATA(tmp_array));
}
开发者ID:00liujj,项目名称:trilinos,代码行数:53,代码来源:Epetra_NumPyIntVector.cpp


示例9: CONVERT_TO_INDEX

NUITKA_MAY_BE_UNUSED static Py_ssize_t CONVERT_TO_INDEX( PyObject *value )
{
    assertObject( value );

#if PYTHON_VERSION < 300
    if ( PyInt_Check( value ) )
    {
        return PyInt_AS_LONG( value );
    }
    else
#endif
    if ( PyIndex_Check( value ) )
    {
        Py_ssize_t result = PyNumber_AsSsize_t( value, NULL );

        if (unlikely( result == -1 ))
        {
            THROW_IF_ERROR_OCCURED();
        }

        return result;
    }
    else
    {
        PyErr_Format( PyExc_TypeError, "slice indices must be integers or None or have an __index__ method" );
        throw PythonException();
    }
}
开发者ID:ballacky13,项目名称:Nuitka,代码行数:28,代码来源:indexes.hpp


示例10: PyArray_ContiguousFromObject

// Static helper functions
// =============================================================================
double * Epetra_NumPyMultiVector::getArray(PyObject * pyObject)
{
  // Try to build a contiguous PyArrayObject from the pyObject
  if (!tmp_array)
    tmp_array = (PyArrayObject *)
      PyArray_ContiguousFromObject(pyObject,NPY_DOUBLE,0,0);
  
  // If this fails, clean up and throw a PythonException
  if (!tmp_array)
  {
    cleanup();
    throw PythonException();
  }
  // If the contiguous PyArrayObject built successfully, make sure it has the correct
  // number of dimensions
  else
  {
    if (PyArray_NDIM(tmp_array) < 2)
    {
      PyObject * tuple = Py_BuildValue("(ii)",1,-1);
      tmp_array = (PyArrayObject *) PyArray_Reshape(tmp_array,tuple);
      Py_DECREF(tuple);
    }
  }

  return (double *) (PyArray_DATA(tmp_array));
}
开发者ID:EllieGong,项目名称:trilinos,代码行数:29,代码来源:Epetra_NumPyMultiVector.cpp


示例11: getEpetraOperatorObjectAttr

Teuchos::RCP< Epetra_Operator >
getEpetraOperatorObjectAttr(PyObject   * object,
                            CONST char * name)
{
  static swig_type_info * swig_EO_ptr =
    SWIG_TypeQuery("Teuchos::RCP< Epetra_Operator > *");
  void * argp;
  PyObject * value = PyObject_GetAttrString(object, name);
  int newmem = 0;
  if (!SWIG_CheckState(SWIG_Python_ConvertPtrAndOwn(value,
                                                    &argp,
                                                    swig_EO_ptr,
                                                    0,
                                                    &newmem)))
  {
    PyErr_Format(PyExc_TypeError,
                 "Attribute '%s' is not of type Epetra.Operator",
                 name);
    Py_DECREF(value);
    throw PythonException();
  }
  Teuchos::RCP<Epetra_Operator > result =
    *reinterpret_cast< Teuchos::RCP< Epetra_Operator > * >(argp);
  if (newmem)
    delete reinterpret_cast< Teuchos::RCP< Epetra_Operator > * >(argp);
  Py_DECREF(value);
  return result;
}
开发者ID:abhishek4747,项目名称:trilinos,代码行数:28,代码来源:PyTrilinos_Epetra_Util.cpp


示例12: M

// =============================================================================
void Epetra_NumPySerialSymDenseMatrix::setArray(bool copy)
{
  if (tmp_array)
  {
    array     = tmp_array;
    tmp_array = NULL;
  }
  else
  {
    npy_intp dimensions[ ] = { M(), N() };
    double * data = NULL;
    if (!copy) data = Epetra_SerialSymDenseMatrix::A();
    // This NumPy function returns a borrowed pointer: no DECREF
    PyArray_Descr * dtype  = PyArray_DescrFromType(NPY_DOUBLE);
    array = (PyArrayObject*)
      PyArray_NewFromDescr(&PyArray_Type,dtype,2,dimensions,NULL,(void*)data,
			   NPY_ARRAY_FARRAY,NULL);
    if (!array)
    {
      cleanup();
      throw PythonException();
    }
    if (copy)
    {
      double * oldData = Epetra_SerialSymDenseMatrix::A();
      double * newData = (double*) PyArray_DATA(array);
      int      size    = dimensions[0] * dimensions[1];
      for (int i=0; i<size; ++i) newData[i] = oldData[i];
    }
  }
}
开发者ID:EllieGong,项目名称:trilinos,代码行数:32,代码来源:Epetra_NumPySerialSymDenseMatrix.cpp


示例13: convertToMDVector

Teuchos::RCP< Domi::MDVector< Scalar > >
convertToMDVector(const Teuchos::RCP< const Teuchos::Comm< int > > teuchosComm,
                  const DistArrayProtocol & distarray)
{
  // Get the equivalent MDMap
  Teuchos::RCP< const Domi::MDMap<> > mdMap =
    convertToMDMap(teuchosComm, distarray);

  // Get the equivalent MDArrayRCP
  Domi::MDArrayRCP< Scalar > mdArrayRcp =
    convertToMDArrayRCP< Scalar >((PyArrayObject*) distarray.buffer());

#ifdef PYTRILINOS_DOMI_UTIL_VERBOSE
  std::cout << "mdArrayRcp = " << mdArrayRcp << std::endl;
#endif

  // Return the result
  try
  {
    return Teuchos::rcp(new Domi::MDVector< Scalar >(mdMap, mdArrayRcp));
  }
  catch (Domi::InvalidArgument & e)
  {
    PyErr_SetString(PyExc_ValueError, e.what());
    throw PythonException();
  }
}
开发者ID:HTH123,项目名称:Trilinos,代码行数:27,代码来源:PyTrilinos_Domi_Util.hpp


示例14: THROW_IF_ERROR_OCCURED

NUITKA_MAY_BE_UNUSED static void THROW_IF_ERROR_OCCURED( void )
{
    if ( ERROR_OCCURED() )
    {
        throw PythonException();
    }
}
开发者ID:ballacky13,项目名称:Nuitka,代码行数:7,代码来源:raising.hpp


示例15: PyInt_AsLong

// Static helper functions
// =============================================================================
double * Epetra_NumPySerialDenseVector::getArray(PyObject * pyObject)
{
  // If tmp_array is NULL, build a PyArrayObject from the pyObject
  if (tmp_array == NULL)
  {
    // If pyObject is an int, build an array of that length
    if (PyInt_Check(pyObject))
    {
      npy_intp dimensions[ ] = {(npy_intp) PyInt_AsLong(pyObject)};
      tmp_array = (PyArrayObject*)
	PyArray_SimpleNew(1,dimensions,PyArray_DOUBLE);
    }
    // Else try to build a contiguous PyArrayObject from the pyObject
    else
    {
      tmp_array = (PyArrayObject *)
	PyArray_ContiguousFromObject(pyObject,PyArray_DOUBLE,0,0);
    }
  }

  // If these fail, clean up and throw a PythonException
  if (!tmp_array)
  {
    cleanup();
    throw PythonException();
  }
  return (double*)(tmp_array->data);
}
开发者ID:coyigg,项目名称:trilinos,代码行数:30,代码来源:Epetra_NumPySerialDenseVector.cpp


示例16: PyInt_AsLong

// Static helper functions
// =============================================================================
double * Epetra_NumPySerialSymDenseMatrix::getArray(PyObject * pyObject)
{
  // If tmp_array is NULL, build a PyArrayObject from the pyObject
  if (!tmp_array)
  {
    // If pyObject is an int, then emulate an int-int constructor
    if (PyInt_Check(pyObject))
    {
      int numRows = (int) PyInt_AsLong(pyObject);
      npy_intp dimensions[ ] = {numRows, numRows};
      tmp_array = (PyArrayObject *)
	PyArray_SimpleNew(2,dimensions,NPY_DOUBLE);
    }
    // If pyObject is not a bool nor an int, try to build a
    // contiguous 2D PyArrayObject from the pyObject
    else
    {
      // This function returns a borrowed ptr: no DECREF
      PyArray_Descr * dtype = 
	PyArray_DescrFromType(NPY_DOUBLE);
      tmp_array = (PyArrayObject *) PyArray_FromAny(pyObject, dtype, 2, 2,
						    NPY_ARRAY_FARRAY, NULL);
    }
  }
  // If no array has been correctly constructed, clean up and throw a
  // PythonException
  if (!tmp_array)
  {
    cleanup();
    throw PythonException();
  }

  return (double*)(PyArray_DATA(tmp_array));
}
开发者ID:EllieGong,项目名称:trilinos,代码行数:36,代码来源:Epetra_NumPySerialSymDenseMatrix.cpp


示例17: RunPythonAction

RunPythonFileAction::RunPythonFileAction(const ParameterValueMap &parameters) :
    RunPythonAction(parameters)
{
    // Converting to boost::filesystem::path first buys us some useful path expansion and validation
    const std::string filename(boost::filesystem::path(parameters[PATH]).string());
    
    std::FILE *fp = std::fopen(filename.c_str(), "r");
    if (!fp) {
        throw SimpleException(M_FILE_MESSAGE_DOMAIN, "Unable to open Python file", strerror(errno));
    }
    BOOST_SCOPE_EXIT(fp) {
        std::fclose(fp);
    } BOOST_SCOPE_EXIT_END
    
    ScopedGILAcquire sga;
    
    struct _node *node = PyParser_SimpleParseFile(fp, filename.c_str(), Py_file_input);
    BOOST_SCOPE_EXIT(node) {
        PyNode_Free(node);
    } BOOST_SCOPE_EXIT_END
    
    if (!node ||
        !(codeObject = PyNode_Compile(node, filename.c_str())))
    {
        throw PythonException("Python compilation failed");
    }
}
开发者ID:davidcox,项目名称:mworks,代码行数:27,代码来源:RunPythonFileAction.cpp


示例18: assertObject

NUITKA_MAY_BE_UNUSED static PyObject *CALL_FUNCTION( PyObject *function_object, PyObject *positional_args, PyObject *named_args )
{
    assertObject( function_object );
    assertObject( positional_args );
    assert( named_args == NULL || Py_REFCNT( named_args ) > 0 );

    ternaryfunc call_slot = Py_TYPE( function_object )->tp_call;

    if (unlikely( call_slot == NULL ))
    {
        PyErr_Format(
            PyExc_TypeError,
            "'%s' object is not callable",
            function_object->ob_type->tp_name
        );

        throw PythonException();
    }

    if (unlikely( Py_EnterRecursiveCall( (char *)" while calling a Python object") ))
    {
        throw PythonException();
    }

    PyObject *result = (*call_slot)( function_object, positional_args, named_args );

    Py_LeaveRecursiveCall();

    if ( result == NULL )
    {
        if (unlikely( !ERROR_OCCURED() ))
        {
            PyErr_Format(
                PyExc_SystemError,
                "NULL result without error in PyObject_Call"
            );
        }

        throw PythonException();
    }
    else
    {
        return result;
    }
}
开发者ID:TheKK,项目名称:Nuitka,代码行数:45,代码来源:calling.hpp


示例19: getDerivativePropertiesItemObjectAttr

EpetraExt::ModelEvaluator::DerivativeProperties
getDerivativePropertiesItemObjectAttr(PyObject * object, CONST char * name, int i)
{
    // The DerivativeProperties python class object
    static
    PyObject * classDerivativeProperties = NULL;
    if (!classDerivativeProperties)
    {
        classDerivativeProperties = getClassFromModule(PyTrilinosEpetraExt, "DerivativeProperties");
        if (!classDerivativeProperties) throw PythonException();
    }
    // Get the item from the object attribute
    PyObject * tuple = getTupleObjectAttr(object, name);
    PyObject * item  = PyTuple_GetItem(tuple, i);
    Py_DECREF(tuple);
    if (!item) throw PythonException();
    if (!PyObject_IsInstance(item, classDerivativeProperties))
    {
        PyErr_Format(PyExc_TypeError, "Attribute '%s' is not tuple of DerivativeProperties", name);
        Py_DECREF(item);
        throw PythonException();
    }
    EpetraExt::ModelEvaluator::DerivativeProperties result;
    // linearity attribute
    CONST char * linearity = getStringObjectAttr(item, "linearity");
    if (strncmp(linearity, "unknown", 7) == 0)
        result.linearity = EpetraExt::ModelEvaluator::DERIV_LINEARITY_UNKNOWN;
    if (strncmp(linearity, "const", 5) == 0)
        result.linearity = EpetraExt::ModelEvaluator::DERIV_LINEARITY_CONST;
    if (strncmp(linearity, "nonconst", 8) == 0)
        result.linearity = EpetraExt::ModelEvaluator::DERIV_LINEARITY_NONCONST;
    // rank attribute
    CONST char * rank = getStringObjectAttr(item, "rank");
    if (strncmp(rank, "unknown", 7) == 0)
        result.rank = EpetraExt::ModelEvaluator::DERIV_RANK_UNKNOWN;
    if (strncmp(rank, "full", 4) == 0)
        result.rank = EpetraExt::ModelEvaluator::DERIV_RANK_FULL;
    if (strncmp(rank, "deficient", 9) == 0)
        result.rank = EpetraExt::ModelEvaluator::DERIV_RANK_DEFICIENT;
    // supportsAdjoint attribute
    result.supportsAdjoint = getBoolObjectAttr(item, "supportsAdjoint");
    Py_DECREF(item);

    return result;
}
开发者ID:uppatispr,项目名称:trilinos-official,代码行数:45,代码来源:PyTrilinos_EpetraExt_Util.cpp


示例20: PyErr_Format

void DistArrayProtocol::checkAxis(int axis) const
{
  if ((axis < 0) || (axis >= dim_data.size()))
  {
    PyErr_Format(PyExc_IndexError, "axis = %d out of range [0, %ld)",
                 axis, dim_data.size());
    throw PythonException();
  }
}
开发者ID:chuprakov,项目名称:trilinos,代码行数:9,代码来源:PyTrilinos_DAP.cpp



注:本文中的PythonException函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ PythonQtSlotFunction_Check函数代码示例发布时间:2022-05-30
下一篇:
C++ Pycairo_Check_Status函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap