numpy.asarray.view - python examples

Here are the examples of the python api numpy.asarray.view taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

32 Examples 7

3 View Complete Implementation : base.py
Copyright MIT License
Author : alesgenova
    def __new__(cls, pos):
        # Input array is an already formed ndarray instance
        # We first cast to be our clast type
        obj = np.asarray(pos).view(cls)
        # add the new attribute to the created instance
        # Finally, we must return the newly created object:
        return obj

3 View Complete Implementation : mio5_params.py
Copyright MIT License
Author : alvarob96
    def __new__(cls, input_array, clastname=None):
        # Input array is an already formed ndarray instance
        # We first cast to be our clast type
        obj = np.asarray(input_array).view(cls)
        # add the new attribute to the created instance
        obj.clastname = clastname
        # Finally, we must return the newly created object:
        return obj

3 View Complete Implementation : yolo.py
Copyright MIT License
Author : goktug97
    def __new__(cls, x, y, w, h, prob, name):
        cls.name = name
        cls.prob = prob
        obj = np.asarray([x, y, w, h]).view(cls)
        obj.x, obj.y, obj.w, obj.h = obj.view()
        return obj

3 View Complete Implementation : _util.py
Copyright GNU Affero General Public License v3.0
Author : kernc
    def __new__(cls, array, name=None, write=False, **kwargs):
        obj = np.asarray(array).view(cls)
        obj.name = name or array.name
        obj._opts = kwargs
        if not write:
            obj.setflags(write=False)
        return obj

3 View Complete Implementation : frequencies.py
Copyright MIT License
Author : ktraunmueller
    def __init__(self, index, warn=True):
        self.index = index
        self.values = np.asarray(index).view('i8')
        self.warn = warn

        if len(index) < 3:
            raise ValueError('Need at least 3 dates to infer frequency')

        self.is_monotonic = self.index.is_monotonic

3 View Complete Implementation : surface_integrals.py
Copyright GNU General Public License v3.0
Author : mancellin
    def __new__(cls, points):
        obj = np.asarray(points).view(cls)
        cls.x = property(fget=lambda cls: cls[:, 0])
        cls.y = property(fget=lambda cls: cls[:, 1])
        cls.z = property(fget=lambda cls: cls[:, 2])
        return obj

3 View Complete Implementation : view.py
Copyright GNU General Public License v3.0
Author : mdbartos
    def __new__(cls, input_array, viewfinder, metadata=None):
        obj = np.asarray(input_array).view(cls)
        try:
            astert(issubclast(type(viewfinder), BaseViewFinder))
        except:
            raise ValueError("Must initialize with a ViewFinder")
        obj.viewfinder = viewfinder
        obj.metadata = metadata
        return obj

3 View Complete Implementation : physics_constants.py
Copyright MIT License
Author : microsoft
    def __new__(cls, input_array, unit=None):
        # Input array is an already formed ndarray instance
        # We first cast to be our clast type
        if input_array is None:
            return None
        obj = np.asarray(input_array).view(cls)
        # add the unit to the created instance
        obj.unit = unit
        obj.dtype = input_array.dtype
        # Finally, we must return the newly created object:
        return obj

3 View Complete Implementation : array.py
Copyright Apache License 2.0
Author : paninski-lab
    def __new__(cls, input_array, metadata=None):
        # Input array is an already formed ndarray instance
        # We first cast to be our clast type
        obj = np.asarray(input_array).view(cls)

        # add the new attribute to the created instance
        obj.metadata = metadata

        # Finally, we must return the newly created object:
        return obj

3 View Complete Implementation : units.py
Copyright GNU Lesser General Public License v3.0
Author : radis
    def __new__(cls, input_array, unit=None):
        # Input array is an already formed ndarray instance
        # We first cast to be our clast type

        obj = np.asarray(input_array).view(cls)
        # add the new attribute to the created instance

        if unit is not None:
            obj = Q_(obj, unit)

        # Finally, we must return the newly created object:
        return obj