Compatibility with ctypes.
        Allows passing transparently a Point object to an API call.
345553
def _as_parameter_(self):
        
        return RECT(self.left, self.top, self.right, self.bottom)
1191256
def ctypes2numpy(cptr, length, dtype):
    
    NUMPY_TO_CTYPES_MAPPING = {
        np.float32: ctypes.c_float,
        np.uint32: ctypes.c_uint,
    }
    if dtype not in NUMPY_TO_CTYPES_MAPPING:
        raise RuntimeError('Supported types: {}'.format(NUMPY_TO_CTYPES_MAPPING.keys()))
    ctype = NUMPY_TO_CTYPES_MAPPING[dtype]
    if not isinstance(cptr, ctypes.POINTER(ctype)):
        raise RuntimeError('expected {} pointer'.format(ctype))
    res = np.zeros(length, dtype=dtype)
    if not ctypes.memmove(res.ctypes.data, cptr, length * res.strides[0]):
        raise RuntimeError('memmove failed')
    return res
1147776
def from_dict(cls, ctx):
        ''
        ctx = Context(ctx)
        s = cls()
        ContextFlags = ctx['ContextFlags']
        setattr(s, 'ContextFlags', ContextFlags)
        if (ContextFlags & CONTEXT_DEBUG_REGISTERS) == CONTEXT_DEBUG_REGISTERS:
            for key in s._ctx_debug:
                setattr(s, key, ctx[key])
        if (ContextFlags & CONTEXT_FLOATING_POINT) == CONTEXT_FLOATING_POINT:
            fsa = ctx['FloatSave']
            s.FloatSave = FLOATING_SAVE_AREA.from_dict(fsa)
        if (ContextFlags & CONTEXT_SEGMENTS) == CONTEXT_SEGMENTS:
            for key in s._ctx_segs:
                setattr(s, key, ctx[key])
        if (ContextFlags & CONTEXT_INTEGER) == CONTEXT_INTEGER:
            for key in s._ctx_int:
                setattr(s, key, ctx[key])
        if (ContextFlags & CONTEXT_CONTROL) == CONTEXT_CONTROL:
            for key in s._ctx_ctrl:
                setattr(s, key, ctx[key])
        if (ContextFlags & CONTEXT_EXTENDED_REGISTERS) == CONTEXT_EXTENDED_REGISTERS:
            er = ctx['ExtendedRegisters']
            for index in compat.xrange(0, MAXIMUM_SUPPORTED_EXTENSION):
                s.ExtendedRegisters[index] = er[index]
        return s
542303
def point_to_t(self, point):
        """"""

        # Single-precision floats have only 7 significant figures of
        # resolution, so test that we're within 6 sig figs.
        if np.isclose(point, self.start, rtol=0, atol=1e-6):
            return 0.0
        elif np.isclose(point, self.end, rtol=0, atol=1e-6):
            return 1.0

        # Finding the point "by hand" here is much faster than calling
        # radialrange(), see the discussion on PR #40:
        # https://github.com/mathandy/svgpathtools/pull/40#issuecomment-358134261

        p = self.poly()
        # p(t) = (p_1 * t) + p_0 = point
        # t = (point - p_0) / p_1
        t = (point - p[0]) / p[1]
        if np.isclose(t.imag, 0) and (t.real >= 0.0) and (t.real <= 1.0):
            return t.real
        return None
1076690
def multipointm(self, points):
        """"""
        shapeType = MULTIPOINTM
        points = [points] # nest the points inside a list to be compatible with the generic shapeparts method
        self._shapeparts(parts=points, shapeType=shapeType)
1267565
def _ctypes_regular(parameter):
    
    if ("pointer" in parameter.modifiers or "allocatable" in parameter.modifiers
        or "target" in parameter.modifiers or parameter.dtype == "logical"):
        return (parameter.definition(local=True), False)
36690
def WrapCFTypeInPython(self, obj):
    
    obj_type = self.dll.CFGetTypeID(obj)
    if obj_type == self.dll.CFBooleanGetTypeID():
      return CFBoolean(obj)
    elif obj_type == self.dll.CFNumberGetTypeID():
      return CFNumber(obj)
    elif obj_type == self.dll.CFStringGetTypeID():
      return CFString(obj)
    elif obj_type == self.dll.CFDictionaryGetTypeID():
      return CFDictionary(obj)
    elif obj_type == self.dll.CFArrayGetTypeID():
      return CFArray(obj)
    else:
      raise TypeError('Unknown type for object: {0}'.format(obj))
558862
def dimod_object_hook(obj):
    
    if _is_sampleset_v2(obj):
        # in the future we could handle subtypes but right now we just have the
        # one
        return SampleSet.from_serializable(obj)
    elif _is_bqm_v2(obj):
        # in the future we could handle subtypes but right now we just have the
        # one
        return BinaryQuadraticModel.from_serializable(obj)
    return obj
494902
def get_ptr(data, offset=None, ptr_type=ctypes.c_void_p):
    """"""
    ptr = ctypes.cast(ctypes.pointer(data), ctypes.c_void_p)

    if offset:
        ptr = ctypes.c_void_p(ptr.value + offset)

    if ptr_type != ctypes.c_void_p:
        ptr = ctypes.cast(ptr, ptr_type)

    return ptr
500480
def point_type(name, fields, srid_map):
    

    def srid(self):
        try:
            return srid_map[len(self)]
        except KeyError:
            return None

    attributes = {"srid": property(srid)}

    for index, subclass_field in enumerate(fields):

        def accessor(self, i=index, f=subclass_field):
            try:
                return self[i]
            except IndexError:
                raise AttributeError(f)

        for field_alias in {subclass_field, "xyz"[index]}:
            attributes[field_alias] = property(accessor)

    cls = type(name, (Point,), attributes)

    with __srid_table_lock:
        for dim, srid in srid_map.items():
            __srid_table[srid] = (cls, dim)

    return cls
786581
def _Constructor(cls, ptr=_internal_guard):
    
    if ptr == _internal_guard:
        raise VLCException("(INTERNAL) ctypes class. You should get references for this class through methods of the LibVLC API.")
    if ptr is None or ptr == 0:
        return None
    return _Cobject(cls, ctypes.c_void_p(ptr))
698679
def _py_pytype(parameter):
    
    pytype = parameter.pytype
    if pytype is None:
        raise ValueError("Can't pre-determine type for parameter: {}".format(parameter.definition()))
    return pytype
812030
def shape(self):
        """"""

        # Create C variables that will serve as out parameters for TCMPS.
        shape_ptr = _ctypes.POINTER(_ctypes.c_size_t)()  # size_t* shape_ptr
        dim = _ctypes.c_size_t()                         # size_t dim

        # Obtain pointer into memory owned by the C++ object self.handle.
        status_code = self._LIB.TCMPSGetFloatArrayShape(
            self.handle, _ctypes.byref(shape_ptr), _ctypes.byref(dim))
        assert status_code == 0, "Error calling TCMPSGetFloatArrayShape"

        return _shape_tuple_from_ctypes(shape_ptr, dim)
630132
def pass_obj(f):
    
    def new_func(*args, **kwargs):
        return f(get_current_context().obj, *args, **kwargs)
    return update_wrapper(new_func, f)
306384
def _appendBPoint(self, type, anchor, bcpIn=None, bcpOut=None, **kwargs):
        
        self.insertBPoint(
            len(self.bPoints),
            type,
            anchor,
            bcpIn=bcpIn,
            bcpOut=bcpOut
        )
20689
def _ctypes_code_parameter(lines, parameter, position):
    
    mdict = {
        'indices': _ctypes_indices,
        'variable': _ctypes_variables,
        'out': _ctypes_out,
        'regular': _ctypes_regular,
        'saved': _ctypes_saved,
        'assign': _ctypes_assign,
        'clean': _ctypes_clean
    }
    line = mdict[position](parameter)
    if line is not None:
        value, blank = line
        lines.append(value)
        if blank:
            lines.append("")
319679
def point(cls):  # No range because it's unknown at this time.
    """"""
    def factory(i, name):
      return cls(i, name, (0, 0), lambda a: point.Point(*a).floor(), None)
    return factory