Skip to content

Commit

Permalink
Improve JSON schemas and add them in the documentation
Browse files Browse the repository at this point in the history
Change-Id: I405df310ad3a9385cd1f947ce92cfa59c78a387b
  • Loading branch information
adrien-berchet committed May 4, 2021
1 parent f2e2036 commit 1760dee
Show file tree
Hide file tree
Showing 8 changed files with 511 additions and 124 deletions.
1 change: 1 addition & 0 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"sphinx.ext.graphviz",
"sphinx.ext.napoleon",
"sphinx.ext.intersphinx",
"sphinx-jsonschema",
]

# Add any paths that contain templates here, relative to this directory.
Expand Down
1 change: 1 addition & 0 deletions doc/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
:maxdepth: 2

Home <self>
params_and_distrs
changelog
api
21 changes: 21 additions & 0 deletions doc/source/params_and_distrs.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Parameters and distributions
============================

This page describes the format of the expected parameters and distributions used by TNS.

Parameters
----------

.. jsonschema:: ../../tns/schemas/parameters.json
:lift_definitions:
:auto_reference:
:auto_target:


Distributions
-------------

.. jsonschema:: ../../tns/schemas/distributions.json
:lift_definitions:
:auto_reference:
:auto_target:
30 changes: 30 additions & 0 deletions tests/test_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,36 @@ def test_validate_params():
data['apical']['orientation'] = None
tested.validate_neuron_params(data)

# If method != external it should not have any other entry than 'method'
data['diameter_params'] = {
"method": "default"
}
tested.validate_neuron_params(data)

data['diameter_params'] = {
"method": "default",
"other key": "any value"
}
assert_raises(ValidationError, tested.validate_neuron_params, data)

data['diameter_params'] = {
"method": "M1",
"other key": "any value"
}
assert_raises(ValidationError, tested.validate_neuron_params, data)

# If method == external it may have any other entry than 'method'
data['diameter_params'] = {
"method": "external"
}
tested.validate_neuron_params(data)

data['diameter_params'] = {
"method": "external",
"other key": "any value"
}
tested.validate_neuron_params(data)

# It must be a list of vectors, not a single one
data['apical']['orientation'] = [0, 0, 0]
assert_raises(ValidationError, tested.validate_neuron_params, data)
Expand Down
Loading

0 comments on commit 1760dee

Please sign in to comment.