geff.testing.data
Test data generation utilities for geff graphs.
This module provides functions to create mock geff graphs for testing and development. It includes both simple convenience functions and a comprehensive function for advanced use cases.
Examples:
Simple 2D graph with defaults
>>> store, memory_geff = create_simple_2d_geff()
>>> # Creates: 10 nodes, 15 edges, undirected, 2D (x, y, t)
Simple 3D graph with custom size
>>> store, memory_geff = create_simple_3d_geff(num_nodes=20, num_edges=30)
>>> # Creates: 20 nodes, 30 edges, undirected, 3D (x, y, z, t)
Advanced usage with full control
>>> store, memory_geff = create_mock_geff(
... node_id_dtype="int",
... node_axis_dtypes={"position": "float64", "time": "float32"},
... directed=True,
... num_nodes=5,
... num_edges=8,
... extra_node_props={"label": "str", "confidence": "float64"},
... extra_edge_props={"score": "float64", "color": "uint8",
... "weight": "float64", "type": "str"},
... include_t=True,
... include_z=False, # 2D only
... include_y=True,
... include_x=True,
... )
Advanced usage with custom arrays
>>> import numpy as np
>>> custom_labels = np.array(["A", "B", "C", "D", "E"])
>>> custom_scores = np.array([0.1, 0.5, 0.8, 0.3, 0.9])
>>> custom_edge_weights = np.array([0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8])
>>> store, memory_geff = create_mock_geff(
... node_id_dtype="int",
... node_axis_dtypes={"position": "float64", "time": "float64"},
... directed=False,
... num_nodes=5,
... num_edges=8,
... extra_node_props={"label": custom_labels, "score": custom_scores,
... "confidence": "float64"},
... extra_edge_props={"weight": custom_edge_weights, "type": "str"},
... include_t=True,
... include_z=False,
... include_y=True,
... include_x=True,
... )
To construct an graph with a backend graph lib
>>> # Import construct function of your choice
>>> store, memory_geff = create_simple_2d_geff()
>>> graph = construct_nx(**memory_geff)
>>> # graph is a networkx Graph ready for analysis
ExampleNodeAxisPropsDtypes
Bases: TypedDict
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
position
|
ForwardRef('DTypeStr', module='geff.testing.data')
|
|
required |
time
|
ForwardRef('DTypeStr', module='geff.testing.data')
|
|
required |
create_dummy_in_mem_geff
create_dummy_in_mem_geff(
node_id_dtype: NodeIdDTypeStr,
node_axis_dtypes: ExampleNodeAxisPropsDtypes,
directed: bool,
num_nodes: int = 5,
num_edges: int = 4,
extra_node_props: Mapping[str, DTypeStr | NDArray[Any]]
| None = None,
extra_edge_props: Mapping[str, DTypeStr | NDArray[Any]]
| None = None,
include_t: bool = True,
include_z: bool = True,
include_y: bool = True,
include_x: bool = True,
include_varlength: bool = False,
include_missing: bool = False,
) -> InMemoryGeff
Create dummy graph properties for testing.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
node_id_dtype
|
NodeIdDTypeStr
|
Data type for node IDs |
required |
node_axis_dtypes
|
ExampleNodeAxisPropsDtypes
|
Dictionary specifying dtypes for node axis properties (space and time) |
required |
directed
|
bool
|
Whether the graph is directed |
required |
num_nodes
|
int
|
Number of nodes to generate |
5
|
num_edges
|
int
|
Number of edges to generate |
4
|
extra_node_props
|
Mapping[str, DTypeStr | NDArray[Any]] | None
|
Dict mapping property names to dtypes for extra node properties |
None
|
extra_edge_props
|
Mapping[str, DTypeStr | NDArray[Any]] | None
|
Dict mapping property names to dtypes for extra edge properties |
None
|
include_t
|
bool
|
Whether to include time dimension |
True
|
include_z
|
bool
|
Whether to include z dimension |
True
|
include_y
|
bool
|
Whether to include y dimension |
True
|
include_x
|
bool
|
Whether to include x dimension |
True
|
include_varlength
|
bool
|
Whether to include a variable length property. If true, will make a property on nodes called "var_length" that has 2d np arrays of various shapes |
False
|
include_missing
|
bool
|
If true, creades a node and edge prop called "sparse_prop" where every other node/edge has a missing value |
False
|
Returns:
| Type | Description |
|---|---|
InMemoryGeff
|
InMemoryGeff containing all graph properties |
create_empty_geff
create_empty_geff(
directed: bool = False,
) -> tuple[zarr.storage.MemoryStore, InMemoryGeff]
Creates a geff without any nodes or edges
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
directed
|
bool
|
Whether to create a directed graph. Defaults to False. |
False
|
Returns:
| Type | Description |
|---|---|
tuple[MemoryStore, InMemoryGeff]
|
tuple[zarr.storage.MemoryStore, InMemoryGeff] |
create_mock_geff
create_mock_geff(
node_id_dtype: NodeIdDTypeStr,
node_axis_dtypes: ExampleNodeAxisPropsDtypes,
directed: bool,
num_nodes: int = 5,
num_edges: int = 4,
extra_node_props: Mapping[str, DTypeStr | NDArray[Any]]
| None = None,
extra_edge_props: Mapping[str, DTypeStr | NDArray[Any]]
| None = None,
include_t: bool = True,
include_z: bool = True,
include_y: bool = True,
include_x: bool = True,
include_varlength: bool = False,
include_missing: bool = False,
) -> tuple[zarr.storage.MemoryStore, InMemoryGeff]
Create a mock geff in memory and return the zarr store and the in memory geff.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
node_id_dtype
|
NodeIdDTypeStr
|
Data type for node IDs |
required |
node_axis_dtypes
|
ExampleNodeAxisPropsDtypes
|
Dictionary specifying dtypes for node axis properties (space and time) |
required |
directed
|
bool
|
Whether the graph is directed |
required |
num_nodes
|
int
|
Number of nodes to generate |
5
|
num_edges
|
int
|
Number of edges to generate |
4
|
extra_node_props
|
Mapping[str, DTypeStr | NDArray[Any]] | None
|
Dict mapping property names to dtypes for extra node properties |
None
|
extra_edge_props
|
Mapping[str, DTypeStr | NDArray[Any]] | None
|
Dict mapping property names to dtypes for extra edge properties |
None
|
include_t
|
bool
|
Whether to include time dimension |
True
|
include_z
|
bool
|
Whether to include z dimension |
True
|
include_y
|
bool
|
Whether to include y dimension |
True
|
include_x
|
bool
|
Whether to include x dimension |
True
|
include_varlength
|
bool
|
Whether to include a variable length property. If true, will make a property on nodes called "var_length" that has 2d np arrays of various shapes |
False
|
include_missing
|
bool
|
If true, creades a node prop called "sparse_prop" where every other node has a missing value |
False
|
Returns:
| Type | Description |
|---|---|
tuple[MemoryStore, InMemoryGeff]
|
Tuple of (zarr store in memory, InMemoryGeff) |
create_simple_2d_geff
create_simple_2d_geff(
num_nodes: int = 10,
num_edges: int = 15,
directed: bool = False,
) -> tuple[zarr.storage.MemoryStore, InMemoryGeff]
Create a simple 2D geff graph with default settings.
This is a convenience function for creating basic 2D graphs without having to specify all the detailed parameters. Uses sensible defaults for common use cases.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
num_nodes
|
int
|
Number of nodes to generate (default: 10) |
10
|
num_edges
|
int
|
Number of edges to generate (default: 15) |
15
|
directed
|
bool
|
Whether the graph is directed (default: False) |
False
|
Returns:
| Type | Description |
|---|---|
tuple[MemoryStore, InMemoryGeff]
|
Tuple of (zarr store in memory, InMemoryGeff) |
create_simple_3d_geff
create_simple_3d_geff(
num_nodes: int = 10,
num_edges: int = 15,
directed: bool = False,
) -> tuple[zarr.storage.MemoryStore, InMemoryGeff]
Create a simple 3D geff graph with default settings.
This is a convenience function for creating basic 3D graphs without having to specify all the detailed parameters. Uses sensible defaults for common use cases.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
num_nodes
|
int
|
Number of nodes to generate (default: 10) |
10
|
num_edges
|
int
|
Number of edges to generate (default: 15) |
15
|
directed
|
bool
|
Whether the graph is directed (default: False) |
False
|
Returns:
| Type | Description |
|---|---|
tuple[MemoryStore, InMemoryGeff]
|
Tuple of (zarr store in memory, InMemoryGeff) |
create_simple_temporal_geff
create_simple_temporal_geff(
num_nodes: int = 10,
num_edges: int = 15,
directed: bool = False,
) -> tuple[zarr.storage.MemoryStore, InMemoryGeff]
Create a simple geff graph with only time dimension (no spatial dimensions).
This function creates a graph with nodes, edges, and time coordinates, but no spatial dimensions (x, y, z). Useful for temporal-only analysis.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
num_nodes
|
int
|
Number of nodes to generate (default: 10) |
10
|
num_edges
|
int
|
Number of edges to generate (default: 15) |
15
|
directed
|
bool
|
Whether the graph is directed (default: False) |
False
|
Returns:
| Type | Description |
|---|---|
tuple[MemoryStore, InMemoryGeff]
|
Tuple of (zarr store in memory, InMemoryGeff) |