Python numpy.ctypeslib() Examples

The following are 3 code examples for showing how to use numpy.ctypeslib(). These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example.

You may check out the related API usage on the sidebar.

You may also want to check out all available functions/classes of the module numpy , or try the search function .

Example 1
Project: switchio   Author: friends-of-freeswitch   File: shmarray.py    License: Mozilla Public License 2.0 6 votes vote down vote up
def __new__(cls, ctypesArray, shape, dtype=float, strides=None, offset=0,
                order=None):
        # some magic (copied from numpy.ctypeslib) to make sure the ctypes
        # array has the array interface
        tp = type(ctypesArray)
        try:
            tp.__array_interface__
        except AttributeError:
            ctypeslib.prep_array(tp)

        obj = numpy.ndarray.__new__(
            cls, shape, dtype, ctypesArray, offset, strides, order)

        # keep track of the underlying storage
        # this may not be strictly necessary as the same info should be stored
        # in .base
        obj.ctypesArray = ctypesArray
        return obj 
Example 2
Project: switchy   Author: sangoma   File: shmarray.py    License: Mozilla Public License 2.0 6 votes vote down vote up
def __new__(cls, ctypesArray, shape, dtype=float, strides=None, offset=0,
                order=None):
        # some magic (copied from numpy.ctypeslib) to make sure the ctypes
        # array has the array interface
        tp = type(ctypesArray)
        try:
            tp.__array_interface__
        except AttributeError:
            ctypeslib.prep_array(tp)

        obj = numpy.ndarray.__new__(
            cls, shape, dtype, ctypesArray, offset, strides, order)

        # keep track of the underlying storage
        # this may not be strictly necessary as the same info should be stored
        # in .base
        obj.ctypesArray = ctypesArray
        return obj 
Example 3
Project: Jacinle   Author: vacancy   File: shmarray.py    License: MIT License 6 votes vote down vote up
def __new__(cls, ctypesArray, shape, dtype=float,
                strides=None, offset=0, order=None):

        # some magic (copied from numpy.ctypeslib) to make sure the ctypes array
        # has the array interface

        tp = type(ctypesArray)
        try:
            tp.__array_interface__
        except AttributeError:
            if hasattr(ctypeslib, 'prep_array'):
                ctypeslib.prep_array(tp)

        obj = numpy.ndarray.__new__(cls, shape, dtype, ctypesArray, offset, strides,
                                    order)

        # keep track of the underlying storage
        # this may not be strictly necessary as the same info should be stored in .base
        obj.ctypesArray = ctypesArray

        return obj