CFFI interop module¶
NativePointerLike = Union[OwningCffiNativeHandle, CffiNativeHandle, CffiData]
module-attribute
¶
types that can represent time series
CffiMarshal
¶
A helper class for marshalling data to/from a native library module (i.e. DLL)
Source code in cinterop/cffi/marshal.py
901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 | |
nullptr
property
¶
The C NULL pointer
Returns:
| Name | Type | Description |
|---|---|---|
Any |
Any
|
returns FFI.NULL |
as_arrayof_bytes(obj)
¶
as_c_double_array(data, shallow=False)
¶
as_character_vector(obj)
¶
Convert a list of "strings" to a character_vector* native struct
as_charptr(x, wrap=False)
¶
convert an object to bytes, create as C array of char and copy values to it. Equivalent to char arg[] = "world" if x is the bytes b"world"
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
str
|
a string-like object; bytes or str, or string like object that can be encoded to bytes (six.string_like) |
required |
wrap
|
bool
|
return a "naked" cdata pointer object if False, or wrapped in a |
False
|
Returns:
| Type | Description |
|---|---|
CffiData
|
Union[OwningCffiNativeHandle,CffiData]: a (wrapper to a) cdata pointer object owning a new array of |
Source code in cinterop/cffi/marshal.py
as_datetime(ptr)
¶
Convert if possible a cffi pointer to a C date_time_to_second struct, into a datetime
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ptr
|
CffiData
|
cffi pointer (FFI.CData) |
required |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
conversion is not supported |
Returns:
| Name | Type | Description |
|---|---|---|
datetime |
datetime
|
converted data |
Source code in cinterop/cffi/marshal.py
as_native_time_series(data)
¶
as_native_tsgeom(tsgeom)
¶
C-compatible representation of a time series geometry
Returns:
| Name | Type | Description |
|---|---|---|
TimeSeriesGeometryNative |
TimeSeriesGeometryNative
|
wrapper around a cdata pointer to a new C struct |
Source code in cinterop/cffi/marshal.py
as_np_array_double(ptr, size, shallow=False)
¶
Convert if possible a cffi pointer to a C data array, into a numpy array of double precision floats double[n].
The returned numpy array may be directly pointing to the original data (faster performance), or a deep copy (memory safety - "normal" numpy array)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ptr
|
CffiData
|
cffi pointer (FFI.CData) |
required |
size
|
int
|
array size |
required |
shallow
|
bool
|
If True the resulting numpy array points directly to the native data array. |
False
|
Raises:
| Type | Description |
|---|---|
RuntimeError
|
conversion is not supported |
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: converted data |
Source code in cinterop/cffi/marshal.py
as_numeric_np_array(ptr, size, shallow=False)
¶
Convert if possible a cffi pointer to a C data array, into a numpy array.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ptr
|
CffiData
|
cffi pointer (FFI.CData) |
required |
size
|
int
|
array size |
required |
shallow
|
bool
|
If true the array points directly to native data array. Defaults to False. |
False
|
Raises:
| Type | Description |
|---|---|
RuntimeError
|
conversion is not supported |
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: converted data |
Source code in cinterop/cffi/marshal.py
as_xarray_time_series(ptr)
¶
c_charptrptr_as_string_list(ptr, size)
¶
Convert if possible a cffi pointer to a C data array char** , into a list of python strings.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ptr
|
CffiData
|
cffi pointer (FFI.CData) |
required |
size
|
int
|
number of character strings in the char** pointer |
required |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
conversion is not supported |
Returns:
| Type | Description |
|---|---|
List[str]
|
List[str]: converted data |
Source code in cinterop/cffi/marshal.py
c_string_as_py_string(ptr)
¶
Convert if possible a cffi pointer to an ANSI C string
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ptr
|
CffiData
|
cffi pointer (FFI.CData) |
required |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
conversion is not supported |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
converted string |
Source code in cinterop/cffi/marshal.py
character_vector_as_string_list(ptr)
¶
Convert if possible a cffi pointer to a C character_vector , into a list of python strings.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ptr
|
CffiData
|
cffi pointer (FFI.CData) |
required |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
conversion is not supported |
Returns:
| Type | Description |
|---|---|
List[str]
|
List[str]: converted data |
Source code in cinterop/cffi/marshal.py
create_values_struct(data)
¶
datetime_to_dtts(dt)
¶
dict_to_named_values(data)
¶
Convert a dictionary to a cffi pointer to a named_values_vector struct
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Dict[str, float]
|
mapping from keys to numeric values |
required |
Returns:
| Name | Type | Description |
|---|---|---|
OwningCffiNativeHandle |
OwningCffiNativeHandle
|
A wrapper that owns the memory allocated for the resulting |
Source code in cinterop/cffi/marshal.py
dict_to_string_map(data)
¶
get_native_tsgeom(pd_series)
¶
named_values_to_dict(ptr)
¶
Convert if possible a cffi pointer to a named_values_vector struct, into a dictionary
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ptr
|
CffiData
|
cffi pointer (FFI.CData) to a |
required |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
conversion is not supported |
Returns:
| Type | Description |
|---|---|
Dict[str, float]
|
Dict[str,float]: converted data |
Source code in cinterop/cffi/marshal.py
new_charptr_array(size, wrap=False)
¶
new_ctype_array(ctype, size, wrap=False)
¶
new_date_time_to_second()
¶
new_double_array(size, wrap=False)
¶
new_doubleptr_array(size, wrap=False)
¶
new_int_array(size, wrap=False)
¶
Creates a new C array of integers int[n]
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
size
|
int
|
array size |
required |
wrap
|
bool
|
return a "naked" cdata pointer object if False, or wrapped in a |
False
|
Returns:
| Type | Description |
|---|---|
Union[OwningCffiNativeHandle, CffiData]
|
Union[OwningCffiNativeHandle,CffiData]: a (wrapper to a) cdata pointer object owning a new array of integers of length |
Source code in cinterop/cffi/marshal.py
new_int_scalar_ptr(value=0)
¶
Creates a new C array of integers
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
int
|
description. Defaults to 0. |
0
|
Returns:
| Name | Type | Description |
|---|---|---|
CffiData |
CffiData
|
a cdata pointer object owning a new pointer to a single integer valued as specified. |
Source code in cinterop/cffi/marshal.py
new_native_struct(type)
¶
new_native_tsgeom()
¶
string_map_to_dict(ptr)
¶
Convert if possible a cffi pointer to a string_string_map struct, into a dictionary
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ptr
|
CffiData
|
cffi pointer (FFI.CData) to a |
required |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
conversion is not supported |
Returns:
| Type | Description |
|---|---|
Dict[str, str]
|
Dict[str,str]: converted data |
Source code in cinterop/cffi/marshal.py
two_d_as_np_array_double(ptr, nrow, ncol)
¶
Convert if possible a cffi pointer to a C data array, into a numpy array of double precision floats.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ptr
|
CffiData
|
cffi pointer (FFI.CData) |
required |
nrow
|
int
|
number of rows |
required |
ncol
|
int
|
number of columns |
required |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
conversion is not supported |
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: converted data |
Source code in cinterop/cffi/marshal.py
two_d_np_array_double_to_native(data)
¶
values_to_nparray(ptr)
¶
Convert if possible a cffi pointer to a values_vector struct, into a python array
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ptr
|
CffiData
|
cffi pointer (FFI.CData) to a |
required |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
conversion is not supported |
Returns:
| Type | Description |
|---|---|
ndarray
|
Dict[str,float]: converted data |
Source code in cinterop/cffi/marshal.py
TimeSeriesGeometry
¶
Simplified representation of the temporal geometry of a time series.
Suitable for interop with the C struct regular_time_series_geometry
Source code in cinterop/cffi/marshal.py
__init__(start=None, time_step_seconds=3600, length=1, time_step_code=0)
¶
Simplified representation of the temporal geometry of a time series.
Suitable for interop with the C struct regular_time_series_geometry
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
start
|
ConvertibleToTimestamp
|
Start date of a time series. Defaults to None. |
None
|
time_step_seconds
|
int
|
time step length in seconds, used if this is a regular time step. Defaults to 3600. |
3600
|
length
|
int
|
number of items in the time series. Defaults to 1. |
1
|
time_step_code
|
int
|
type of time step: 0 for even time steps, or 1 for monthly, in which case |
0
|
Source code in cinterop/cffi/marshal.py
as_native(ffi)
¶
C-compatible representation of a time series geometry
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ffi
|
FFI
|
FFI instance wrapping the native compilation module owning the native memory |
required |
Returns:
| Name | Type | Description |
|---|---|---|
TimeSeriesGeometryNative |
TimeSeriesGeometryNative
|
wrapper around a cdata pointer to a new C struct |
Source code in cinterop/cffi/marshal.py
TimeSeriesGeometryNative
¶
Bases: OwningCffiNativeHandle
Wrapper around a cdata pointer to a new C struct regular_time_series_geometry
Source code in cinterop/cffi/marshal.py
__init__(ffi, start=None, time_step_seconds=3600, length=1, time_step_code=0)
¶
Wrapper around a cdata pointer to a new C struct regular_time_series_geometry
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ffi
|
Union[FFI, CffiData]
|
FFI instance, or a preexisting cdata pointer to a |
required |
start
|
ConvertibleToTimestamp
|
Start date of a time series. Defaults to None. |
None
|
time_step_seconds
|
int
|
time step length in seconds, used if this is a regular time step. Defaults to 3600. |
3600
|
length
|
int
|
number of items in the time series. Defaults to 1. |
1
|
time_step_code
|
int
|
type of time step: 0 for even time steps, or 1 for monthly, in which case |
0
|
Source code in cinterop/cffi/marshal.py
as_arrayof_bytes(ffi, obj)
¶
Convert a list of "strings" to a char** like C array
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
List
|
list of objects (strings) to convert |
required |
Returns:
| Name | Type | Description |
|---|---|---|
List |
OwningCffiNativeHandle
|
objects converted to bytes if it was a type of string |
Source code in cinterop/cffi/marshal.py
as_bytes(obj)
¶
Convert obj to bytes if it is a string type
Mostly a legacy for python⅔ compatibility.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
Any
|
object to convert |
required |
Returns:
| Type | Description |
|---|---|
Union[bytes, Any]
|
Union[bytes, Any]: object converted to bytes if it was a type of string |
Source code in cinterop/cffi/marshal.py
as_character_vector(ffi, obj)
¶
Convert a list of "strings" to a character_vector* native struct
Source code in cinterop/cffi/marshal.py
as_charptr(ffi, x, wrap=False)
¶
convert an object to bytes, create as C array of char and copy values to it. Equivalent to char arg[] = "world" if x is the bytes b"world"
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ffi
|
FFI
|
ffi object to the native library accessed |
required |
x
|
str
|
a string-like object; bytes or str, or string like object that can be encoded to bytes (six.string_like) |
required |
wrap
|
bool
|
return a "naked" cdata pointer object if False, or wrapped in a |
False
|
Returns:
| Type | Description |
|---|---|
Union[OwningCffiNativeHandle, CffiData]
|
Union[OwningCffiNativeHandle,CffiData]: a (wrapper to a) cdata pointer object owning a new array of |
Source code in cinterop/cffi/marshal.py
as_native_time_series(ffi, data)
¶
Convert a pure python time series to a native representation via a C struct multi_regular_time_series_data
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ffi
|
FFI
|
description |
required |
data
|
TimeSeriesLike
|
xarray or pandas based time series |
required |
Raises:
| Type | Description |
|---|---|
TypeError
|
unexpected input type |
Returns:
| Name | Type | Description |
|---|---|---|
OwningCffiNativeHandle |
OwningCffiNativeHandle
|
wrapper to a C struct |
Source code in cinterop/cffi/marshal.py
as_native_tsgeom(ffi, tsgeom)
¶
convert a simlified time series geometry to a native representation
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ffi
|
Union[FFI, CffiData]
|
FFI instance, or a preexisting cdata pointer to a |
required |
tsgeom
|
TimeSeriesGeometry
|
simplified representation |
required |
Returns:
| Name | Type | Description |
|---|---|---|
TimeSeriesGeometryNative |
TimeSeriesGeometryNative
|
Wrapper around a cdata pointer to a new C struct |
Source code in cinterop/cffi/marshal.py
as_np_array_double(ffi, ptr, size, shallow=False)
¶
Convert if possible a cffi pointer to a C data array, into a numpy array of double precision floats double[n].
The returned numpy array may be directly pointing to the original data (faster performance), or a deep copy (memory safety - "normal" numpy array)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ffi
|
FFI
|
FFI instance wrapping the native compilation module owning the native memory |
required |
ptr
|
CffiData
|
cffi pointer (FFI.CData) |
required |
size
|
int
|
array size |
required |
shallow
|
bool
|
If True the resulting numpy array points directly to the native data array. |
False
|
Raises:
| Type | Description |
|---|---|
RuntimeError
|
conversion is not supported |
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: converted data |
Source code in cinterop/cffi/marshal.py
as_numeric_np_array(ffi, ptr, size, shallow=False)
¶
Convert if possible a cffi pointer to a C data array, into a numpy array.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ffi
|
FFI
|
FFI instance wrapping the native compilation module owning the native memory |
required |
ptr
|
CffiData
|
cffi pointer (FFI.CData) |
required |
size
|
int
|
array size |
required |
shallow
|
bool
|
If true the array points directly to native data array. Defaults to False. |
False
|
Raises:
| Type | Description |
|---|---|
TypeError
|
conversion is not supported |
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: converted data |
Source code in cinterop/cffi/marshal.py
as_string(obj)
¶
Convert obj to string/unicode if it is a bytes object.
Mostly a legacy for python⅔ compatibility.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
Any
|
object to convert |
required |
Returns:
| Type | Description |
|---|---|
Union[str, Any]
|
Union[str, Any]: result converted (or not) to unicode string |
Source code in cinterop/cffi/marshal.py
as_xarray_time_series(ffi, ptr, name=None, allow_empty=True)
¶
Converts a native time series structure to an xarray representation
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ffi
|
FFI
|
ffi object to the library |
required |
ptr
|
CffiData
|
pointer to the native struct |
required |
name
|
str
|
name of the returned series. Defaults to None. |
None
|
Returns:
| Type | Description |
|---|---|
Optional[DataArray]
|
xr.DataArray: xarray time series |
Source code in cinterop/cffi/marshal.py
c_charptrptr_as_string_list(ffi, ptr, size)
¶
Convert if possible a cffi pointer to a C data array char** , into a list of python strings.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ffi
|
FFI
|
FFI instance wrapping the native compilation module owning the native memory |
required |
ptr
|
CffiData
|
cffi pointer (FFI.CData) |
required |
size
|
int
|
number of character strings in the char** pointer |
required |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
conversion is not supported |
Returns:
| Type | Description |
|---|---|
List[str]
|
List[str]: converted data |
Source code in cinterop/cffi/marshal.py
c_string_as_py_string(ffi, ptr)
¶
Convert if possible a cffi pointer to an ANSI C string
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ffi
|
FFI
|
FFI instance wrapping the native compilation module owning the native memory |
required |
ptr
|
CffiData
|
cffi pointer (FFI.CData) |
required |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
conversion is not supported |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
converted string |
Source code in cinterop/cffi/marshal.py
convert_strings(func)
¶
Returns a wrapper that converts any str/unicode object arguments to bytes.
Source code in cinterop/cffi/marshal.py
create_values_struct(ffi, data)
¶
create_values_struct
Source code in cinterop/cffi/marshal.py
datetime_to_dtts(ffi, dt)
¶
dict_to_named_values(ffi, data)
¶
Convert a dictionary to a cffi pointer to a named_values_vector struct
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ffi
|
FFI
|
FFI instance wrapping the native compilation module owning the native memory |
required |
data
|
Dict[str, float]
|
mapping from keys to numeric values |
required |
Returns:
| Name | Type | Description |
|---|---|---|
OwningCffiNativeHandle |
OwningCffiNativeHandle
|
A wrapper that owns the memory allocated for the resulting |
Source code in cinterop/cffi/marshal.py
dict_to_string_map(ffi, data)
¶
Convert a dictionary to a cffi pointer to a string_string_map struct
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ffi
|
FFI
|
FFI instance wrapping the native compilation module owning the native memory |
required |
data
|
Dict[str, float]
|
mapping from keys to (str) values |
required |
Returns:
| Name | Type | Description |
|---|---|---|
OwningCffiNativeHandle |
OwningCffiNativeHandle
|
A wrapper that owns the memory allocated for the resulting |
Source code in cinterop/cffi/marshal.py
dtts_as_datetime(ptr)
¶
Convert if possible a cffi pointer to a C data array char** , into a list of python strings.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ptr
|
CffiData
|
cffi pointer (FFI.CData) |
required |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
conversion is not supported |
Returns:
| Name | Type | Description |
|---|---|---|
datetime |
datetime
|
converted data |
Source code in cinterop/cffi/marshal.py
geom_to_xarray_time_series(ts_geom, data, name=None)
¶
Converts an native time series structure to an xarray representation
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ts_geom
|
TimeSeriesGeometryNative
|
time series geometry |
required |
data
|
ndarray
|
time series data, with one dimension |
required |
name
|
str
|
name of the returned series. Defaults to None. |
None
|
Returns:
| Type | Description |
|---|---|
DataArray
|
xr.DataArray: xarray time series |
Source code in cinterop/cffi/marshal.py
get_tsgeom(data)
¶
Extract a simplified representation of the geometry of a time series. A simple heuristic is used to find the time step
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
TimeSeriesLike
|
A pandas or xarray representation of a time series, with the pandas index or "time" dimension expected. |
required |
Raises:
| Type | Description |
|---|---|
TypeError
|
Unexpected type of data |
Returns:
| Name | Type | Description |
|---|---|---|
TimeSeriesGeometry |
TimeSeriesGeometry
|
simplified time series geometry |
Source code in cinterop/cffi/marshal.py
named_values_to_dict(ffi, ptr)
¶
Convert if possible a cffi pointer to a named_values_vector struct, into a dictionary
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ffi
|
FFI
|
FFI instance wrapping the native compilation module owning the native memory |
required |
ptr
|
CffiData
|
cffi pointer (FFI.CData) to a |
required |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
conversion is not supported |
Returns:
| Type | Description |
|---|---|
Dict[str, float]
|
Dict[str,float]: converted data |
Source code in cinterop/cffi/marshal.py
new_charptr_array(ffi, size, wrap=False)
¶
Creates a new C array of pointers to char: char*[n]
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ffi
|
FFI
|
ffi object to the native library accessed |
required |
size
|
int
|
array size |
required |
wrap
|
bool
|
return a "naked" cdata pointer object if False, or wrapped in a |
False
|
Returns:
| Type | Description |
|---|---|
Union[OwningCffiNativeHandle, CffiData]
|
Union[OwningCffiNativeHandle,CffiData]: a (wrapper to a) cdata pointer object owning a new array of |
Source code in cinterop/cffi/marshal.py
new_ctype_array(ffi, ctype, size, wrap=False)
¶
summary
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ffi
|
FFI
|
ffi object to the native library accessed |
required |
ctype
|
str
|
valid C type for array creation |
required |
size
|
int
|
array size |
required |
wrap
|
bool
|
return a "naked" cdata pointer object if False, or wrapped in a |
False
|
Returns:
| Type | Description |
|---|---|
Union[OwningCffiNativeHandle, CffiData]
|
Union[OwningCffiNativeHandle,CffiData]: cdata pointer or wrapper to it. |
Source code in cinterop/cffi/marshal.py
new_date_time_to_second(ffi)
¶
new_double_array(ffi, size, wrap=False)
¶
Creates a new C array of double precision floats double[n]
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ffi
|
FFI
|
ffi object to the native library accessed |
required |
size
|
int
|
array size |
required |
wrap
|
bool
|
return a "naked" cdata pointer object if False, or wrapped in a |
False
|
Returns:
| Type | Description |
|---|---|
Union[OwningCffiNativeHandle, CffiData]
|
Union[OwningCffiNativeHandle,CffiData]: a (wrapper to a) cdata pointer object owning a new array of |
Source code in cinterop/cffi/marshal.py
new_doubleptr_array(ffi, size, wrap=False)
¶
Creates a new C array of pointers to double precision floats double*[n]
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ffi
|
FFI
|
ffi object to the native library accessed |
required |
size
|
int
|
array size |
required |
wrap
|
bool
|
return a "naked" cdata pointer object if False, or wrapped in a |
False
|
Returns:
| Type | Description |
|---|---|
Union[OwningCffiNativeHandle, CffiData]
|
Union[OwningCffiNativeHandle,CffiData]: a (wrapper to a) cdata pointer object owning a new array of |
Source code in cinterop/cffi/marshal.py
new_int_array(ffi, size, wrap=False)
¶
Creates a new C array of integers int[n]
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ffi
|
FFI
|
ffi object to the native library accessed |
required |
size
|
int
|
array size |
required |
wrap
|
bool
|
return a "naked" cdata pointer object if False, or wrapped in a |
False
|
Returns:
| Type | Description |
|---|---|
Union[OwningCffiNativeHandle, CffiData]
|
Union[OwningCffiNativeHandle,CffiData]: a (wrapper to a) cdata pointer object owning a new array of integers of length |
Source code in cinterop/cffi/marshal.py
new_int_scalar_ptr(ffi, value=0)
¶
Creates a new C array of integers
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ffi
|
FFI
|
ffi object to the native library accessed |
required |
value
|
int
|
description. Defaults to 0. |
0
|
Returns:
| Name | Type | Description |
|---|---|---|
CffiData |
CffiData
|
a cdata pointer object owning a new pointer to a single integer valued as specified. |
Source code in cinterop/cffi/marshal.py
string_map_to_dict(ffi, ptr)
¶
Convert if possible a cffi pointer to a string_string_map struct, into a dictionary
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ffi
|
FFI
|
FFI instance wrapping the native compilation module owning the native memory |
required |
ptr
|
CffiData
|
cffi pointer (FFI.CData) to a |
required |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
conversion is not supported |
Returns:
| Type | Description |
|---|---|
Dict[str, str]
|
Dict[str,str]: converted data |
Source code in cinterop/cffi/marshal.py
two_d_as_np_array_double(ffi, ptr, nrow, ncol)
¶
Convert if possible a cffi pointer to a C data array, into a numpy array of double precision floats.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ffi
|
FFI
|
FFI instance wrapping the native compilation module owning the native memory |
required |
ptr
|
CffiData
|
cffi pointer (FFI.CData) |
required |
nrow
|
int
|
number of rows |
required |
ncol
|
int
|
number of columns |
required |
shallow
|
bool
|
If true the array points directly to native data array. Defaults to False. |
required |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
conversion is not supported |
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: converted data |
Source code in cinterop/cffi/marshal.py
two_d_np_array_double_to_native(ffi, data)
¶
Convert if possible a cffi pointer to a C data array, into a numpy array of double precision floats.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ffi
|
FFI
|
FFI instance wrapping the native compilation module owning the native memory |
required |
data
|
ndarray
|
data |
required |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
conversion is not supported |
Returns:
| Type | Description |
|---|---|
OwningCffiNativeHandle
|
np.ndarray: converted data |
Source code in cinterop/cffi/marshal.py
values_to_nparray(ffi, ptr)
¶
Convert if possible a cffi pointer to a values_vector struct, into a python array
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ffi
|
FFI
|
FFI instance wrapping the native compilation module owning the native memory |
required |
ptr
|
CffiData
|
cffi pointer (FFI.CData) to a |
required |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
conversion is not supported |
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: converted data |