routing.core.functions#
Base file for storing all useful functions.
- class routing.core.functions.CompressedArray(data: bytes, shape: tuple, dtype: dtype)[source]#
Bases:
objectA compressed numpy array using zlib.
- data: bytes#
- dtype: dtype#
- property nbytes: int#
Return compressed size in bytes.
- shape: tuple#
- routing.core.functions.box_window(bounds: dict[str, tuple[int, int]]) tuple[slice, slice, slice][source]#
Index slices for the inclusive box
bounds(per-axis(lowest, highest)), to be applied to any grid-shaped array.
- routing.core.functions.build_frame_from_vector(node: ndarray, vector: ndarray) ndarray[source]#
Build a standard default frame from origin node and main axis vector.
- routing.core.functions.build_frame_vectorized(node: ndarray, next_node: ndarray) ndarray[source]#
Build a standard default frame from two points.
- routing.core.functions.clipped_grid_window(lower: ndarray, upper: ndarray, grid_shape: ndarray) tuple[slice, slice, slice][source]#
Index slices for
[lower, upper)trimmed togrid_shape; empty slices when the box misses the grid.
- routing.core.functions.cluster_points(points: list[ndarray], tolerance: float) list[ndarray][source]#
Greedily cluster points lying within
toleranceof an existing cluster member; one centroid per cluster.
- routing.core.functions.compress_array(array: ndarray | CompressedArray | None) CompressedArray | None[source]#
Compress a numpy array using zlib compression.
- routing.core.functions.csv_to_dicts(path: str) list[dict][source]#
Read a CSV file into a list of dicts, parsing numeric values and skipping empty cells.
- routing.core.functions.cylinder_bounding_box(start: ndarray, end: ndarray, radius: float) ndarray[source]#
Get the bounding box of a cylinder.
- routing.core.functions.from_bounding_rectangles(bounding_rectangles: list[BoundingRectangle], name: str = '') BoundingRectangle[source]#
Bounding rectangle enclosing all
bounding_rectangles.
- routing.core.functions.get_bounding_rectangle(center: tuple[float, float], radius: float) BoundingRectangle[source]#
Bounding rectangle of the circle of given
centerandradius.
- routing.core.functions.get_crossed_voxels(weights: ndarray, node1: tuple[int, int, int], node2: tuple[int, int, int]) ndarray[source]#
Voxels crossed by the
node1-node2segment,node1first.
- routing.core.functions.get_direction(start: ndarray, end: ndarray) tuple[ndarray, float, ndarray][source]#
Get vector, length and unit_vector of a vector defined with start and end points.
- routing.core.functions.grid_index_bounds(origin: tuple[float, float, float], shape: tuple[int, int, int], voxel_size: float, parent_origin: tuple[float, float, float], parent_voxel_size: float) dict[str, tuple[int, int]][source]#
Inclusive index box a grid spans, expressed in a coarser parent grid’s indices.
Both extreme voxel centres are rounded onto the parent grid, so the two voxel sizes need not divide one another — unlike
RoutingVoxelization.nesting_in(), which requires a whole block.
- routing.core.functions.grid_window(lower: ndarray, upper: ndarray) tuple[slice, slice, slice][source]#
Index slices for the half-open box
[lower, upper), to be applied to any grid-shaped array.
- routing.core.functions.h_coord(coords: ndarray) ndarray[source]#
Convert coordinates to homogeneous coordinates by adding a row of ones.
- routing.core.functions.index_sphere(radius: float) ndarray[source]#
Boolean cube marking the index offsets no further than
radiusvoxels from its centre.The lattice ball a halo grows by:
radius0 is the centre alone, 1 the six face neighbours (the diagonals are atsqrt(2)), 2 reaches the second cardinal ring.
- routing.core.functions.invert_frame(frame: ndarray) ndarray[source]#
Invert a HTM frame with inverse movement instead of inverse matrix.
- routing.core.functions.parse_csv_value(value: str) int | float | str[source]#
Parse a CSV string value to int, float, or str.
- routing.core.functions.points_to_homogeneous_matrix(points: list) ndarray[source]#
Convert a list of points to a homogeneous transformation matrix.
- routing.core.functions.redefines(method: Callable, base_function: Callable) bool[source]#
Whether the bound
methodruns another function thanbase_function: a subclass or the instance redefined it.
- routing.core.functions.set_primitives_name(primitives: list[Primitive3D], name: str) None[source]#
Add an indexed name to primitives when a name is defined as argument.