File: carray.pxd.mako

package info (click to toggle)
cyarray 1.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 452 kB
  • sloc: python: 768; makefile: 15
file content (93 lines) | stat: -rw-r--r-- 3,357 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<%
type_info = [
    ('int', 'IntArray', 'NPY_INT'),
    ('unsigned int', 'UIntArray', 'NPY_UINT'),
    ('long', 'LongArray', 'NPY_LONG'),
    ('float', 'FloatArray', 'NPY_FLOAT'),
    ('double', 'DoubleArray', 'NPY_DOUBLE'),
]
%># This file (carray.pxd) has been generated automatically.
# DO NOT modify this file
# To make changes modify the source templates (carray.pxd.mako) and regenerate
#cython: language_level=3
"""
Implementation of resizable arrays of different types in Cython.

Declaration File.

"""

# numpy import
cimport numpy as np

cdef long aligned(long n, int item_size) noexcept nogil
cdef void* aligned_malloc(size_t bytes) noexcept nogil
cdef void* aligned_realloc(void* existing, size_t bytes, size_t old_size) noexcept nogil
cdef void aligned_free(void* p) noexcept nogil

# forward declaration
cdef class BaseArray
cdef class LongArray(BaseArray)

cdef class BaseArrayIter:
    cdef BaseArray arr
    cdef long i

cdef class BaseArray:
    """Base class for managed C-arrays."""
    cdef public long length, alloc
    cdef np.ndarray _npy_array

    cdef void c_align_array(self, LongArray new_indices, int stride=*) noexcept nogil
    cdef void c_reserve(self, long size) noexcept nogil
    cdef void c_reset(self) noexcept nogil
    cdef void c_resize(self, long size) noexcept nogil
    cdef void c_squeeze(self) noexcept nogil

    cpdef reserve(self, long size)
    cpdef resize(self, long size)
    cpdef np.ndarray get_npy_array(self)
    cpdef set_data(self, np.ndarray)
    cpdef squeeze(self)
    cpdef remove(self, np.ndarray index_list, bint input_sorted=*, int stride=*)
    cpdef extend(self, np.ndarray in_array)
    cpdef reset(self)

    cpdef align_array(self, LongArray new_indices, int stride=*)
    cpdef str get_c_type(self)
    cpdef copy_values(self, LongArray indices, BaseArray dest, int stride=*, int start=*)
    cpdef copy_subset(self, BaseArray source, long start_index=*, long end_index=*, int stride=*)
    cpdef update_min_max(self)

% for ARRAY_TYPE, CLASSNAME, NUMPY_TYPENAME in type_info:
# ###########################################################################
# `${CLASSNAME}` class.
# ###########################################################################
cdef class ${CLASSNAME}(BaseArray):
    """This class defines a managed array of ${ARRAY_TYPE}s. """
    cdef ${ARRAY_TYPE} *data
    cdef ${ARRAY_TYPE} *_old_data
    cdef public ${ARRAY_TYPE} minimum, maximum
    cdef ${CLASSNAME} _parent

    cdef _setup_npy_array(self)
    cdef void c_align_array(self, LongArray new_indices, int stride=*) noexcept nogil
    cdef void c_append(self, ${ARRAY_TYPE} value) noexcept nogil
    cdef void c_set_view(self, ${ARRAY_TYPE} *array, long length) noexcept nogil
    cdef ${ARRAY_TYPE}* get_data_ptr(self)

    cpdef ${ARRAY_TYPE} get(self, long idx)
    cpdef set(self, long idx, ${ARRAY_TYPE} value)
    cpdef append(self, ${ARRAY_TYPE} value)
    cpdef reserve(self, long size)
    cpdef resize(self, long size)
    cpdef np.ndarray get_npy_array(self)
    cpdef set_data(self, np.ndarray)
    cpdef set_view(self, ${CLASSNAME}, long start, long end)
    cpdef squeeze(self)
    cpdef remove(self, np.ndarray index_list, bint input_sorted=*, int stride=*)
    cpdef extend(self, np.ndarray in_array)
    cpdef reset(self)
    cpdef long index(self, ${ARRAY_TYPE} value)

% endfor