utils
batcharray.utils ¶
Contain utility functions.
batcharray.utils.bfs_array ¶
bfs_array(data: Any) -> Generator[ndarray]
Implement a Breadth-First Search (BFS) iterator over the
numpy.ndarray
s.
This function assumes the underlying data has a tree-like structure.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data
|
Any
|
Specifies the data to iterate on. |
required |
Yields:
Type | Description |
---|---|
Generator[ndarray]
|
The next |
Example usage:
>>> import numpy as np
>>> from batcharray.utils import bfs_array
>>> list(bfs_array(["abc", np.ones((2, 3)), 42, np.array([0, 1, 2, 3, 4])]))
[array([[1., 1., 1.], [1., 1., 1.]]), array([0, 1, 2, 3, 4])]
batcharray.utils.dfs_array ¶
dfs_array(data: Any) -> Generator[ndarray]
Implement a Depth-First Search (DFS) iterator over the
np.ndarray
s.
This function assumes the underlying data has a tree-like structure.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data
|
Any
|
Specifies the data to iterate on. |
required |
Yields:
Type | Description |
---|---|
Generator[ndarray]
|
The next |
Example usage:
>>> import numpy as np
>>> from batcharray.utils.dfs import dfs_array
>>> list(dfs_array(["abc", np.ones((2, 3)), 42, np.array([0, 1, 2, 3, 4])]))
[array([[1., 1., 1.], [1., 1., 1.]]), array([0, 1, 2, 3, 4])]