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

C++ PyNumber_Float函数代码示例

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

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



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

示例1: PyNumber_Float

static PyObject *mpy_Matrix_inplace_mul(PyObject *M, PyObject *N)
{
    PyObject *tmp_arg_as_py_double;

    if (PyObject_TypeCheck(M, &mpy_MatrixType)) {
        if (PyNumber_Check(N)) {
            tmp_arg_as_py_double = PyNumber_Float(N);
            if (tmp_arg_as_py_double != NULL) {
                double N_as_double = PyFloat_AsDouble(tmp_arg_as_py_double);
                ((mpy_Matrix *)M)->M *= N_as_double;
                Py_INCREF(M);
                return M;
            }
        }
    }
    else if (PyNumber_Check(M)) {
        if (PyObject_TypeCheck(N, &mpy_MatrixType)) {
            tmp_arg_as_py_double = PyNumber_Float(M);
            if (tmp_arg_as_py_double != NULL) {
                double M_as_double = PyFloat_AsDouble(tmp_arg_as_py_double);
                ((mpy_Matrix *)N)->M *= M_as_double;
                Py_INCREF(N);
                return N;
            }
        }
    }

    Py_INCREF(Py_NotImplemented);
    return Py_NotImplemented;
}
开发者ID:volund,项目名称:mango,代码行数:30,代码来源:mangopy_matrix.cpp


示例2: Polygon_Raise

static PyObject *Polygon_addContour(Polygon *self, PyObject *args) {
#ifdef WITH_NUMERIC
    PyObject *a=NULL;
    gpc_vertex_list *vl;
    int hole = 0;
    if (! PyArg_ParseTuple(args, "O|i", &a, &hole))
        return Polygon_Raise(ERR_ARG);
    if ((a = PyArray_ContiguousFromObject(a, PyArray_DOUBLE, 2, 2)) == NULL)
        return Polygon_Raise(ERR_ARG);
    if (((PyArrayObject *)a)->nd != 2)            return Polygon_Raise(ERR_ARG);
    if (((PyArrayObject *)a)->dimensions[1] != 2) return Polygon_Raise(ERR_ARG);
    vl = PyMem_New(gpc_vertex_list, 1);
    vl->num_vertices = ((PyArrayObject *)a)->dimensions[0];
    vl->vertex = PyMem_New(gpc_vertex, vl->num_vertices);
    memcpy((vl->vertex), (((PyArrayObject *)a)->data), 2*vl->num_vertices*sizeof(double));
    Py_DECREF(a);
#else
    PyObject *list=NULL, *flist, *point=NULL, *X, *Y;
    gpc_vertex_list *vl;
    gpc_vertex *v;
    int i, imax, hole = 0;
    if (! PyArg_ParseTuple(args, "O|i", &list, &hole))
        return Polygon_Raise(ERR_ARG);
    if (! PySequence_Check(list))
        return Polygon_Raise(ERR_ARG);
    flist = PySequence_Fast(list, "this is not a sequence");
    if ((! flist) || ((imax = PySequence_Length(flist)) <= 2))
        return Polygon_Raise(ERR_INV);
    vl = PyMem_New(gpc_vertex_list, 1);
    vl->num_vertices = imax;
    vl->vertex = v = PyMem_New(gpc_vertex, imax);
    for (i=0; i<imax; i++) {
        point = PySequence_Fast(PySequence_Fast_GET_ITEM(flist, i), "this is not a point");
        if ((!point) || (PySequence_Length(point) != 2))
            return Polygon_Raise(ERR_INV);
        v->x = PyFloat_AsDouble(X = PyNumber_Float(PySequence_Fast_GET_ITEM(point, 0)));
        v->y = PyFloat_AsDouble(Y = PyNumber_Float(PySequence_Fast_GET_ITEM(point, 1)));
        v++;
        Py_DECREF(X);
        Py_DECREF(Y);
        Py_DECREF(point);
    }
    Py_DECREF(flist);
#endif /* WITH_NUMERIC */
    gpc_add_contour(self->p, vl, hole);
    self->bbValid = 0;
    PyMem_Free(vl->vertex);
    PyMem_Free(vl);
    Py_INCREF(Py_None);
    return Py_None;
}
开发者ID:anujonthemove,项目名称:supreme,代码行数:51,代码来源:cPolygon.c


示例3: LFO_setFreq

static PyObject *
LFO_setFreq(LFO *self, PyObject *arg)
{
	PyObject *tmp, *streamtmp;
	
	if (arg == NULL) {
		Py_INCREF(Py_None);
		return Py_None;
	}
    
	int isNumber = PyNumber_Check(arg);
	
	tmp = arg;
	Py_INCREF(tmp);
	Py_DECREF(self->freq);
	if (isNumber == 1) {
		self->freq = PyNumber_Float(tmp);
        self->modebuffer[2] = 0;
	}
	else {
		self->freq = tmp;
        streamtmp = PyObject_CallMethod((PyObject *)self->freq, "_getStream", NULL);
        Py_INCREF(streamtmp);
        Py_XDECREF(self->freq_stream);
        self->freq_stream = (Stream *)streamtmp;
		self->modebuffer[2] = 1;
	}
    
    (*self->mode_func_ptr)(self);
    
	Py_INCREF(Py_None);
	return Py_None;
}	
开发者ID:aalex,项目名称:ubuntu-python-pyo,代码行数:33,代码来源:lfomodule.c


示例4: tupleToDoubleArray

PyObject * tupleToDoubleArray(PyObject *tuple_obj, double *arr, unsigned n, int demandExactLen) {
	PyObject *item, *f_item;
	unsigned pytuple_len = (unsigned) PyTuple_Size(tuple_obj);
	unsigned i;
	if (pytuple_len != n && ((demandExactLen != 0) || (pytuple_len < n))) {
		PyErr_SetString(PyExc_IndexError, "tuple index out of range");
		return 0L;
	}
	for (i = 0; i < n; ++i) {
		item = PyTuple_GetItem(tuple_obj, i);
		if (item == 0L) {
			return 0L;
		}
		Py_INCREF(item);
		f_item = PyNumber_Float(item);
		if (f_item == 0L) {
			Py_DECREF(item);
			return 0L;
		}
		arr[i] = PyFloat_AsDouble(item);
		Py_DECREF(item);
		Py_DECREF(f_item);
	}
	return none();
}
开发者ID:argriffing,项目名称:pytbeaglehon,代码行数:25,代码来源:py_util.c


示例5: listToDoubleArray

PyObject * listToDoubleArray(PyObject *list_obj, double *arr, unsigned n) {
	PyObject *item, *f_item;
	unsigned pylist_len = (unsigned) PyList_Size(list_obj);
	unsigned i;
	if (pylist_len != n) {
		PyErr_SetString(PyExc_IndexError, "list index out of range");
		return 0L;
	}
	for (i = 0; i < n; ++i) {
		item = PyList_GetItem(list_obj, i);
		if (item == 0L) {
			return 0L;
		}
		Py_INCREF(item);
		f_item = PyNumber_Float(item);
		if (f_item == 0L) {
			Py_DECREF(item);
			return 0L;
		}
		arr[i] = PyFloat_AsDouble(item);
		Py_DECREF(item);
		Py_DECREF(f_item);
	}
	return none();
}
开发者ID:argriffing,项目名称:pytbeaglehon,代码行数:25,代码来源:py_util.c


示例6: SigTo_setValue

static PyObject *
SigTo_setValue(SigTo *self, PyObject *arg)
{
	PyObject *tmp, *streamtmp;
	
	if (arg == NULL) {
		Py_INCREF(Py_None);
		return Py_None;
	}
    
	int isNumber = PyNumber_Check(arg);
	
	tmp = arg;
	Py_INCREF(tmp);
    Py_DECREF(self->value);
	if (isNumber == 1) {
		self->value = PyNumber_Float(tmp);
        self->modebuffer[2] = 0;
    }
    else {
		self->value = tmp;
        streamtmp = PyObject_CallMethod((PyObject *)self->value, "_getStream", NULL);
        Py_INCREF(streamtmp);
        Py_XDECREF(self->value_stream);
        self->value_stream = (Stream *)streamtmp;
        self->modebuffer[2] = 1;
    }
    
	Py_INCREF(Py_None);
	return Py_None;
}	
开发者ID:aalex,项目名称:ubuntu-python-pyo,代码行数:31,代码来源:sigmodule.c


示例7: ue_py_slate_cast

static PyObject *py_ue_sborder_set_padding(ue_PySBorder *self, PyObject * args)
{
	ue_py_slate_cast(SBorder);

	PyObject *py_padding;
	if (!PyArg_ParseTuple(args, "O:set_padding", &py_padding))
	{
		return nullptr;
	}

	FMargin *margin = ue_py_check_struct<FMargin>(py_padding);
	if (!margin)
	{
		if (!PyNumber_Check(py_padding))
		{
			return PyErr_Format(PyExc_Exception, "argument is not a FMargin or a number");
		}
		PyObject *py_float = PyNumber_Float(py_padding);
		FMargin new_margin(PyFloat_AsDouble(py_float));
		margin = &new_margin;
		Py_DECREF(py_float);
	}

	py_SBorder->SetPadding(*margin);

	Py_RETURN_SLATE_SELF;
}
开发者ID:rdsgautier,项目名称:UnrealEnginePython,代码行数:27,代码来源:UEPySBorder.cpp


示例8: Chorus_setMix

static PyObject *
Chorus_setMix(Chorus *self, PyObject *arg)
{
	PyObject *tmp, *streamtmp;
	
	if (arg == NULL) {
		Py_INCREF(Py_None);
		return Py_None;
	}
    
	int isNumber = PyNumber_Check(arg);
    
	tmp = arg;
	Py_INCREF(tmp);
	Py_DECREF(self->mix);
	if (isNumber == 1) {
		self->mix = PyNumber_Float(tmp);
        self->modebuffer[4] = 0;
	}
	else {
		self->mix = tmp;
        streamtmp = PyObject_CallMethod((PyObject *)self->mix, "_getStream", NULL);
        Py_INCREF(streamtmp);
        Py_XDECREF(self->mix_stream);
        self->mix_stream = (Stream *)streamtmp;
		self->modebuffer[4] = 1;
	}
    
    (*self->mode_func_ptr)(self);
    
	Py_INCREF(Py_None);
	return Py_None;
}	
开发者ID:aalex,项目名称:ubuntu-python-pyo,代码行数:33,代码来源:chorusmodule.c


示例9: PyFloat_FromString

NUITKA_MAY_BE_UNUSED static PyObject *TO_FLOAT( PyObject *value )
{
    PyObject *result;

#if PYTHON_VERSION < 300
    if ( PyString_CheckExact( value ) )
    {
        result = PyFloat_FromString( value, NULL );
    }
#else
    if ( PyUnicode_CheckExact( value ) )
    {
        result = PyFloat_FromString( value );
    }
#endif
    else
    {
        result = PyNumber_Float( value );
    }

    if (unlikely( result == NULL ))
    {
        return NULL;
    }

    return result;
}
开发者ID:gitter-badger,项目名称:Nuitka,代码行数:27,代码来源:helpers.hpp


示例10: FourBandMain_setFreq3

static PyObject *
FourBandMain_setFreq3(FourBandMain *self, PyObject *arg)
{
	PyObject *tmp, *streamtmp;

	if (arg == NULL) {
		Py_INCREF(Py_None);
		return Py_None;
	}

	int isNumber = PyNumber_Check(arg);

	tmp = arg;
	Py_INCREF(tmp);
	Py_DECREF(self->freq3);
	if (isNumber == 1) {
		self->freq3 = PyNumber_Float(tmp);
        self->modebuffer[2] = 0;
	}
	else {
		self->freq3 = tmp;
        streamtmp = PyObject_CallMethod((PyObject *)self->freq3, "_getStream", NULL);
        Py_INCREF(streamtmp);
        Py_XDECREF(self->freq3_stream);
        self->freq3_stream = (Stream *)streamtmp;
		self->modebuffer[2] = 1;
	}

	Py_INCREF(Py_None);
	return Py_None;
}
开发者ID:BackupGGCode,项目名称:pyo,代码行数:31,代码来源:bandsplitmodule.c


示例11: BandSplitter_setQ

static PyObject *
BandSplitter_setQ(BandSplitter *self, PyObject *arg)
{
	PyObject *tmp, *streamtmp;

	if (arg == NULL) {
		Py_INCREF(Py_None);
		return Py_None;
	}

	int isNumber = PyNumber_Check(arg);

	tmp = arg;
	Py_INCREF(tmp);
	Py_DECREF(self->q);
	if (isNumber == 1) {
		self->q = PyNumber_Float(tmp);
        self->modebuffer[0] = 0;
        BandSplitter_compute_variables((BandSplitter *)self, PyFloat_AS_DOUBLE(self->q));
	}
	else {
		self->q = tmp;
        streamtmp = PyObject_CallMethod((PyObject *)self->q, "_getStream", NULL);
        Py_INCREF(streamtmp);
        Py_XDECREF(self->q_stream);
        self->q_stream = (Stream *)streamtmp;
		self->modebuffer[0] = 1;
	}

    (*self->mode_func_ptr)(self);

	Py_INCREF(Py_None);
	return Py_None;
}
开发者ID:BackupGGCode,项目名称:pyo,代码行数:34,代码来源:bandsplitmodule.c


示例12: OscBank_setArnda

static PyObject *
OscBank_setArnda(OscBank *self, PyObject *arg)
{
	PyObject *tmp, *streamtmp;
	
	if (arg == NULL) {
		Py_INCREF(Py_None);
		return Py_None;
	}
    
	int isNumber = PyNumber_Check(arg);
	
	tmp = arg;
	Py_INCREF(tmp);
	Py_DECREF(self->arnda);
	if (isNumber == 1) {
		self->arnda = PyNumber_Float(tmp);
        self->modebuffer[8] = 0;
	}
	else {
		self->arnda = tmp;
        streamtmp = PyObject_CallMethod((PyObject *)self->arnda, "_getStream", NULL);
        Py_INCREF(streamtmp);
        Py_XDECREF(self->arnda_stream);
        self->arnda_stream = (Stream *)streamtmp;
		self->modebuffer[8] = 1;
	}
    
	Py_INCREF(Py_None);
	return Py_None;
}	
开发者ID:aalex,项目名称:ubuntu-python-pyo,代码行数:31,代码来源:oscbankmodule.c


示例13: NewMatrix_setMatrix

static PyObject *
NewMatrix_setMatrix(NewMatrix *self, PyObject *value)
{
    int i, j;
    PyObject *innerlist;

    if (value == NULL) {
        PyErr_SetString(PyExc_TypeError, "Cannot delete the list attribute.");
        return PyInt_FromLong(-1);
    }
    
    if (! PyList_Check(value)) {
        PyErr_SetString(PyExc_TypeError, "The matrix value value must be a list.");
        return PyInt_FromLong(-1);
    }

    int height = PyList_Size(value);
    int width = PyList_Size(PyList_GetItem(value, 0));
    if (height != self->height || width != self->width) {
        PyErr_SetString(PyExc_TypeError, "New matrix must be of the same size as actual matrix.");
        return PyInt_FromLong(-1);
    }
    
    for(i=0; i<self->height; i++) {
        innerlist = PyList_GetItem(value, i);
        for (j=0; j<self->width; j++) {
            self->data[i][j] = PyFloat_AS_DOUBLE(PyNumber_Float(PyList_GET_ITEM(innerlist, j)));
        }    
    }

    Py_INCREF(Py_None);
    return Py_None;    
}
开发者ID:aalex,项目名称:ubuntu-python-pyo,代码行数:33,代码来源:matrixmodule.c


示例14: Harmonizer_setFeedback

static PyObject *
Harmonizer_setFeedback(Harmonizer *self, PyObject *arg)
{
    PyObject *tmp, *streamtmp;

    if (arg == NULL) {
        Py_INCREF(Py_None);
        return Py_None;
    }

    int isNumber = PyNumber_Check(arg);

    tmp = arg;
    Py_INCREF(tmp);
    Py_DECREF(self->feedback);
    if (isNumber == 1) {
        self->feedback = PyNumber_Float(tmp);
        self->modebuffer[3] = 0;
    }
    else {
        self->feedback = tmp;
        streamtmp = PyObject_CallMethod((PyObject *)self->feedback, "_getStream", NULL);
        Py_INCREF(streamtmp);
        Py_XDECREF(self->feedback_stream);
        self->feedback_stream = (Stream *)streamtmp;
        self->modebuffer[3] = 1;
    }

    (*self->mode_func_ptr)(self);

    Py_INCREF(Py_None);
    return Py_None;
}
开发者ID:aalex,项目名称:ubuntu-python-pyo,代码行数:33,代码来源:harmonizermodule.c


示例15: OscBank_setArndf

static PyObject *
OscBank_setArndf(OscBank *self, PyObject *arg)
{
	PyObject *tmp, *streamtmp;

    ASSERT_ARG_NOT_NULL

	int isNumber = PyNumber_Check(arg);

	tmp = arg;
	Py_INCREF(tmp);
	Py_DECREF(self->arndf);
	if (isNumber == 1) {
		self->arndf = PyNumber_Float(tmp);
        self->modebuffer[7] = 0;
	}
	else {
		self->arndf = tmp;
        streamtmp = PyObject_CallMethod((PyObject *)self->arndf, "_getStream", NULL);
        Py_INCREF(streamtmp);
        Py_XDECREF(self->arndf_stream);
        self->arndf_stream = (Stream *)streamtmp;
		self->modebuffer[7] = 1;
	}

	Py_INCREF(Py_None);
	return Py_None;
}
开发者ID:razorboy73,项目名称:pyo,代码行数:28,代码来源:oscbankmodule.c


示例16: PyNumber_Float

static PyObject *NumberValue(PyObject *self, PyObject *args)
{
  PyObject *object;
  PyObject *result = NULL;

  if (!PyArg_ParseTuple(args, "O:NumberValue", &object))
    return NULL;
  
  result = PyNumber_Float(object);
  if (result)
    return result;

  PyErr_Clear();

  if (PyString_Check(object) || PyUnicode_Check(object))
    return string_to_number(object);

  /* convert it to a string */
  object = object_to_string(object);
  if (object) {
    result = string_to_number(object);
    Py_DECREF(object);
  }
  else result = NULL;

  return result;
}
开发者ID:H1d3r,项目名称:binary_blobs,代码行数:27,代码来源:_conversions.c


示例17: parse_save_field

/*
 * READER
 */
static int
parse_save_field(ReaderObj *self)
{
    PyObject *field;

    field = PyString_FromStringAndSize(self->field, self->field_len);
    if (field == NULL)
        return -1;
    self->field_len = 0;
    if (self->numeric_field) {
        PyObject *tmp;

        self->numeric_field = 0;
        tmp = PyNumber_Float(field);
        if (tmp == NULL) {
            Py_DECREF(field);
            return -1;
        }
        Py_DECREF(field);
        field = tmp;
    }
    PyList_Append(self->fields, field);
    Py_DECREF(field);
    return 0;
}
开发者ID:AbnerChang,项目名称:edk2-staging,代码行数:28,代码来源:_csv.c


示例18: parse_save_field

/*
 * READER
 */
static int
parse_save_field(ReaderObj *self)
{
    PyObject *field;

    field = PyUnicode_FromKindAndData(PyUnicode_4BYTE_KIND,
                                      (void *) self->field, self->field_len);
    if (field == NULL)
        return -1;
    self->field_len = 0;
    if (self->numeric_field) {
        PyObject *tmp;

        self->numeric_field = 0;
        tmp = PyNumber_Float(field);
        Py_DECREF(field);
        if (tmp == NULL)
            return -1;
        field = tmp;
    }
    if (PyList_Append(self->fields, field) < 0) {
        Py_DECREF(field);
        return -1;
    }
    Py_DECREF(field);
    return 0;
}
开发者ID:1st1,项目名称:cpython,代码行数:30,代码来源:_csv.c


示例19: LFO_setSharp

static PyObject *
LFO_setSharp(LFO *self, PyObject *arg)
{
	PyObject *tmp, *streamtmp;

    ASSERT_ARG_NOT_NULL

	int isNumber = PyNumber_Check(arg);

	tmp = arg;
	Py_INCREF(tmp);
	Py_DECREF(self->sharp);
	if (isNumber == 1) {
		self->sharp = PyNumber_Float(tmp);
        self->modebuffer[3] = 0;
	}
	else {
		self->sharp = tmp;
        streamtmp = PyObject_CallMethod((PyObject *)self->sharp, "_getStream", NULL);
        Py_INCREF(streamtmp);
        Py_XDECREF(self->sharp_stream);
        self->sharp_stream = (Stream *)streamtmp;
		self->modebuffer[3] = 1;
	}

    (*self->mode_func_ptr)(self);

	Py_INCREF(Py_None);
	return Py_None;
}
开发者ID:belangeo,项目名称:pyo,代码行数:30,代码来源:lfomodule.c


示例20: GetDoubleFromPyObject

 bool GetDoubleFromPyObject(PyObject* object, double* val)
 {
     if(!val || !object) return false;
     
     if( PyFloat_Check( object ) )
     {
         *val = PyFloat_AS_DOUBLE( object );
         return true;
     }
     
     if( PyInt_Check( object ) )
     {
         *val = static_cast<double>( PyInt_AS_LONG( object ) );
         return true;
     }
     
     PyObject* floatObject = PyNumber_Float(object);
     if(floatObject)
     {
         *val = PyFloat_AS_DOUBLE( floatObject );
         Py_DECREF(floatObject);
         return true;
     }
     
     PyErr_Clear();
     return false;
 }
开发者ID:heesoo,项目名称:OpenColorIO,代码行数:27,代码来源:PyUtil.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ PyOS_snprintf函数代码示例发布时间:2022-05-30
下一篇:
C++ PyNumber_Check函数代码示例发布时间: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