Skip to content

Commit ed94e2e

Browse files
authored
Fix spine annotation schema (#102)
* fix spine annotation schema * formatting * fix tests
1 parent 73e3e3a commit ed94e2e

File tree

2 files changed

+20
-14
lines changed

2 files changed

+20
-14
lines changed

emannotationschemas/schemas/postsynaptic_compartment.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
import marshmallow as mm
22
from marshmallow.validate import OneOf
33

4-
from emannotationschemas.schemas.base import BoundSpatialPoint, ReferenceAnnotation
4+
from emannotationschemas.schemas.base import (
5+
AnnotationSchema,
6+
BoundSpatialPoint,
7+
ReferenceAnnotation,
8+
)
59

610
allowed_compartments = [
711
"soma",
@@ -32,7 +36,13 @@ class PostsynapticCompartment(ReferenceAnnotation):
3236
)
3337

3438

35-
class SpineWithInfo(BoundSpatialPoint):
39+
class SpineWithInfo(AnnotationSchema):
40+
pt = mm.fields.Nested(
41+
BoundSpatialPoint,
42+
required=True,
43+
description="Spatial point representing the location of the spine",
44+
)
45+
3646
volume = mm.fields.Float(
3747
required=False, description="Estimated volume of the spine"
3848
)

tests/test_spine.py

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
from emannotationschemas.schemas.postsynaptic_compartment import SpineWithInfo
22

33
good_spine_with_info = {
4-
"position": [100, 200, 300],
5-
"supervoxel_id": 50,
6-
"root_id": 10,
4+
"pt": {"position": [100, 200, 300], "supervoxel_id": 50, "root_id": 10},
75
"volume": 1.5,
86
"n_inputs": 3,
97
}
@@ -12,9 +10,9 @@
1210
def test_spine_with_info_schema():
1311
schema = SpineWithInfo()
1412
result = schema.load(good_spine_with_info)
15-
assert result["position"] == [100, 200, 300]
16-
assert result["supervoxel_id"] == 50
17-
assert result["root_id"] == 10
13+
assert result['pt']["position"] == [100, 200, 300]
14+
assert result['pt']["supervoxel_id"] == 50
15+
assert result['pt']["root_id"] == 10
1816
assert result["volume"] == 1.5
1917
assert result["n_inputs"] == 3
2018

@@ -23,13 +21,11 @@ def test_spine_with_info_optional():
2321
schema = SpineWithInfo()
2422
result = schema.load(
2523
{
26-
"position": [100, 200, 300],
27-
"supervoxel_id": 50,
28-
"root_id": 10,
24+
"pt": {"position": [100, 200, 300], "supervoxel_id": 50, "root_id": 10},
2925
}
3026
)
31-
assert result["position"] == [100, 200, 300]
32-
assert result["supervoxel_id"] == 50
33-
assert result["root_id"] == 10
27+
assert result['pt']["position"] == [100, 200, 300]
28+
assert result['pt']["supervoxel_id"] == 50
29+
assert result['pt']["root_id"] == 10
3430
assert "volume" not in result
3531
assert "n_inputs" not in result

0 commit comments

Comments
 (0)