spatial_graph.dtypes
Classes:
-
DType
–A class to represent a data type in C/C++ and Cython/PYX files.
DType
DType(dtype_str: str)
A class to represent a data type in C/C++ and Cython/PYX files.
Parameters:
-
dtype_str
str
) –The data type string in the format "base_type[size]". The base_type must be one of the valid base types defined in VALID_BASE_TYPES, and size is optional.
Methods:
-
to_c_decl
–Convert this dtype to the equivalent C/C++ declaration with the given name.
-
to_pyxtype
–Convert this dtype to the equivalent PYX type.
-
to_rvalue
–Convert this dtype into an r-value to be used in PYX files for assignments.
Attributes:
-
base_c_type
(str
) –Convert the base of this DType into the equivalent C/C++ type.
Source code in src/spatial_graph/dtypes.py
42 43 44 45 46 |
|
base_c_type
property
base_c_type: str
Convert the base of this DType into the equivalent C/C++ type.
to_c_decl
to_c_decl(name: str) -> str
Convert this dtype to the equivalent C/C++ declaration with the given name.
"base_c_type name" if not an array "base_c_type name[size]" if an array type
Source code in src/spatial_graph/dtypes.py
70 71 72 73 74 75 76 77 78 79 |
|
to_pyxtype
to_pyxtype(
use_memory_view: bool = False, add_dim: bool = False
) -> str
Convert this dtype to the equivalent PYX type.
"base_c_type"
"base_c_type[size]" if an array type
"base_c_type[::1]" if an array type and use_memory_view
"base_c_type[::1]" if not an array type and add_dim
"base_c_type[:, ::1]" if an array type and add_dim
Args:
use_memory_view:
If set, will produce "dtype[::1]" instead of "dtype[dim]" for
array types.
add_dim:
Append a dim to the type, e.g., "int32_t[::1]" instead of
"int32_t" for dtype "int32". If this DType is already an array,
will create a 2D array, e.g., "int32_t[:, ::1]".
Source code in src/spatial_graph/dtypes.py
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
|
to_rvalue
to_rvalue(name: str, array_index: str | None = None) -> str
Convert this dtype into an r-value to be used in PYX files for assignments.
"name" default "name[array_index]" if array_index is given "{name[0], ..., name[size-1]}" if an array type "{name[array_index, 0], ..., name[array_index, size-1]}" if an array type and array_index is given
Source code in src/spatial_graph/dtypes.py
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
|