spatial-graph 0.0.2__tar.gz → 0.0.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. spatial_graph-0.0.2/.github/workflows/ci.yaml → spatial_graph-0.0.4/.github/workflows/ci.yml +31 -0
  2. spatial_graph-0.0.4/.github/workflows/docs.yaml +29 -0
  3. {spatial_graph-0.0.2 → spatial_graph-0.0.4}/.gitignore +2 -0
  4. {spatial_graph-0.0.2 → spatial_graph-0.0.4}/.pre-commit-config.yaml +1 -1
  5. spatial_graph-0.0.4/Dockerfile +38 -0
  6. {spatial_graph-0.0.2 → spatial_graph-0.0.4}/PKG-INFO +44 -6
  7. {spatial_graph-0.0.2 → spatial_graph-0.0.4}/README.md +42 -4
  8. spatial_graph-0.0.4/docs/index.md +90 -0
  9. {spatial_graph-0.0.2 → spatial_graph-0.0.4}/examples/basic_usage.py +0 -1
  10. {spatial_graph-0.0.2 → spatial_graph-0.0.4}/examples/query_nearest_vispy.py +0 -1
  11. spatial_graph-0.0.4/mkdocs.yml +44 -0
  12. {spatial_graph-0.0.2 → spatial_graph-0.0.4}/pyproject.toml +31 -4
  13. spatial_graph-0.0.4/src/spatial_graph/__init__.py +24 -0
  14. spatial_graph-0.0.2/src/spatial_graph/dtypes.py → spatial_graph-0.0.4/src/spatial_graph/_dtypes.py +9 -12
  15. spatial_graph-0.0.4/src/spatial_graph/_graph/__init__.py +3 -0
  16. spatial_graph-0.0.4/src/spatial_graph/_graph/graph.py +227 -0
  17. spatial_graph-0.0.4/src/spatial_graph/_graph/graph_base.py +321 -0
  18. spatial_graph-0.0.2/src/spatial_graph/graph/graph.py → spatial_graph-0.0.4/src/spatial_graph/_graph/views.py +44 -104
  19. {spatial_graph-0.0.2/src/spatial_graph/graph → spatial_graph-0.0.4/src/spatial_graph/_graph}/wrapper_template.pyx +2 -2
  20. {spatial_graph-0.0.2/src/spatial_graph/rtree → spatial_graph-0.0.4/src/spatial_graph/_rtree}/line_rtree.py +21 -29
  21. {spatial_graph-0.0.2/src/spatial_graph/rtree → spatial_graph-0.0.4/src/spatial_graph/_rtree}/rtree.py +135 -123
  22. spatial_graph-0.0.4/src/spatial_graph/_rtree/tree_base.py +0 -0
  23. {spatial_graph-0.0.2/src/spatial_graph/rtree → spatial_graph-0.0.4/src/spatial_graph/_rtree}/wrapper_template.pyx +2 -2
  24. spatial_graph-0.0.2/src/spatial_graph/spatial_graph.py → spatial_graph-0.0.4/src/spatial_graph/_spatial_graph.py +46 -33
  25. spatial_graph-0.0.4/src/spatial_graph/_util.py +101 -0
  26. {spatial_graph-0.0.2 → spatial_graph-0.0.4}/tests/test_attributes.py +3 -4
  27. spatial_graph-0.0.4/tests/test_bench.py +77 -0
  28. {spatial_graph-0.0.2 → spatial_graph-0.0.4}/tests/test_dtype.py +1 -1
  29. {spatial_graph-0.0.2 → spatial_graph-0.0.4}/tests/test_graph.py +19 -30
  30. spatial_graph-0.0.4/tests/test_invalid_inputs.py +34 -0
  31. {spatial_graph-0.0.2 → spatial_graph-0.0.4}/tests/test_rtree.py +11 -11
  32. {spatial_graph-0.0.2 → spatial_graph-0.0.4}/tests/test_spatial_graph.py +16 -24
  33. spatial_graph-0.0.2/src/spatial_graph/__init__.py +0 -13
  34. spatial_graph-0.0.2/src/spatial_graph/graph/__init__.py +0 -3
  35. spatial_graph-0.0.2/tests/test_assert.py +0 -2
  36. {spatial_graph-0.0.2 → spatial_graph-0.0.4}/LICENSE +0 -0
  37. {spatial_graph-0.0.2/src/spatial_graph/graph → spatial_graph-0.0.4/src/spatial_graph/_graph}/src/LICENSE.txt +0 -0
  38. {spatial_graph-0.0.2/src/spatial_graph/graph → spatial_graph-0.0.4/src/spatial_graph/_graph}/src/graph_lite.h +0 -0
  39. {spatial_graph-0.0.2/src/spatial_graph/rtree → spatial_graph-0.0.4/src/spatial_graph/_rtree}/__init__.py +0 -0
  40. {spatial_graph-0.0.2/src/spatial_graph/rtree → spatial_graph-0.0.4/src/spatial_graph/_rtree}/point_rtree.py +0 -0
  41. {spatial_graph-0.0.2/src/spatial_graph/rtree → spatial_graph-0.0.4/src/spatial_graph/_rtree}/src/ARCHITECTURE.md +0 -0
  42. {spatial_graph-0.0.2/src/spatial_graph/rtree → spatial_graph-0.0.4/src/spatial_graph/_rtree}/src/LICENSE +0 -0
  43. {spatial_graph-0.0.2/src/spatial_graph/rtree → spatial_graph-0.0.4/src/spatial_graph/_rtree}/src/config.h +0 -0
  44. {spatial_graph-0.0.2/src/spatial_graph/rtree → spatial_graph-0.0.4/src/spatial_graph/_rtree}/src/rtree.c +0 -0
  45. {spatial_graph-0.0.2/src/spatial_graph/rtree → spatial_graph-0.0.4/src/spatial_graph/_rtree}/src/rtree.h +0 -0
@@ -42,6 +42,25 @@ jobs:
42
42
  with:
43
43
  token: ${{ secrets.CODECOV_TOKEN }}
44
44
 
45
+ benchmarks:
46
+ runs-on: ubuntu-latest
47
+ env:
48
+ UV_NO_SYNC: "1"
49
+ steps:
50
+ - uses: actions/checkout@v4
51
+ - uses: astral-sh/setup-uv@v6
52
+ with:
53
+ python-version: "3.13"
54
+ enable-cache: true
55
+
56
+ - name: install
57
+ run: uv sync --no-dev --group test-codspeed
58
+
59
+ - name: Run benchmarks
60
+ uses: CodSpeedHQ/action@v3
61
+ with:
62
+ run: uv run pytest -W ignore --codspeed -v --color=yes
63
+
45
64
  deploy:
46
65
  name: Deploy
47
66
  needs: test
@@ -74,3 +93,15 @@ jobs:
74
93
  with:
75
94
  generate_release_notes: true
76
95
  files: "./dist/*"
96
+
97
+ docker-test:
98
+ runs-on: ubuntu-latest
99
+
100
+ steps:
101
+ - name: Checkout code
102
+ uses: actions/checkout@v4
103
+
104
+ - name: Build and test Docker image
105
+ run: |
106
+ docker build -t spatial_graph .
107
+ docker run --rm spatial_graph
@@ -0,0 +1,29 @@
1
+ name: Deploy Documentation
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ workflow_dispatch:
7
+
8
+ concurrency:
9
+ group: ${{ github.workflow }}-${{ github.ref }}
10
+ cancel-in-progress: true
11
+
12
+ permissions:
13
+ contents: write
14
+
15
+ jobs:
16
+ docs:
17
+ name: Deploy Documentation
18
+ runs-on: ubuntu-latest
19
+ steps:
20
+ - uses: actions/checkout@v4
21
+ with:
22
+ fetch-depth: 0
23
+ - name: Configure Git Credentials
24
+ run: |
25
+ git config user.name github-actions[bot]
26
+ git config user.email github-actions[bot]@users.noreply.github.com
27
+ - uses: astral-sh/setup-uv@v6
28
+ - name: Deploy documentation
29
+ run: uv run --group docs mkdocs gh-deploy --strict --force
@@ -11,6 +11,8 @@ build
11
11
  dist
12
12
  .vscode
13
13
  docs/_build/
14
+ coverage.xml
15
+ site
14
16
 
15
17
  # remove me to enforce synchrony across development environments
16
18
  uv.lock
@@ -17,7 +17,7 @@ repos:
17
17
  - repo: https://github.com/astral-sh/ruff-pre-commit
18
18
  rev: v0.12.2
19
19
  hooks:
20
- - id: ruff
20
+ - id: ruff-check
21
21
  args: [--fix, --unsafe-fixes]
22
22
  - id: ruff-format
23
23
 
@@ -0,0 +1,38 @@
1
+ FROM ubuntu:24.04
2
+
3
+ ENV DEBIAN_FRONTEND=noninteractive \
4
+ MAMBA_ROOT_PREFIX=/opt/conda \
5
+ PATH=/opt/conda/bin:$PATH
6
+
7
+ RUN apt-get update && \
8
+ apt-get install -y --no-install-recommends \
9
+ git curl tar bzip2 ca-certificates && \
10
+ rm -rf /var/lib/apt/lists/*
11
+
12
+ # auto-detect arch and grab the matching micromamba binary
13
+ RUN set -eux; \
14
+ arch="$(uname -m)"; \
15
+ case "$arch" in \
16
+ x86_64) url_arch=linux-64 ;; \
17
+ aarch64|arm64) url_arch=linux-aarch64 ;; \
18
+ ppc64le) url_arch=linux-ppc64le ;; \
19
+ *) echo "Unsupported arch: $arch"; exit 1 ;; \
20
+ esac; \
21
+ curl -Ls "https://micro.mamba.pm/api/micromamba/$url_arch/latest" \
22
+ | tar -xvj -C /usr/local/bin bin/micromamba; \
23
+ chmod +x /usr/local/bin/bin/micromamba; \
24
+ mv /usr/local/bin/bin/micromamba /usr/local/bin/micromamba; \
25
+ rmdir /usr/local/bin/bin
26
+
27
+
28
+ WORKDIR /app
29
+ COPY . /app
30
+
31
+ RUN micromamba create -y -n test-env -c conda-forge python=3.12 pip compilers
32
+ RUN micromamba run -n test-env pip install -e . --group test
33
+
34
+ SHELL ["micromamba", "run", "-n", "test-env", "/bin/bash", "-o", "pipefail", "-c"]
35
+
36
+
37
+ # when you docker run, this will invoke pytest from inside test-env
38
+ CMD ["micromamba", "run", "-n", "test-env", "pytest", "-q", "-x"]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: spatial-graph
3
- Version: 0.0.2
3
+ Version: 0.0.4
4
4
  Summary: A spatial graph datastructure for python.
5
5
  Project-URL: homepage, https://github.com/funkelab/spatial_graph
6
6
  Project-URL: repository, https://github.com/funkelab/spatial_graph
@@ -20,7 +20,7 @@ Requires-Python: >=3.9
20
20
  Requires-Dist: ct3>=3.3.3
21
21
  Requires-Dist: numpy
22
22
  Requires-Dist: setuptools>=75.8.0
23
- Requires-Dist: witty>=v0.2.1
23
+ Requires-Dist: witty>=v0.3.0
24
24
  Description-Content-Type: text/markdown
25
25
 
26
26
  # spatial-graph
@@ -28,8 +28,9 @@ Description-Content-Type: text/markdown
28
28
  [![License](https://img.shields.io/pypi/l/spatial-graph.svg?color=green)](https://github.com/funkelab/spatial_graph/raw/main/LICENSE)
29
29
  [![PyPI](https://img.shields.io/pypi/v/spatial-graph.svg?color=green)](https://pypi.org/project/spatial-graph)
30
30
  [![Python Version](https://img.shields.io/pypi/pyversions/spatial-graph.svg?color=green)](https://python.org)
31
- [![CI](https://github.com/funkelab/spatial_graph/actions/workflows/ci.yaml/badge.svg)](https://github.com/funkelab/spatial_graph/actions/workflows/ci.yaml)
31
+ [![CI](https://github.com/funkelab/spatial_graph/actions/workflows/ci.yml/badge.svg)](https://github.com/funkelab/spatial_graph/actions/workflows/ci.yml)
32
32
  [![codecov](https://codecov.io/gh/funkelab/spatial_graph/branch/main/graph/badge.svg)](https://codecov.io/gh/funkelab/spatial_graph)
33
+ [![CodSpeed](https://img.shields.io/endpoint?url=https://codspeed.io/badge.json)](https://codspeed.io/funkelab/spatial_graph)
33
34
 
34
35
  `spatial_graph` provides a data structure for directed and undirected graphs,
35
36
  where each node has an nD position (in time or space).
@@ -74,7 +75,6 @@ graph = sg.SpatialGraph(
74
75
  node_attr_dtypes={"position": "double[3]"},
75
76
  edge_attr_dtypes={"score": "float32"},
76
77
  position_attr="position",
77
- directed=False,
78
78
  )
79
79
  ```
80
80
 
@@ -133,8 +133,35 @@ graph.remove_nodes(nodes[:1000])
133
133
 
134
134
  A `SpatialGraph` consists of three data structures:
135
135
 
136
- * The `Graph` itself, holding nodes, edges, and their attributes ([graphlite](https://github.com/haasdo95/graphlite)).
137
- * Two R-trees for spatial node and edge queries (based on [rtree.c](https://github.com/tidwall/rtree.c)).
136
+ * The `Graph` itself, holding nodes, edges, and their attributes
137
+ ([graphlite](https://github.com/haasdo95/graphlite)).
138
+ * Two R-trees for spatial node and edge queries (based on
139
+ [rtree.c](https://github.com/tidwall/rtree.c)). We modified the original code
140
+ to also include a fast kNN search.
141
+
142
+ ## Cross-Platform Support
143
+
144
+ `spatial_graph` compiles C/C++ code at runtime, and as such needs access to a
145
+ compiler. If you already have one, great! You can use the PyPI package.
146
+
147
+ If you (or your users) don't have a compiler installed, you either need to
148
+
149
+ 1. Install a compiler. This might be weird for non-technical users.
150
+ 2. Install `spatial_graph` from `conda-forge`, where we include a compiler
151
+ (`clang`) in its dependencies.
152
+
153
+ ### Why is this so complicated?
154
+
155
+ There is no cross-platform C/C++ compiler that we can install using `pip`.
156
+ [`numba`](https://github.com/numba/numba) is maybe the closest to having solved
157
+ that problem: `numba` does compile during runtime even if you don't have a
158
+ compiler locally installed. This works because `numba` is generating LLVM IR,
159
+ an intermediate representation language that LLVM can compile into machine
160
+ code. `numba` depends on [`llvmlite`](https://github.com/numba/llvmlite), which
161
+ provides a subset of the LLVM API, statically linked into the binaries in that
162
+ package. This is just enough to compile the `numba` generated LLVM IR into
163
+ machine code. We can't use this strategy, because we compile general C/C++
164
+ code. Converting that into LLVM IR is exactly what we need a compiler for.
138
165
 
139
166
  ## For Developers
140
167
 
@@ -147,3 +174,14 @@ git push upstream --follow-tags
147
174
  ```
148
175
 
149
176
  This will trigger the CI workflow, which will build the package and upload it to PyPI.
177
+
178
+ ### Testing in a conda environment
179
+
180
+ To simulate a naive user environment, with *no* assumptions made about the
181
+ availability of a C/C++ compiler, you can run the included Dockerfile
182
+ (where the key part of the conda env is the `compilers` package):
183
+
184
+ ```bash
185
+ docker build -t spatial_graph .
186
+ docker run --rm spatial_graph
187
+ ```
@@ -3,8 +3,9 @@
3
3
  [![License](https://img.shields.io/pypi/l/spatial-graph.svg?color=green)](https://github.com/funkelab/spatial_graph/raw/main/LICENSE)
4
4
  [![PyPI](https://img.shields.io/pypi/v/spatial-graph.svg?color=green)](https://pypi.org/project/spatial-graph)
5
5
  [![Python Version](https://img.shields.io/pypi/pyversions/spatial-graph.svg?color=green)](https://python.org)
6
- [![CI](https://github.com/funkelab/spatial_graph/actions/workflows/ci.yaml/badge.svg)](https://github.com/funkelab/spatial_graph/actions/workflows/ci.yaml)
6
+ [![CI](https://github.com/funkelab/spatial_graph/actions/workflows/ci.yml/badge.svg)](https://github.com/funkelab/spatial_graph/actions/workflows/ci.yml)
7
7
  [![codecov](https://codecov.io/gh/funkelab/spatial_graph/branch/main/graph/badge.svg)](https://codecov.io/gh/funkelab/spatial_graph)
8
+ [![CodSpeed](https://img.shields.io/endpoint?url=https://codspeed.io/badge.json)](https://codspeed.io/funkelab/spatial_graph)
8
9
 
9
10
  `spatial_graph` provides a data structure for directed and undirected graphs,
10
11
  where each node has an nD position (in time or space).
@@ -49,7 +50,6 @@ graph = sg.SpatialGraph(
49
50
  node_attr_dtypes={"position": "double[3]"},
50
51
  edge_attr_dtypes={"score": "float32"},
51
52
  position_attr="position",
52
- directed=False,
53
53
  )
54
54
  ```
55
55
 
@@ -108,8 +108,35 @@ graph.remove_nodes(nodes[:1000])
108
108
 
109
109
  A `SpatialGraph` consists of three data structures:
110
110
 
111
- * The `Graph` itself, holding nodes, edges, and their attributes ([graphlite](https://github.com/haasdo95/graphlite)).
112
- * Two R-trees for spatial node and edge queries (based on [rtree.c](https://github.com/tidwall/rtree.c)).
111
+ * The `Graph` itself, holding nodes, edges, and their attributes
112
+ ([graphlite](https://github.com/haasdo95/graphlite)).
113
+ * Two R-trees for spatial node and edge queries (based on
114
+ [rtree.c](https://github.com/tidwall/rtree.c)). We modified the original code
115
+ to also include a fast kNN search.
116
+
117
+ ## Cross-Platform Support
118
+
119
+ `spatial_graph` compiles C/C++ code at runtime, and as such needs access to a
120
+ compiler. If you already have one, great! You can use the PyPI package.
121
+
122
+ If you (or your users) don't have a compiler installed, you either need to
123
+
124
+ 1. Install a compiler. This might be weird for non-technical users.
125
+ 2. Install `spatial_graph` from `conda-forge`, where we include a compiler
126
+ (`clang`) in its dependencies.
127
+
128
+ ### Why is this so complicated?
129
+
130
+ There is no cross-platform C/C++ compiler that we can install using `pip`.
131
+ [`numba`](https://github.com/numba/numba) is maybe the closest to having solved
132
+ that problem: `numba` does compile during runtime even if you don't have a
133
+ compiler locally installed. This works because `numba` is generating LLVM IR,
134
+ an intermediate representation language that LLVM can compile into machine
135
+ code. `numba` depends on [`llvmlite`](https://github.com/numba/llvmlite), which
136
+ provides a subset of the LLVM API, statically linked into the binaries in that
137
+ package. This is just enough to compile the `numba` generated LLVM IR into
138
+ machine code. We can't use this strategy, because we compile general C/C++
139
+ code. Converting that into LLVM IR is exactly what we need a compiler for.
113
140
 
114
141
  ## For Developers
115
142
 
@@ -122,3 +149,14 @@ git push upstream --follow-tags
122
149
  ```
123
150
 
124
151
  This will trigger the CI workflow, which will build the package and upload it to PyPI.
152
+
153
+ ### Testing in a conda environment
154
+
155
+ To simulate a naive user environment, with *no* assumptions made about the
156
+ availability of a C/C++ compiler, you can run the included Dockerfile
157
+ (where the key part of the conda env is the `compilers` package):
158
+
159
+ ```bash
160
+ docker build -t spatial_graph .
161
+ docker run --rm spatial_graph
162
+ ```
@@ -0,0 +1,90 @@
1
+ # spatial-graph
2
+
3
+ `spatial-graph` provides a data structure for directed and undirected graphs,
4
+ where each node has an nD position (in time or space).
5
+
6
+ It leverages well-in-time compiled C++ code for efficient graph operations,
7
+ coupled with an rtree implementation for fast spatial queries.
8
+
9
+ ## Goals
10
+
11
+ - Support for arbitrary number of dimensions
12
+ - Typed node identifiers and attributes
13
+ - Any fixed-length type that is supported by `numpy`
14
+ - Efficient node/edge queries by
15
+ - ROI
16
+ - kNN (by points / lines)
17
+ - numpy-like interface for efficient:
18
+ - Graph population and manipulation
19
+ - Query results
20
+ - Attribute access
21
+ - Minimal memory footprint
22
+ - Minimal dependencies
23
+ - PYX API for graph algorithms in C/C++
24
+
25
+ ## Basic Usage
26
+
27
+ Graph creation:
28
+
29
+ ```python
30
+ graph = sg.SpatialGraph(
31
+ ndims=3,
32
+ node_dtype="uint64",
33
+ node_attr_dtypes={"position": "double[3]"},
34
+ edge_attr_dtypes={"score": "float32"},
35
+ position_attr="position",
36
+ )
37
+ ```
38
+
39
+ Adding nodes/edges:
40
+
41
+ ```python
42
+ graph.add_nodes(
43
+ np.array([1, 2, 3, 4, 5], dtype="uint64"),
44
+ position=np.array(
45
+ [
46
+ [0.1, 0.1, 0.1],
47
+ [0.2, 0.2, 0.2],
48
+ [0.3, 0.3, 0.3],
49
+ [0.4, 0.4, 0.4],
50
+ [0.5, 0.5, 0.5],
51
+ ],
52
+ dtype="double",
53
+ ),
54
+ )
55
+
56
+ graph.add_edges(
57
+ np.array([[1, 2], [3, 4], [5, 1]], dtype="uint64"),
58
+ score=np.array([0.2, 0.3, 0.4], dtype="float32"),
59
+ )
60
+ ```
61
+
62
+ Query nodes/edges in ROI:
63
+
64
+ ```python
65
+ # nodes/edges will be numpy arrays of dtype uint64 and shape (n,)/(n, 2)
66
+ nodes = graph.query_nodes_in_roi(np.array([[0.0, 0.0, 0.0], [0.25, 0.25, 0.25]]))
67
+ edges = graph.query_edges_in_roi(np.array([[0.0, 0.0, 0.0], [0.25, 0.25, 0.25]]))
68
+ ```
69
+
70
+ Query nodes/edges by position:
71
+
72
+ ```python
73
+ nodes = graph.query_nearest_nodes(np.array([0.3, 0.3, 0.3]), k=3)
74
+ edges = graph.query_nearest_edges(np.array([0.3, 0.3, 0.3]), k=3)
75
+ ```
76
+
77
+ Access node/edge attributes:
78
+
79
+ ```python
80
+ node_positions = graph.node_attrs[nodes].position
81
+ edge_scores = graph.edge_attrs[edges].score
82
+ ```
83
+
84
+ Delete nodes/edges:
85
+
86
+ ```python
87
+ graph.remove_nodes(nodes[:1000])
88
+ ```
89
+
90
+ See the [API documentation](./reference) for more details.
@@ -23,7 +23,6 @@ def main():
23
23
  node_attr_dtypes={"position": "double[3]"},
24
24
  edge_attr_dtypes={"score": "float32"},
25
25
  position_attr="position",
26
- directed=False,
27
26
  )
28
27
  print(f" Created graph with {graph.ndims} dimensions")
29
28
  print(f" Node dtype: {graph.node_dtype}")
@@ -30,7 +30,6 @@ graph = SpatialGraph(
30
30
  node_attr_dtypes={"position": "double[3]"},
31
31
  edge_attr_dtypes={"score": "float32"},
32
32
  position_attr="position",
33
- directed=False,
34
33
  )
35
34
  nodes = np.arange(100_000, dtype="uint64")
36
35
  graph.add_nodes(nodes, position=np.random.random((100_000, 3)))
@@ -0,0 +1,44 @@
1
+ site_name: "spatial-graph"
2
+ site_url: https://github.com/funkelab/spatial_graph
3
+ site_description: >-
4
+ High performance spatial graph library for Python
5
+ # Repository
6
+ repo_name: funkelab/spatial_graph
7
+ repo_url: https://github.com/funkelab/spatial_graph
8
+
9
+ theme:
10
+ name: material
11
+ palette:
12
+ scheme: default
13
+ primary: pink
14
+ features:
15
+ - content.tabs.link
16
+ - content.code.copy
17
+ - content.code.annotate
18
+ - navigation.instant
19
+
20
+ plugins:
21
+ - search
22
+ - api-autonav:
23
+ modules: ["src/spatial_graph"]
24
+ - mkdocstrings:
25
+ handlers:
26
+ python:
27
+ inventories:
28
+ - https://docs.python.org/3/objects.inv
29
+ options:
30
+ docstring_section_style: list # or "table"
31
+ docstring_style: "numpy"
32
+ preload_modules: [spatial_graph]
33
+ filters: ["!^_"]
34
+ heading_level: 1
35
+ merge_init_into_class: true
36
+ parameter_headings: true
37
+ separate_signature: true
38
+ show_root_heading: true
39
+ show_signature_annotations: true
40
+ show_symbol_type_heading: true
41
+ show_symbol_type_toc: true
42
+ summary: true
43
+ inherited_members: true
44
+ force_inspection: true
@@ -5,7 +5,6 @@ build-backend = "hatchling.build"
5
5
  [tool.hatch.version]
6
6
  source = "vcs"
7
7
 
8
-
9
8
  [project]
10
9
  name = "spatial-graph"
11
10
  dynamic = ["version"]
@@ -28,17 +27,26 @@ classifiers = [
28
27
  "Programming Language :: Python :: 3.13",
29
28
  "Typing :: Typed",
30
29
  ]
31
- dependencies = ["witty>=v0.2.1", "CT3>=3.3.3", "numpy", "setuptools>=75.8.0"]
30
+ dependencies = ["witty>=v0.3.0", "CT3>=3.3.3", "numpy", "setuptools>=75.8.0"]
32
31
 
33
32
  [dependency-groups]
33
+ test = ["pytest>=8.3.5", "pytest-cov>=6.1.1"]
34
+ test-codspeed = [{ include-group = "test" }, "pytest-codspeed >=3.2.0"]
34
35
  dev = [
36
+ { include-group = "test" },
35
37
  "ipython>=8.18.1",
36
38
  "mypy>=1.15.0",
37
39
  "pre-commit>=4.2.0",
38
- "pytest>=8.3.5",
39
- "pytest-cov>=6.1.1",
40
+ "pytest-benchmark>=5.1.0", # specifically excluded from test group for ci
40
41
  "ruff>=0.11.10",
41
42
  ]
43
+ docs = [
44
+ "mkdocs>=1.6.1",
45
+ "mkdocs-api-autonav>=0.3.0",
46
+ "mkdocs-material>=9.6.15",
47
+ "mkdocstrings-python>=1.16.12",
48
+ "ruff",
49
+ ]
42
50
 
43
51
 
44
52
  [project.urls]
@@ -48,6 +56,8 @@ repository = "https://github.com/funkelab/spatial_graph"
48
56
  [tool.ruff]
49
57
  target-version = "py39"
50
58
  line-length = 88
59
+ fix = true
60
+ unsafe-fixes = true
51
61
 
52
62
  [tool.ruff.lint]
53
63
  select = [
@@ -75,3 +85,20 @@ pretty = true
75
85
  [tool.pytest.ini_options]
76
86
  addopts = "-v --color=yes"
77
87
  filterwarnings = ["error", "ignore:'cgi' is deprecated"]
88
+
89
+
90
+ [tool.coverage.report]
91
+ show_missing = true
92
+ exclude_lines = [
93
+ "pragma: no cover",
94
+ "if TYPE_CHECKING:",
95
+ "@overload",
96
+ "except ImportError",
97
+ "raise AssertionError",
98
+ "\\.\\.\\.",
99
+ "if __name__ == .__main__.:",
100
+ "raise NotImplementedError",
101
+ ]
102
+
103
+ [tool.coverage.run]
104
+ source = ['spatial_graph']
@@ -0,0 +1,24 @@
1
+ from importlib.metadata import PackageNotFoundError, version
2
+
3
+ try:
4
+ __version__ = version("spatial_graph")
5
+ except PackageNotFoundError: # pragma: no cover
6
+ __version__ = "unknown"
7
+
8
+
9
+ from ._graph import DiGraph, Graph, GraphBase
10
+ from ._rtree import LineRTree, PointRTree
11
+ from ._spatial_graph import SpatialDiGraph, SpatialGraph, SpatialGraphBase
12
+ from ._util import create_graph
13
+
14
+ __all__ = [
15
+ "DiGraph",
16
+ "Graph",
17
+ "GraphBase",
18
+ "LineRTree",
19
+ "PointRTree",
20
+ "SpatialDiGraph",
21
+ "SpatialGraph",
22
+ "SpatialGraphBase",
23
+ "create_graph",
24
+ ]
@@ -87,18 +87,15 @@ class DType:
87
87
  "base_c_type[::1]" if not an array type and add_dim
88
88
  "base_c_type[:, ::1]" if an array type and add_dim
89
89
 
90
- Args:
91
-
92
- use_memory_view:
93
-
94
- If set, will produce "dtype[::1]" instead of "dtype[dim]" for
95
- array types.
96
-
97
- add_dim:
98
-
99
- Append a dim to the type, e.g., "int32_t[::1]" instead of
100
- "int32_t" for dtype "int32". If this DType is already an array,
101
- will create a 2D array, e.g., "int32_t[:, ::1]".
90
+ Parameters
91
+ ----------
92
+ use_memory_view : bool
93
+ If set, will produce "dtype[::1]" instead of "dtype[dim]" for
94
+ array types.
95
+ add_dim : bool
96
+ Append a dim to the type, e.g., "int32_t[::1]" instead of
97
+ "int32_t" for dtype "int32". If this DType is already an array,
98
+ will create a 2D array, e.g., "int32_t[:, ::1]".
102
99
  """
103
100
  if self.is_array:
104
101
  if add_dim:
@@ -0,0 +1,3 @@
1
+ from .graph import DiGraph, Graph, GraphBase
2
+
3
+ __all__ = ["DiGraph", "Graph", "GraphBase"]