当前位置: 首页>>代码示例>>Python>>正文


Python ctypes.c_uint方法代码示例

本文整理汇总了Python中ctypes.c_uint方法的典型用法代码示例。如果您正苦于以下问题:Python ctypes.c_uint方法的具体用法?Python ctypes.c_uint怎么用?Python ctypes.c_uint使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ctypes的用法示例。


在下文中一共展示了ctypes.c_uint方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: list_global_func_names

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_uint [as 别名]
def list_global_func_names():
    """Get list of global functions registered.

    Returns
    -------
    names : list
       List of global functions names.
    """
    plist = ctypes.POINTER(ctypes.c_char_p)()
    size = ctypes.c_uint()

    check_call(_LIB.DGLFuncListGlobalNames(ctypes.byref(size),
                                           ctypes.byref(plist)))
    fnames = []
    for i in range(size.value):
        fnames.append(py_str(plist[i]))
    return fnames 
开发者ID:dmlc,项目名称:dgl,代码行数:19,代码来源:function.py

示例2: list_arguments

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_uint [as 别名]
def list_arguments(self):
        """Lists all the arguments in the symbol.

        Example
        -------
        >>> a = mx.sym.var('a')
        >>> b = mx.sym.var('b')
        >>> c = a + b
        >>> c.list_arguments
        ['a', 'b']

        Returns
        -------
        args : list of string
            List containing the names of all the arguments required to compute the symbol.
        """
        size = ctypes.c_uint()
        sarr = ctypes.POINTER(ctypes.c_char_p)()
        check_call(_LIB.MXSymbolListArguments(
            self.handle, ctypes.byref(size), ctypes.byref(sarr)))
        return [py_str(sarr[i]) for i in range(size.value)] 
开发者ID:awslabs,项目名称:dynamic-training-with-apache-mxnet-on-aws,代码行数:23,代码来源:symbol.py

示例3: list_inputs

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_uint [as 别名]
def list_inputs(self):
        """Lists all arguments and auxiliary states of this Symbol.

        Returns
        -------
        inputs : list of str
            List of all inputs.

        Examples
        --------
        >>> bn = mx.sym.BatchNorm(name='bn')
        >>> bn.list_arguments()
        ['bn_data', 'bn_gamma', 'bn_beta']
        >>> bn.list_auxiliary_states()
        ['bn_moving_mean', 'bn_moving_var']
        >>> bn.list_inputs()
        ['bn_data', 'bn_gamma', 'bn_beta', 'bn_moving_mean', 'bn_moving_var']
        """
        size = ctypes.c_uint()
        sarr = ctypes.POINTER(ctypes.c_char_p)()
        check_call(_LIB.NNSymbolListInputNames(
            self.handle, 0, ctypes.byref(size), ctypes.byref(sarr)))
        return [py_str(sarr[i]) for i in range(size.value)] 
开发者ID:awslabs,项目名称:dynamic-training-with-apache-mxnet-on-aws,代码行数:25,代码来源:symbol.py

示例4: _init_torch_module

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_uint [as 别名]
def _init_torch_module():
    """List and add all the torch backed ndarray functions to current module."""
    plist = ctypes.POINTER(FunctionHandle)()
    size = ctypes.c_uint()
    check_call(_LIB.MXListFunctions(ctypes.byref(size),
                                    ctypes.byref(plist)))

    module_obj = sys.modules[__name__]
    for i in range(size.value):
        hdl = FunctionHandle(plist[i])
        function = _make_torch_function(hdl)
        # if function name starts with underscore, register as static method of NDArray
        if function is not None:
            setattr(module_obj, function.__name__, function)

# Initialize the NDArray module 
开发者ID:awslabs,项目名称:dynamic-training-with-apache-mxnet-on-aws,代码行数:18,代码来源:torch.py

示例5: delay_and_stop

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_uint [as 别名]
def delay_and_stop(duration, dll, device_number):
    """Stop vibration aka force feedback aka rumble on
    Windows after duration miliseconds."""
    xinput = getattr(ctypes.windll, dll)
    time.sleep(duration/1000)
    xinput_set_state = xinput.XInputSetState
    xinput_set_state.argtypes = [
        ctypes.c_uint, ctypes.POINTER(XinputVibration)]
    xinput_set_state.restype = ctypes.c_uint
    vibration = XinputVibration(0, 0)
    xinput_set_state(device_number, ctypes.byref(vibration))


# I made this GamePad class before Mouse and Keyboard above, and have
# learned a lot about Windows in the process.  This can probably be
# simplified massively and made to match Mouse and Keyboard more. 
开发者ID:zeth,项目名称:inputs,代码行数:18,代码来源:inputs.py

示例6: getChannelData_Name

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_uint [as 别名]
def getChannelData_Name(self, channel):
        """Get the product name.
        Retrieves the product name of the device connected to channel. The name
        is returned as an ASCII string.
        Args:
            channel (int): The channel you are interested in
        Returns:
            name (string): The product name
        """
        self.fn = inspect.currentframe().f_code.co_name
        name = ct.create_string_buffer(80)
        self.dll.canGetChannelData(channel,
                                   canCHANNELDATA_DEVDESCR_ASCII,
                                   ct.byref(name), ct.sizeof(name))
        buf_type = ct.c_uint * 1
        buf = buf_type()
        self.dll.canGetChannelData(channel,
                                   canCHANNELDATA_CHAN_NO_ON_CARD,
                                   ct.byref(buf), ct.sizeof(buf))
        return "%s (channel %d)" % (name.value, buf[0]) 
开发者ID:diyjac,项目名称:Udacity-SDC-Radar-Driver-Micro-Challenge,代码行数:22,代码来源:canlib.py

示例7: getChannelData_Chan_No_On_Card

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_uint [as 别名]
def getChannelData_Chan_No_On_Card(self, channel):
        """Get the channel number on the card.
        Retrieves the channel number, as numbered locally on the card, device
        connected to channel.
        Args:
            channel (int): The channel you are interested in
        Returns:
            number (int): The local channel number
        """
        self.fn = inspect.currentframe().f_code.co_name
        number = ct.c_ulong()
        self.dll.canGetChannelData(channel,
                                   canCHANNELDATA_CHAN_NO_ON_CARD,
                                   ct.byref(number), ct.sizeof(number))
        buf_type = ct.c_uint * 1
        buf = buf_type()
        self.dll.canGetChannelData(channel,
                                   canCHANNELDATA_CHAN_NO_ON_CARD,
                                   ct.byref(buf), ct.sizeof(buf))
        return number.value 
开发者ID:diyjac,项目名称:Udacity-SDC-Radar-Driver-Micro-Challenge,代码行数:22,代码来源:canlib.py

示例8: _create_polygon

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_uint [as 别名]
def _create_polygon(self, length, items):
        # Instantiate LinearRing objects if necessary, but don't clone them yet
        # _construct_ring will throw a TypeError if a parameter isn't a valid ring
        # If we cloned the pointers here, we wouldn't be able to clean up
        # in case of error.
        rings = []
        for r in items:
            if isinstance(r, GEOM_PTR):
                rings.append(r)
            else:
                rings.append(self._construct_ring(r))

        shell = self._clone(rings.pop(0))

        n_holes = length - 1
        if n_holes:
            holes = get_pointer_arr(n_holes)
            for i, r in enumerate(rings):
                holes[i] = self._clone(r)
                holes_param = byref(holes)
        else:
            holes_param = None

        return capi.create_polygon(shell, holes_param, c_uint(n_holes)) 
开发者ID:lanbing510,项目名称:GTDWeb,代码行数:26,代码来源:polygon.py

示例9: cs_operation

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_uint [as 别名]
def cs_operation(func, ordinate=False, get=False):
    "For coordinate sequence operations."
    if get:
        # Get routines get double parameter passed-in by reference.
        func.errcheck = check_cs_get
        dbl_param = POINTER(c_double)
    else:
        func.errcheck = check_cs_op
        dbl_param = c_double

    if ordinate:
        # Get/Set ordinate routines have an extra uint parameter.
        func.argtypes = [CS_PTR, c_uint, c_uint, dbl_param]
    else:
        func.argtypes = [CS_PTR, c_uint, dbl_param]

    func.restype = c_int
    return func 
开发者ID:lanbing510,项目名称:GTDWeb,代码行数:20,代码来源:coordseq.py

示例10: test_int_pointers

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_uint [as 别名]
def test_int_pointers(self):
        from ctypes import c_short, c_uint, c_int, c_long, POINTER, pointer
        LPINT = POINTER(c_int)

##        p = pointer(c_int(42))
##        x = LPINT.from_param(p)
        x = LPINT.from_param(pointer(c_int(42)))
        self.assertEqual(x.contents.value, 42)
        self.assertEqual(LPINT(c_int(42)).contents.value, 42)

        self.assertEqual(LPINT.from_param(None), None)

        if c_int != c_long:
            self.assertRaises(TypeError, LPINT.from_param, pointer(c_long(42)))
        self.assertRaises(TypeError, LPINT.from_param, pointer(c_uint(42)))
        self.assertRaises(TypeError, LPINT.from_param, pointer(c_short(42))) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:18,代码来源:test_parameters.py

示例11: __init__

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_uint [as 别名]
def __init__(self, *, slot_bytes, slot_count):
        """Initializer.

        Args:
            slot_bytes: The maximum size of slots in the buffer.
            slot_count: How many slots should be in the buffer.
        """
        self.slot_count = slot_count
        self.array = SlotArray(slot_bytes=slot_bytes, slot_count=slot_count)
        self.lock = ReadersWriterLock()
        # Each reading process may modify its own Pointer while the read
        # lock is being held. Each reading process can also load the position
        # of the writer, but not load any other readers. Each reading process
        # can also load the value of the 'active' count.
        self.readers = []
        # The writer can load and store the Pointer of all the reader Pointers
        # or the writer Pointer while the write lock is held. It can also load
        # and store the value of the 'active' acount.
        self.writer = Pointer(self.slot_count)
        self.active = multiprocessing.RawValue(ctypes.c_uint, 0) 
开发者ID:bslatkin,项目名称:ringbuffer,代码行数:22,代码来源:ringbuffer.py

示例12: _create_point

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_uint [as 别名]
def _create_point(cls, ndim, coords):
        """
        Create a coordinate sequence, set X, Y, [Z], and create point
        """
        if not ndim:
            return capi.create_point(None)

        if ndim < 2 or ndim > 3:
            raise TypeError('Invalid point dimension: %s' % ndim)

        cs = capi.create_cs(c_uint(1), c_uint(ndim))
        i = iter(coords)
        capi.cs_setx(cs, 0, next(i))
        capi.cs_sety(cs, 0, next(i))
        if ndim == 3:
            capi.cs_setz(cs, 0, next(i))

        return capi.create_point(cs) 
开发者ID:reBiocoder,项目名称:bioforum,代码行数:20,代码来源:point.py

示例13: _create_polygon

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_uint [as 别名]
def _create_polygon(self, length, items):
        # Instantiate LinearRing objects if necessary, but don't clone them yet
        # _construct_ring will throw a TypeError if a parameter isn't a valid ring
        # If we cloned the pointers here, we wouldn't be able to clean up
        # in case of error.
        if not length:
            return capi.create_empty_polygon()

        rings = []
        for r in items:
            if isinstance(r, GEOM_PTR):
                rings.append(r)
            else:
                rings.append(self._construct_ring(r))

        shell = self._clone(rings.pop(0))

        n_holes = length - 1
        if n_holes:
            holes = (GEOM_PTR * n_holes)(*[self._clone(r) for r in rings])
            holes_param = byref(holes)
        else:
            holes_param = None

        return capi.create_polygon(shell, holes_param, c_uint(n_holes)) 
开发者ID:reBiocoder,项目名称:bioforum,代码行数:27,代码来源:polygon.py

示例14: test_array_pointers

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_uint [as 别名]
def test_array_pointers(self):
        from ctypes import c_short, c_uint, c_int, c_long, POINTER
        INTARRAY = c_int * 3
        ia = INTARRAY()
        self.assertEqual(len(ia), 3)
        self.assertEqual([ia[i] for i in range(3)], [0, 0, 0])

        # Pointers are only compatible with arrays containing items of
        # the same type!
        LPINT = POINTER(c_int)
        LPINT.from_param((c_int*3)())
        self.assertRaises(TypeError, LPINT.from_param, c_short*3)
        self.assertRaises(TypeError, LPINT.from_param, c_long*3)
        self.assertRaises(TypeError, LPINT.from_param, c_uint*3)

##    def test_performance(self):
##        check_perf() 
开发者ID:dxwu,项目名称:BinderFilter,代码行数:19,代码来源:test_parameters.py

示例15: _get_long_path_name

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_uint [as 别名]
def _get_long_path_name(path):
        """Get a long path name (expand ~) on Windows using ctypes.

        Examples
        --------

        >>> get_long_path_name('c:\\docume~1')
        u'c:\\\\Documents and Settings'

        """
        try:
            import ctypes
        except ImportError:
            raise ImportError('you need to have ctypes installed for this to work')
        _GetLongPathName = ctypes.windll.kernel32.GetLongPathNameW
        _GetLongPathName.argtypes = [ctypes.c_wchar_p, ctypes.c_wchar_p,
            ctypes.c_uint ]

        buf = ctypes.create_unicode_buffer(260)
        rv = _GetLongPathName(path, buf, 260)
        if rv == 0 or rv > 260:
            return path
        else:
            return buf.value 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:26,代码来源:path.py


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