spatial-reasoner 0.1.0__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.
- spatial_reasoner-0.1.0/LICENSE +121 -0
- spatial_reasoner-0.1.0/PKG-INFO +145 -0
- spatial_reasoner-0.1.0/README.md +107 -0
- spatial_reasoner-0.1.0/pyproject.toml +84 -0
- spatial_reasoner-0.1.0/setup.cfg +4 -0
- spatial_reasoner-0.1.0/src/spatial_reasoner/__init__.py +94 -0
- spatial_reasoner-0.1.0/src/spatial_reasoner/bbox_sector.py +351 -0
- spatial_reasoner-0.1.0/src/spatial_reasoner/exporter.py +128 -0
- spatial_reasoner-0.1.0/src/spatial_reasoner/reasoner.py +557 -0
- spatial_reasoner-0.1.0/src/spatial_reasoner/spatial_basics.py +256 -0
- spatial_reasoner-0.1.0/src/spatial_reasoner/spatial_inference.py +920 -0
- spatial_reasoner-0.1.0/src/spatial_reasoner/spatial_object.py +2375 -0
- spatial_reasoner-0.1.0/src/spatial_reasoner/spatial_predicate.py +753 -0
- spatial_reasoner-0.1.0/src/spatial_reasoner/spatial_relation.py +120 -0
- spatial_reasoner-0.1.0/src/spatial_reasoner/spatial_taxonomy.py +210 -0
- spatial_reasoner-0.1.0/src/spatial_reasoner/vector2.py +176 -0
- spatial_reasoner-0.1.0/src/spatial_reasoner/vector3.py +82 -0
- spatial_reasoner-0.1.0/src/spatial_reasoner.egg-info/PKG-INFO +145 -0
- spatial_reasoner-0.1.0/src/spatial_reasoner.egg-info/SOURCES.txt +34 -0
- spatial_reasoner-0.1.0/src/spatial_reasoner.egg-info/dependency_links.txt +1 -0
- spatial_reasoner-0.1.0/src/spatial_reasoner.egg-info/requires.txt +13 -0
- spatial_reasoner-0.1.0/src/spatial_reasoner.egg-info/top_level.txt +1 -0
- spatial_reasoner-0.1.0/tests/test_bbox_sector.py +77 -0
- spatial_reasoner-0.1.0/tests/test_distribution.py +44 -0
- spatial_reasoner-0.1.0/tests/test_exporter.py +40 -0
- spatial_reasoner-0.1.0/tests/test_predicate_name_pipeline.py +29 -0
- spatial_reasoner-0.1.0/tests/test_public_imports.py +51 -0
- spatial_reasoner-0.1.0/tests/test_sector.py +78 -0
- spatial_reasoner-0.1.0/tests/test_spatial_attribute.py +95 -0
- spatial_reasoner-0.1.0/tests/test_spatial_basics.py +306 -0
- spatial_reasoner-0.1.0/tests/test_spatial_object.py +910 -0
- spatial_reasoner-0.1.0/tests/test_spatial_predicate.py +453 -0
- spatial_reasoner-0.1.0/tests/test_spatial_reasoning.py +369 -0
- spatial_reasoner-0.1.0/tests/test_spatial_relation.py +688 -0
- spatial_reasoner-0.1.0/tests/test_vector2.py +96 -0
- spatial_reasoner-0.1.0/tests/test_vector3.py +100 -0
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
Creative Commons Legal Code
|
|
2
|
+
|
|
3
|
+
CC0 1.0 Universal
|
|
4
|
+
|
|
5
|
+
CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
|
|
6
|
+
LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
|
|
7
|
+
ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
|
|
8
|
+
INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
|
|
9
|
+
REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
|
|
10
|
+
PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
|
|
11
|
+
THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
|
|
12
|
+
HEREUNDER.
|
|
13
|
+
|
|
14
|
+
Statement of Purpose
|
|
15
|
+
|
|
16
|
+
The laws of most jurisdictions throughout the world automatically confer
|
|
17
|
+
exclusive Copyright and Related Rights (defined below) upon the creator
|
|
18
|
+
and subsequent owner(s) (each and all, an "owner") of an original work of
|
|
19
|
+
authorship and/or a database (each, a "Work").
|
|
20
|
+
|
|
21
|
+
Certain owners wish to permanently relinquish those rights to a Work for
|
|
22
|
+
the purpose of contributing to a commons of creative, cultural and
|
|
23
|
+
scientific works ("Commons") that the public can reliably and without fear
|
|
24
|
+
of later claims of infringement build upon, modify, incorporate in other
|
|
25
|
+
works, reuse and redistribute as freely as possible in any form whatsoever
|
|
26
|
+
and for any purposes, including without limitation commercial purposes.
|
|
27
|
+
These owners may contribute to the Commons to promote the ideal of a free
|
|
28
|
+
culture and the further production of creative, cultural and scientific
|
|
29
|
+
works, or to gain reputation or greater distribution for their Work in
|
|
30
|
+
part through the use and efforts of others.
|
|
31
|
+
|
|
32
|
+
For these and/or other purposes and motivations, and without any
|
|
33
|
+
expectation of additional consideration or compensation, the person
|
|
34
|
+
associating CC0 with a Work (the "Affirmer"), to the extent that he or she
|
|
35
|
+
is an owner of Copyright and Related Rights in the Work, voluntarily
|
|
36
|
+
elects to apply CC0 to the Work and publicly distribute the Work under its
|
|
37
|
+
terms, with knowledge of his or her Copyright and Related Rights in the
|
|
38
|
+
Work and the meaning and intended legal effect of CC0 on those rights.
|
|
39
|
+
|
|
40
|
+
1. Copyright and Related Rights. A Work made available under CC0 may be
|
|
41
|
+
protected by copyright and related or neighboring rights ("Copyright and
|
|
42
|
+
Related Rights"). Copyright and Related Rights include, but are not
|
|
43
|
+
limited to, the following:
|
|
44
|
+
|
|
45
|
+
i. the right to reproduce, adapt, distribute, perform, display,
|
|
46
|
+
communicate, and translate a Work;
|
|
47
|
+
ii. moral rights retained by the original author(s) and/or performer(s);
|
|
48
|
+
iii. publicity and privacy rights pertaining to a person's image or
|
|
49
|
+
likeness depicted in a Work;
|
|
50
|
+
iv. rights protecting against unfair competition in regards to a Work,
|
|
51
|
+
subject to the limitations in paragraph 4(a), below;
|
|
52
|
+
v. rights protecting the extraction, dissemination, use and reuse of data
|
|
53
|
+
in a Work;
|
|
54
|
+
vi. database rights (such as those arising under Directive 96/9/EC of the
|
|
55
|
+
European Parliament and of the Council of 11 March 1996 on the legal
|
|
56
|
+
protection of databases, and under any national implementation
|
|
57
|
+
thereof, including any amended or successor version of such
|
|
58
|
+
directive); and
|
|
59
|
+
vii. other similar, equivalent or corresponding rights throughout the
|
|
60
|
+
world based on applicable law or treaty, and any national
|
|
61
|
+
implementations thereof.
|
|
62
|
+
|
|
63
|
+
2. Waiver. To the greatest extent permitted by, but not in contravention
|
|
64
|
+
of, applicable law, Affirmer hereby overtly, fully, permanently,
|
|
65
|
+
irrevocably and unconditionally waives, abandons, and surrenders all of
|
|
66
|
+
Affirmer's Copyright and Related Rights and associated claims and causes
|
|
67
|
+
of action, whether now known or unknown (including existing as well as
|
|
68
|
+
future claims and causes of action), in the Work (i) in all territories
|
|
69
|
+
worldwide, (ii) for the maximum duration provided by applicable law or
|
|
70
|
+
treaty (including future time extensions), (iii) in any current or future
|
|
71
|
+
medium and for any number of copies, and (iv) for any purpose whatsoever,
|
|
72
|
+
including without limitation commercial, advertising or promotional
|
|
73
|
+
purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
|
|
74
|
+
member of the public at large and to the detriment of Affirmer's heirs and
|
|
75
|
+
successors, fully intending that such Waiver shall not be subject to
|
|
76
|
+
revocation, rescission, cancellation, termination, or any other legal or
|
|
77
|
+
equitable action to disrupt the quiet enjoyment of the Work by the public
|
|
78
|
+
as contemplated by Affirmer's express Statement of Purpose.
|
|
79
|
+
|
|
80
|
+
3. Public License Fallback. Should any part of the Waiver for any reason
|
|
81
|
+
be judged legally invalid or ineffective under applicable law, then the
|
|
82
|
+
Waiver shall be preserved to the maximum extent permitted taking into
|
|
83
|
+
account Affirmer's express Statement of Purpose. In addition, to the
|
|
84
|
+
extent the Waiver is so judged Affirmer hereby grants to each affected
|
|
85
|
+
person a royalty-free, non transferable, non sublicensable, non exclusive,
|
|
86
|
+
irrevocable and unconditional license to exercise Affirmer's Copyright and
|
|
87
|
+
Related Rights in the Work (i) in all territories worldwide, (ii) for the
|
|
88
|
+
maximum duration provided by applicable law or treaty (including future
|
|
89
|
+
time extensions), (iii) in any current or future medium and for any number
|
|
90
|
+
of copies, and (iv) for any purpose whatsoever, including without
|
|
91
|
+
limitation commercial, advertising or promotional purposes (the
|
|
92
|
+
"License"). The License shall be deemed effective as of the date CC0 was
|
|
93
|
+
applied by Affirmer to the Work. Should any part of the License for any
|
|
94
|
+
reason be judged legally invalid or ineffective under applicable law, such
|
|
95
|
+
partial invalidity or ineffectiveness shall not invalidate the remainder
|
|
96
|
+
of the License, and in such case Affirmer hereby affirms that he or she
|
|
97
|
+
will not (i) exercise any of his or her remaining Copyright and Related
|
|
98
|
+
Rights in the Work or (ii) assert any associated claims and causes of
|
|
99
|
+
action with respect to the Work, in either case contrary to Affirmer's
|
|
100
|
+
express Statement of Purpose.
|
|
101
|
+
|
|
102
|
+
4. Limitations and Disclaimers.
|
|
103
|
+
|
|
104
|
+
a. No trademark or patent rights held by Affirmer are waived, abandoned,
|
|
105
|
+
surrendered, licensed or otherwise affected by this document.
|
|
106
|
+
b. Affirmer offers the Work as-is and makes no representations or
|
|
107
|
+
warranties of any kind concerning the Work, express, implied,
|
|
108
|
+
statutory or otherwise, including without limitation warranties of
|
|
109
|
+
title, merchantability, fitness for a particular purpose, non
|
|
110
|
+
infringement, or the absence of latent or other defects, accuracy, or
|
|
111
|
+
the present or absence of errors, whether or not discoverable, all to
|
|
112
|
+
the greatest extent permissible under applicable law.
|
|
113
|
+
c. Affirmer disclaims responsibility for clearing rights of other persons
|
|
114
|
+
that may apply to the Work or any use thereof, including without
|
|
115
|
+
limitation any person's Copyright and Related Rights in the Work.
|
|
116
|
+
Further, Affirmer disclaims responsibility for obtaining any necessary
|
|
117
|
+
consents, permissions or other rights required for any use of the
|
|
118
|
+
Work.
|
|
119
|
+
d. Affirmer understands and acknowledges that Creative Commons is not a
|
|
120
|
+
party to this document and has no duty or obligation with respect to
|
|
121
|
+
this CC0 or use of the Work.
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: spatial-reasoner
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A flexible 3D spatial reasoning library for Python
|
|
5
|
+
Author: Steven Häsler, Philipp Ackermann
|
|
6
|
+
License-Expression: CC0-1.0
|
|
7
|
+
Project-URL: Documentation, https://github.com/metason/SpatialReasoner
|
|
8
|
+
Project-URL: Issues, https://github.com/metason/SRpy/issues
|
|
9
|
+
Project-URL: Paper, https://doi.org/10.1109/ICVARS66454.2025.11198690
|
|
10
|
+
Project-URL: Repository, https://github.com/metason/SRpy
|
|
11
|
+
Keywords: 3d,inference,reasoning,spatial,xr
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Intended Audience :: Science/Research
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
22
|
+
Classifier: Topic :: Scientific/Engineering
|
|
23
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
24
|
+
Requires-Python: >=3.11
|
|
25
|
+
Description-Content-Type: text/markdown
|
|
26
|
+
License-File: LICENSE
|
|
27
|
+
Requires-Dist: numpy>=1.26
|
|
28
|
+
Provides-Extra: export
|
|
29
|
+
Requires-Dist: usd-core>=25.2; extra == "export"
|
|
30
|
+
Provides-Extra: test
|
|
31
|
+
Requires-Dist: coverage[toml]<8,>=7; extra == "test"
|
|
32
|
+
Requires-Dist: pytest<9,>=8; extra == "test"
|
|
33
|
+
Provides-Extra: dev
|
|
34
|
+
Requires-Dist: build<2,>=1.3; extra == "dev"
|
|
35
|
+
Requires-Dist: ruff<0.17,>=0.16; extra == "dev"
|
|
36
|
+
Requires-Dist: twine<7,>=6.2; extra == "dev"
|
|
37
|
+
Dynamic: license-file
|
|
38
|
+
|
|
39
|
+
# Spatial Reasoner for Python
|
|
40
|
+
|
|
41
|
+
`spatial-reasoner` is a 3D spatial-reasoning library derived from the CC0
|
|
42
|
+
[SRSwift reference implementation](https://github.com/metason/SpatialReasoner). It models
|
|
43
|
+
oriented spatial objects and evaluates explicit pipelines for topology, directionality,
|
|
44
|
+
visibility, connectivity, comparison, and similarity predicates.
|
|
45
|
+
|
|
46
|
+
This is an alpha release. Version 0.1.x preserves the SRSwift-facing camelCase API and
|
|
47
|
+
reasoning behavior, but the Python package API may still evolve before 1.0.
|
|
48
|
+
|
|
49
|
+
## Installation
|
|
50
|
+
|
|
51
|
+
Spatial Reasoner supports Python 3.11 through 3.14.
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
python -m pip install spatial-reasoner
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
OpenUSD scene export is optional:
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
python -m pip install "spatial-reasoner[export]"
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Quick start
|
|
64
|
+
|
|
65
|
+
The principal classes are available directly from `spatial_reasoner`:
|
|
66
|
+
|
|
67
|
+
```python
|
|
68
|
+
from spatial_reasoner import SpatialObject, SpatialReasoner, Vector3
|
|
69
|
+
|
|
70
|
+
crate = SpatialObject(
|
|
71
|
+
"crate",
|
|
72
|
+
position=Vector3(0.0, 0.0, 0.0),
|
|
73
|
+
width=2.0,
|
|
74
|
+
height=2.0,
|
|
75
|
+
depth=2.0,
|
|
76
|
+
)
|
|
77
|
+
marker = SpatialObject(
|
|
78
|
+
"marker",
|
|
79
|
+
position=Vector3(3.0, 0.0, 0.0),
|
|
80
|
+
width=0.1,
|
|
81
|
+
height=0.1,
|
|
82
|
+
depth=0.1,
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
reasoner = SpatialReasoner()
|
|
86
|
+
reasoner.load([crate, marker])
|
|
87
|
+
assert reasoner.run("filter(volume > 0.5)")
|
|
88
|
+
assert [obj.id for obj in reasoner.result()] == ["crate"]
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Pipeline predicates may be addressed by their SRSwift-compatible enum names. For example,
|
|
92
|
+
`seenleft` selects the predicate whose readable value is `"seen left"`.
|
|
93
|
+
|
|
94
|
+
> [!WARNING]
|
|
95
|
+
> Pipeline filter, select, map, calculate, and produce expressions use dynamic evaluation.
|
|
96
|
+
> Never accept pipeline text or expression fragments from an untrusted source without an
|
|
97
|
+
> external validator and a strict allowlist.
|
|
98
|
+
|
|
99
|
+
## OpenUSD export
|
|
100
|
+
|
|
101
|
+
Import the exporter from its optional module so normal package imports never require OpenUSD:
|
|
102
|
+
|
|
103
|
+
```python
|
|
104
|
+
from spatial_reasoner import SpatialObject
|
|
105
|
+
from spatial_reasoner.exporter import SceneExporter
|
|
106
|
+
|
|
107
|
+
objects = [SpatialObject("box")]
|
|
108
|
+
SceneExporter("exports").exportUSDZ(objects, "scene.usdz")
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
The exporter uses OpenUSD's packaging API and does not require an external `usdzip` executable.
|
|
112
|
+
|
|
113
|
+
## Status and parity
|
|
114
|
+
|
|
115
|
+
- The reasoning classes, method names, predicates, formulas, and pipeline behavior track SRSwift.
|
|
116
|
+
- CamelCase methods are retained deliberately for cross-language parity.
|
|
117
|
+
- The experimental font-based 3D utility is not distributed.
|
|
118
|
+
- Type annotations are incomplete; this distribution does not claim PEP 561 typed-package status.
|
|
119
|
+
|
|
120
|
+
Full conceptual documentation lives in the
|
|
121
|
+
[SpatialReasoner repository](https://github.com/metason/SpatialReasoner).
|
|
122
|
+
|
|
123
|
+
## Development
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
python -m pip install -e ".[test,dev]"
|
|
127
|
+
ruff check src tests
|
|
128
|
+
ruff format --check src tests
|
|
129
|
+
coverage run -m pytest -m "not export and not distribution"
|
|
130
|
+
coverage report
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
To run the optional exporter test, install `.[export,test]` and run
|
|
134
|
+
`pytest -m export`. Function-length and complexity checks are intentionally not part of the
|
|
135
|
+
style policy because the reasoning implementation follows its reference implementation.
|
|
136
|
+
|
|
137
|
+
## Citation
|
|
138
|
+
|
|
139
|
+
If this software supports your research, cite Häsler and Ackermann, “Spatial Reasoner: A 3D
|
|
140
|
+
Inference Pipeline for XR Applications” (2025),
|
|
141
|
+
[doi:10.1109/ICVARS66454.2025.11198690](https://doi.org/10.1109/ICVARS66454.2025.11198690).
|
|
142
|
+
|
|
143
|
+
## License
|
|
144
|
+
|
|
145
|
+
Spatial Reasoner for Python is released under [CC0-1.0](LICENSE).
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
# Spatial Reasoner for Python
|
|
2
|
+
|
|
3
|
+
`spatial-reasoner` is a 3D spatial-reasoning library derived from the CC0
|
|
4
|
+
[SRSwift reference implementation](https://github.com/metason/SpatialReasoner). It models
|
|
5
|
+
oriented spatial objects and evaluates explicit pipelines for topology, directionality,
|
|
6
|
+
visibility, connectivity, comparison, and similarity predicates.
|
|
7
|
+
|
|
8
|
+
This is an alpha release. Version 0.1.x preserves the SRSwift-facing camelCase API and
|
|
9
|
+
reasoning behavior, but the Python package API may still evolve before 1.0.
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
|
|
13
|
+
Spatial Reasoner supports Python 3.11 through 3.14.
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
python -m pip install spatial-reasoner
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
OpenUSD scene export is optional:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
python -m pip install "spatial-reasoner[export]"
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Quick start
|
|
26
|
+
|
|
27
|
+
The principal classes are available directly from `spatial_reasoner`:
|
|
28
|
+
|
|
29
|
+
```python
|
|
30
|
+
from spatial_reasoner import SpatialObject, SpatialReasoner, Vector3
|
|
31
|
+
|
|
32
|
+
crate = SpatialObject(
|
|
33
|
+
"crate",
|
|
34
|
+
position=Vector3(0.0, 0.0, 0.0),
|
|
35
|
+
width=2.0,
|
|
36
|
+
height=2.0,
|
|
37
|
+
depth=2.0,
|
|
38
|
+
)
|
|
39
|
+
marker = SpatialObject(
|
|
40
|
+
"marker",
|
|
41
|
+
position=Vector3(3.0, 0.0, 0.0),
|
|
42
|
+
width=0.1,
|
|
43
|
+
height=0.1,
|
|
44
|
+
depth=0.1,
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
reasoner = SpatialReasoner()
|
|
48
|
+
reasoner.load([crate, marker])
|
|
49
|
+
assert reasoner.run("filter(volume > 0.5)")
|
|
50
|
+
assert [obj.id for obj in reasoner.result()] == ["crate"]
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Pipeline predicates may be addressed by their SRSwift-compatible enum names. For example,
|
|
54
|
+
`seenleft` selects the predicate whose readable value is `"seen left"`.
|
|
55
|
+
|
|
56
|
+
> [!WARNING]
|
|
57
|
+
> Pipeline filter, select, map, calculate, and produce expressions use dynamic evaluation.
|
|
58
|
+
> Never accept pipeline text or expression fragments from an untrusted source without an
|
|
59
|
+
> external validator and a strict allowlist.
|
|
60
|
+
|
|
61
|
+
## OpenUSD export
|
|
62
|
+
|
|
63
|
+
Import the exporter from its optional module so normal package imports never require OpenUSD:
|
|
64
|
+
|
|
65
|
+
```python
|
|
66
|
+
from spatial_reasoner import SpatialObject
|
|
67
|
+
from spatial_reasoner.exporter import SceneExporter
|
|
68
|
+
|
|
69
|
+
objects = [SpatialObject("box")]
|
|
70
|
+
SceneExporter("exports").exportUSDZ(objects, "scene.usdz")
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
The exporter uses OpenUSD's packaging API and does not require an external `usdzip` executable.
|
|
74
|
+
|
|
75
|
+
## Status and parity
|
|
76
|
+
|
|
77
|
+
- The reasoning classes, method names, predicates, formulas, and pipeline behavior track SRSwift.
|
|
78
|
+
- CamelCase methods are retained deliberately for cross-language parity.
|
|
79
|
+
- The experimental font-based 3D utility is not distributed.
|
|
80
|
+
- Type annotations are incomplete; this distribution does not claim PEP 561 typed-package status.
|
|
81
|
+
|
|
82
|
+
Full conceptual documentation lives in the
|
|
83
|
+
[SpatialReasoner repository](https://github.com/metason/SpatialReasoner).
|
|
84
|
+
|
|
85
|
+
## Development
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
python -m pip install -e ".[test,dev]"
|
|
89
|
+
ruff check src tests
|
|
90
|
+
ruff format --check src tests
|
|
91
|
+
coverage run -m pytest -m "not export and not distribution"
|
|
92
|
+
coverage report
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
To run the optional exporter test, install `.[export,test]` and run
|
|
96
|
+
`pytest -m export`. Function-length and complexity checks are intentionally not part of the
|
|
97
|
+
style policy because the reasoning implementation follows its reference implementation.
|
|
98
|
+
|
|
99
|
+
## Citation
|
|
100
|
+
|
|
101
|
+
If this software supports your research, cite Häsler and Ackermann, “Spatial Reasoner: A 3D
|
|
102
|
+
Inference Pipeline for XR Applications” (2025),
|
|
103
|
+
[doi:10.1109/ICVARS66454.2025.11198690](https://doi.org/10.1109/ICVARS66454.2025.11198690).
|
|
104
|
+
|
|
105
|
+
## License
|
|
106
|
+
|
|
107
|
+
Spatial Reasoner for Python is released under [CC0-1.0](LICENSE).
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=77"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "spatial-reasoner"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "A flexible 3D spatial reasoning library for Python"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.11"
|
|
11
|
+
license = "CC0-1.0"
|
|
12
|
+
license-files = ["LICENSE"]
|
|
13
|
+
authors = [
|
|
14
|
+
{ name = "Steven Häsler" },
|
|
15
|
+
{ name = "Philipp Ackermann" },
|
|
16
|
+
]
|
|
17
|
+
keywords = ["3d", "inference", "reasoning", "spatial", "xr"]
|
|
18
|
+
classifiers = [
|
|
19
|
+
"Development Status :: 3 - Alpha",
|
|
20
|
+
"Intended Audience :: Developers",
|
|
21
|
+
"Intended Audience :: Science/Research",
|
|
22
|
+
"Operating System :: OS Independent",
|
|
23
|
+
"Programming Language :: Python :: 3",
|
|
24
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
25
|
+
"Programming Language :: Python :: 3.11",
|
|
26
|
+
"Programming Language :: Python :: 3.12",
|
|
27
|
+
"Programming Language :: Python :: 3.13",
|
|
28
|
+
"Programming Language :: Python :: 3.14",
|
|
29
|
+
"Topic :: Scientific/Engineering",
|
|
30
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
31
|
+
]
|
|
32
|
+
dependencies = ["numpy>=1.26"]
|
|
33
|
+
|
|
34
|
+
[project.optional-dependencies]
|
|
35
|
+
export = ["usd-core>=25.2"]
|
|
36
|
+
test = [
|
|
37
|
+
"coverage[toml]>=7,<8",
|
|
38
|
+
"pytest>=8,<9",
|
|
39
|
+
]
|
|
40
|
+
dev = [
|
|
41
|
+
"build>=1.3,<2",
|
|
42
|
+
"ruff>=0.16,<0.17",
|
|
43
|
+
"twine>=6.2,<7",
|
|
44
|
+
]
|
|
45
|
+
|
|
46
|
+
[project.urls]
|
|
47
|
+
Documentation = "https://github.com/metason/SpatialReasoner"
|
|
48
|
+
Issues = "https://github.com/metason/SRpy/issues"
|
|
49
|
+
Paper = "https://doi.org/10.1109/ICVARS66454.2025.11198690"
|
|
50
|
+
Repository = "https://github.com/metason/SRpy"
|
|
51
|
+
|
|
52
|
+
[tool.setuptools]
|
|
53
|
+
include-package-data = false
|
|
54
|
+
|
|
55
|
+
[tool.setuptools.packages.find]
|
|
56
|
+
where = ["src"]
|
|
57
|
+
include = ["spatial_reasoner*"]
|
|
58
|
+
|
|
59
|
+
[tool.pytest.ini_options]
|
|
60
|
+
addopts = "-ra"
|
|
61
|
+
testpaths = ["tests"]
|
|
62
|
+
markers = [
|
|
63
|
+
"distribution: artifact-content tests run after building the package",
|
|
64
|
+
"export: tests requiring the optional OpenUSD exporter dependency",
|
|
65
|
+
]
|
|
66
|
+
|
|
67
|
+
[tool.coverage.run]
|
|
68
|
+
branch = true
|
|
69
|
+
source = ["spatial_reasoner"]
|
|
70
|
+
|
|
71
|
+
[tool.coverage.report]
|
|
72
|
+
fail_under = 70
|
|
73
|
+
show_missing = true
|
|
74
|
+
skip_covered = false
|
|
75
|
+
|
|
76
|
+
[tool.ruff]
|
|
77
|
+
line-length = 100
|
|
78
|
+
target-version = "py311"
|
|
79
|
+
|
|
80
|
+
[tool.ruff.lint]
|
|
81
|
+
select = ["E4", "E7", "E9", "F", "I", "B", "UP", "RUF012"]
|
|
82
|
+
|
|
83
|
+
[tool.ruff.format]
|
|
84
|
+
docstring-code-format = true
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"""Public API for the Spatial Reasoner Python implementation."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from importlib.metadata import PackageNotFoundError, version
|
|
6
|
+
|
|
7
|
+
from .bbox_sector import BBoxSector, BBoxSectorFlags
|
|
8
|
+
from .reasoner import SpatialReasoner
|
|
9
|
+
from .spatial_basics import (
|
|
10
|
+
MotionState,
|
|
11
|
+
NearbySchema,
|
|
12
|
+
ObjectCause,
|
|
13
|
+
ObjectConfidence,
|
|
14
|
+
ObjectHandling,
|
|
15
|
+
ObjectShape,
|
|
16
|
+
SectorSchema,
|
|
17
|
+
SpatialAdjustment,
|
|
18
|
+
SpatialAtribute,
|
|
19
|
+
SpatialExistence,
|
|
20
|
+
SpatialPredicateCategories,
|
|
21
|
+
defaultAdjustment,
|
|
22
|
+
)
|
|
23
|
+
from .spatial_inference import SpatialInference
|
|
24
|
+
from .spatial_object import SpatialObject
|
|
25
|
+
from .spatial_predicate import (
|
|
26
|
+
PredicateTerm,
|
|
27
|
+
SpatialPredicate,
|
|
28
|
+
SpatialTerms,
|
|
29
|
+
adjacency,
|
|
30
|
+
assembly,
|
|
31
|
+
comparability,
|
|
32
|
+
connectivity,
|
|
33
|
+
contacts,
|
|
34
|
+
directionality,
|
|
35
|
+
geography,
|
|
36
|
+
orientations,
|
|
37
|
+
proximity,
|
|
38
|
+
sectors,
|
|
39
|
+
similarity,
|
|
40
|
+
topology,
|
|
41
|
+
visibility,
|
|
42
|
+
)
|
|
43
|
+
from .spatial_relation import SpatialRelation
|
|
44
|
+
from .spatial_taxonomy import SpatialObjectConcept, SpatialTaxonomy, TaxonomyParser
|
|
45
|
+
from .vector2 import Vector2
|
|
46
|
+
from .vector3 import Vector3
|
|
47
|
+
|
|
48
|
+
try:
|
|
49
|
+
__version__ = version("spatial-reasoner")
|
|
50
|
+
except PackageNotFoundError: # pragma: no cover - direct source-tree import
|
|
51
|
+
__version__ = "0.1.0"
|
|
52
|
+
|
|
53
|
+
__all__ = [
|
|
54
|
+
"BBoxSector",
|
|
55
|
+
"BBoxSectorFlags",
|
|
56
|
+
"MotionState",
|
|
57
|
+
"NearbySchema",
|
|
58
|
+
"ObjectCause",
|
|
59
|
+
"ObjectConfidence",
|
|
60
|
+
"ObjectHandling",
|
|
61
|
+
"ObjectShape",
|
|
62
|
+
"PredicateTerm",
|
|
63
|
+
"SectorSchema",
|
|
64
|
+
"SpatialAdjustment",
|
|
65
|
+
"SpatialAtribute",
|
|
66
|
+
"SpatialExistence",
|
|
67
|
+
"SpatialInference",
|
|
68
|
+
"SpatialObject",
|
|
69
|
+
"SpatialObjectConcept",
|
|
70
|
+
"SpatialPredicate",
|
|
71
|
+
"SpatialPredicateCategories",
|
|
72
|
+
"SpatialReasoner",
|
|
73
|
+
"SpatialRelation",
|
|
74
|
+
"SpatialTaxonomy",
|
|
75
|
+
"SpatialTerms",
|
|
76
|
+
"TaxonomyParser",
|
|
77
|
+
"Vector2",
|
|
78
|
+
"Vector3",
|
|
79
|
+
"__version__",
|
|
80
|
+
"adjacency",
|
|
81
|
+
"assembly",
|
|
82
|
+
"comparability",
|
|
83
|
+
"connectivity",
|
|
84
|
+
"contacts",
|
|
85
|
+
"defaultAdjustment",
|
|
86
|
+
"directionality",
|
|
87
|
+
"geography",
|
|
88
|
+
"orientations",
|
|
89
|
+
"proximity",
|
|
90
|
+
"sectors",
|
|
91
|
+
"similarity",
|
|
92
|
+
"topology",
|
|
93
|
+
"visibility",
|
|
94
|
+
]
|