From ae46fd862b396a1d1940fb626ea0e159120231a4 Mon Sep 17 00:00:00 2001 From: Eleftherios Zisis Date: Tue, 10 May 2022 13:30:49 +0200 Subject: [PATCH 01/15] Enable doctest in sphinx --- doc/source/conf.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/doc/source/conf.py b/doc/source/conf.py index e2629ed7..40c58846 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -60,8 +60,17 @@ 'sphinx.ext.autodoc', 'sphinx.ext.autosummary', 'sphinx.ext.napoleon', + 'sphinx.ext.doctest', ] +# code that will be executed for each test +doctest_global_setup = """ + +morphology_path = "../tests/data/swc/simple.swc" +morphologies_dir = "../tests/data/valid_set/" + +""" + # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] From ab199b97c5c9f627e74c6b929d79f09f06a80b91 Mon Sep 17 00:00:00 2001 From: Eleftherios Zisis Date: Tue, 10 May 2022 13:31:06 +0200 Subject: [PATCH 02/15] Fix modules to pass with doctest --- neurom/core/morphology.py | 4 +++- neurom/features/__init__.py | 2 +- neurom/features/morphology.py | 8 ++++---- neurom/features/neurite.py | 9 +++++---- neurom/features/population.py | 4 ++-- 5 files changed, 15 insertions(+), 12 deletions(-) diff --git a/neurom/core/morphology.py b/neurom/core/morphology.py index 6e4aa0f5..96941705 100644 --- a/neurom/core/morphology.py +++ b/neurom/core/morphology.py @@ -255,13 +255,15 @@ def iter_neurites( >>> from neurom.core.morphology import iter_neurites >>> from neurom import load_morphologies - >>> pop = load_morphologies('path/to/morphologies') + >>> pop = load_morphologies(morphologies_dir) >>> n_points = [n for n in iter_neurites(pop, lambda x : len(x.points))] Get the number of points in each axon in a morphology population >>> import neurom as nm >>> from neurom.core.morphology import iter_neurites + >>> from neurom import load_morphologies + >>> pop = load_morphologies(morphologies_dir) >>> filter = lambda n : n.type == nm.AXON >>> mapping = lambda n : len(n.points) >>> n_points = [n for n in iter_neurites(pop, mapping, filter)] diff --git a/neurom/features/__init__.py b/neurom/features/__init__.py index 7c327bff..0a1b066f 100644 --- a/neurom/features/__init__.py +++ b/neurom/features/__init__.py @@ -32,7 +32,7 @@ Obtain some morphometrics >>> import neurom >>> from neurom import features - >>> m = neurom.load_morphology('path/to/morphology') + >>> m = neurom.load_morphology(morphology_path) >>> ap_seg_len = features.get('segment_lengths', m, neurite_type=neurom.APICAL_DENDRITE) >>> ax_sec_len = features.get('section_lengths', m, neurite_type=neurom.AXON) """ diff --git a/neurom/features/morphology.py b/neurom/features/morphology.py index af885976..eaaa867d 100644 --- a/neurom/features/morphology.py +++ b/neurom/features/morphology.py @@ -35,10 +35,10 @@ >>> import neurom >>> from neurom import features ->>> m = neurom.load_morphology('path/to/morphology') ->>> features.get('soma_surface_area', m) ->>> population = neurom.load_morphologies('path/to/morphs') ->>> features.get('sholl_crossings', population) +>>> m = neurom.load_morphology(morphology_path) +>>> result = features.get('soma_surface_area', m) +>>> population = neurom.load_morphologies(morphologies_dir) +>>> result = features.get('sholl_crossings', population) For more details see :ref:`features`. """ diff --git a/neurom/features/neurite.py b/neurom/features/neurite.py index 52f77019..4ed24188 100644 --- a/neurom/features/neurite.py +++ b/neurom/features/neurite.py @@ -35,10 +35,11 @@ >>> import neurom >>> from neurom import features ->>> m = neurom.load_morphology('path/to/morphology') ->>> features.get('max_radial_distance', m.neurites[0]) ->>> features.get('max_radial_distance', m) ->>> features.get('number_of_segments', m.neurites, neurite_type=neurom.AXON) +>>> m = neurom.load_morphology(morphology_path) +>>> max_radial_distances1 = features.get('max_radial_distance', m.neurites) +>>> max_radial_distances2 = features.get('max_radial_distance', m.neurites[0]) +>>> max_radial_distances3 = features.get('max_radial_distance', m) +>>> n_segments = features.get('number_of_segments', m, neurite_type=neurom.AXON) For more details see :ref:`features`. """ diff --git a/neurom/features/population.py b/neurom/features/population.py index 14fac2e1..b49d1c9d 100644 --- a/neurom/features/population.py +++ b/neurom/features/population.py @@ -33,8 +33,8 @@ >>> import neurom >>> from neurom import features ->>> pop = neurom.load_morphologies('path/to/morphs') ->>> features.get('sholl_frequency', pop) +>>> pop = neurom.load_morphologies(morphologies_dir) +>>> frequencies = features.get('sholl_frequency', pop) For more details see :ref:`features`. """ From febc294b7a5af5a37ba89aab1d714aa01f44913d Mon Sep 17 00:00:00 2001 From: Eleftherios Zisis Date: Tue, 10 May 2022 13:57:00 +0200 Subject: [PATCH 03/15] Fix docstrings snippets --- doc/source/conf.py | 2 +- neurom/core/types.py | 8 ++++---- neurom/morphmath.py | 7 ------- 3 files changed, 5 insertions(+), 12 deletions(-) diff --git a/doc/source/conf.py b/doc/source/conf.py index 40c58846..0255cd5c 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -66,7 +66,7 @@ # code that will be executed for each test doctest_global_setup = """ -morphology_path = "../tests/data/swc/simple.swc" +morphology_path = "../tests/data/swc/Neuron.swc" morphologies_dir = "../tests/data/valid_set/" """ diff --git a/neurom/core/types.py b/neurom/core/types.py index 9853504a..6a3718be 100644 --- a/neurom/core/types.py +++ b/neurom/core/types.py @@ -85,14 +85,14 @@ def tree_type_checker(*ref): Ex: >>> import neurom >>> from neurom.core.types import NeuriteType, tree_type_checker - >>> from neurom.core.morphology import Section - >>> m = neurom.load_morphology('path') + >>> from neurom.core.morphology import Section, iter_neurites + >>> m = neurom.load_morphology(morphology_path) >>> >>> tree_filter = tree_type_checker(NeuriteType.axon, NeuriteType.basal_dendrite) - >>> m.i_neurites(Section.ipreorder, tree_filter=tree_filter) + >>> it = iter_neurites(m, filt=tree_filter) >>> >>> tree_filter = tree_type_checker((NeuriteType.axon, NeuriteType.basal_dendrite)) - >>> m.i_neurites(Section.ipreorder, tree_filter=tree_filter) + >>> it = iter_neurites(m, filt=tree_filter) """ ref = tuple(ref) if len(ref) == 1 and isinstance(ref[0], tuple): diff --git a/neurom/morphmath.py b/neurom/morphmath.py index 088fe057..d802b5a2 100644 --- a/neurom/morphmath.py +++ b/neurom/morphmath.py @@ -242,13 +242,6 @@ def angle_between_vectors(p1, p2): Normalizes the input vectors and computes the relative angle between them. - - >>> angle_between((1, 0), (0, 1)) - 1.5707963267948966 - >>> angle_between((1, 0), (1, 0)) - 0.0 - >>> angle_between((1, 0), (-1, 0)) - 3.141592653589793 """ if np.equal(p1, p2).all(): return 0.0 From 41567fe0618e54cc575a0f87a13817c11282f124 Mon Sep 17 00:00:00 2001 From: Eleftherios Zisis Date: Tue, 10 May 2022 14:48:59 +0200 Subject: [PATCH 04/15] update documentation --- doc/source/developer.rst | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/doc/source/developer.rst b/doc/source/developer.rst index 4cc0a21b..0c9eed74 100644 --- a/doc/source/developer.rst +++ b/doc/source/developer.rst @@ -59,9 +59,10 @@ individually: .. code-block:: bash - $ tox -e py36-lint # runs only pylint - $ tox -e py36-docs # run only documentation check - $ tox -e py36 # run only the tests + $ tox -e py38-lint # runs only pylint + $ tox -e py38-docs # run only documentation check + $ tox -e py38-coverage # run only coverage check + $ tox -e py38 # run only the tests You can also run tests manually via `pylint` but you need to make sure that you have installed all required dependencies in your virtual environment: From 0b24dc20f51324b418d97ec14658eeda88ef7eb6 Mon Sep 17 00:00:00 2001 From: Eleftherios Zisis Date: Tue, 10 May 2022 18:16:32 +0200 Subject: [PATCH 05/15] Add sphinx doctest to testenv --- tox.ini | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index d1853272..bdff5ec5 100644 --- a/tox.ini +++ b/tox.ini @@ -3,6 +3,7 @@ name = neurom testdeps = mock pytest>3.0 + sphinx [tox] envlist = @@ -15,7 +16,9 @@ envlist = [testenv] deps = {[base]testdeps} extras = plotly -commands = pytest {posargs} +commands = + sphinx-build -b doctest -d {toxinidir}/doc/build/doctrees {toxinidir}/doc/source {toxinidir}/doc/build/doctest + pytest {posargs} [testenv:lint] basepython=python3.7 From 9862d320bd3ac78738a5e6a41b2da70aac48df42 Mon Sep 17 00:00:00 2001 From: Eleftherios Zisis Date: Tue, 10 May 2022 18:18:01 +0200 Subject: [PATCH 06/15] Convert code snippets into testable code --- doc/source/conf.py | 6 ++-- doc/source/examples.rst | 10 +++---- doc/source/features.rst | 49 ++++++++++++++++++++------------ doc/source/heterogeneous.rst | 54 +++++++++++++++++++----------------- doc/source/migration.rst | 11 ++++---- doc/source/quickstart.rst | 9 +++--- doc/source/validation.rst | 8 +++--- 7 files changed, 81 insertions(+), 66 deletions(-) diff --git a/doc/source/conf.py b/doc/source/conf.py index 0255cd5c..82734041 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -65,10 +65,8 @@ # code that will be executed for each test doctest_global_setup = """ - -morphology_path = "../tests/data/swc/Neuron.swc" -morphologies_dir = "../tests/data/valid_set/" - +morphology_path = "tests/data/swc/Neuron.swc" +morphologies_dir = "tests/data/valid_set/" """ # Add any paths that contain templates here, relative to this directory. diff --git a/doc/source/examples.rst b/doc/source/examples.rst index 979a8bcf..87285da0 100644 --- a/doc/source/examples.rst +++ b/doc/source/examples.rst @@ -35,15 +35,15 @@ Examples started *with the virtualenv activated*. That gives access to the ``neurom`` installation. -Fast analysis with :py:mod:`neurom` +Analysis with :py:mod:`neurom` *********************************** Here we load a morphology and obtain some information from it: -.. code-block:: python +.. doctest:: [examples] >>> import neurom as nm - >>> m = nm.load_morphology('some/data/path/morph_file.swc') + >>> m = nm.load_morphology("tests/data/swc/Neuron.swc") >>> ap_seg_len = nm.get('segment_lengths', m, neurite_type=nm.APICAL_DENDRITE) >>> ax_sec_len = nm.get('section_lengths', m, neurite_type=nm.AXON) @@ -54,7 +54,7 @@ Morphology visualization with the :py:mod:`neurom.viewer` module Here we visualize a morphology: -.. code-block:: python +.. doctest:: [examples] >>> # Initialize m as above >>> from neurom import viewer @@ -89,7 +89,7 @@ Getting Log Information They are emitted in the ``neurom`` namespace, and can thus be filtered based on this. An example of setting up a handler is: -.. code-block:: python +.. doctest:: >>> import logging >>> # setup which namespace will be examined, and at what level diff --git a/doc/source/features.rst b/doc/source/features.rst index afc49ed4..982df417 100644 --- a/doc/source/features.rst +++ b/doc/source/features.rst @@ -48,18 +48,25 @@ only to a morphology or a morphology population. An example for ``neurite``: -.. code-block:: python +.. testcode:: - from neurom import load_morphology, features - from neurom.features.neurite import max_radial_distance + from neurom import load_morphology, features + from neurom.features.neurite import max_radial_distance + + m = load_morphology(morphology_path) + + # valid input + rd = max_radial_distance(m.neurites[0]) + + # invalid input + try: + rd = max_radial_distance(m) + except Exception as e: + pass + + # valid input + rd = features.get('max_radial_distance', m) - m = load_morphology('path/to/morphology') - # valid input - max_radial_distance(m.neurites[0]) - # invalid input - max_radial_distance(m) - # valid input - features.get('max_radial_distance', m) The features mechanism assumes that a neurite feature must be summed if it returns a number, and concatenated if it returns a list. Other types of returns are invalid. For example lets take @@ -69,33 +76,39 @@ Calling it on a morphology population will return a list of ``number_of_segments within the population. -.. code-block:: python +.. testcode:: + + from neurom import load_morphology, load_morphologies, features - from neurom import load_morphology, features + m = load_morphology(morphology_path) - m = load_morphology('path/to/morphology') # a single number features.get('number_of_segments', m.neurites[0]) + # a single number that is a sum for all `m.neurites`. features.get('number_of_segments', m) - pop = load_morphology('path/to/morphology population') + pop = load_morphologies(morphologies_dir) + # a list of numbers features.get('number_of_segments', pop) if a list is returned then the feature results are concatenated. -.. code-block:: python +.. testcode:: + + from neurom import load_morphology, load_morphologies, features - from neurom import load_morphology, features + m = load_morphology(morphology_path) - m = load_morphology('path/to/morphology') # a list of lengths in a neurite features.get('section_lengths', m.neurites[0]) + # a flat list of lengths in a morphology, no separation among neurites features.get('section_lengths', m) - pop = load_morphology('path/to/morphology population') + pop = load_morphologies(morphologies_dir) + # a flat list of lengths in a population, no separation among morphologies features.get('section_lengths', pop) diff --git a/doc/source/heterogeneous.rst b/doc/source/heterogeneous.rst index 85e014a2..85483022 100644 --- a/doc/source/heterogeneous.rst +++ b/doc/source/heterogeneous.rst @@ -47,14 +47,19 @@ Identification Heterogeneous neurites can be identified using the ``Neurite::is_heterogeneous`` method: -.. code:: python +.. testcode:: [heterogeneous] from neurom import load_morphology from neurom.core.morphology import iter_neurites m = load_morphology('tests/data/swc/heterogeneous_morphology.swc') - print([neurite.is_heterogeneous() for neurite in m]) + print([neurite.is_heterogeneous() for neurite in m.neurites]) + +.. testoutput:: [heterogeneous] + :hide: + + [False, True, False] which would return ``[False, True, False]``, meaning the 2nd neurite extending from the soma contains multiple neurite types. @@ -69,18 +74,13 @@ NeuroM does not take into account heterogeneous sub-neurites by default. A heterogeneous neurite is treated as a homogeneous one, the type of which is determined by the first section of the tree. For example: -.. code-block:: python - - from neurom import load_morphology - from neurom.core.morphology import iter_neurites - - m = load_morphology('tests/data/swc/heterogeneous_morphology.swc') +.. testcode:: [heterogeneous] basal, axon_carrying_dendrite, apical = list(iter_neurites(m)) print(basal.type, axon_carrying_dendrite.type, apical.type) -Prints:: +.. testoutput:: [heterogeneous] NeuriteType.basal_dendrite NeuriteType.basal_dendrite NeuriteType.apical_dendrite @@ -96,12 +96,16 @@ Sub-neurite mode NeuroM provides an immutable approach (without modifying the morphology) to access the homogeneous sub-neurites of a neurite. Using ``iter_neurites`` with the flag ``use_subtrees`` returns a neurite view for each homogeneous sub-neurite. -.. code-block:: python +.. testcode:: [heterogeneous] basal1, basal2, axon, apical = list(iter_neurites(m, use_subtrees=True)) print(basal1.type, basal2.type, axon.type, apical.type) +.. testoutput:: [heterogeneous] + + NeuriteType.basal_dendrite NeuriteType.basal_dendrite NeuriteType.axon NeuriteType.apical_dendrite + In the example above, two views of the axon-carrying dendrite have been created: the basal and axon dendrite views. .. image:: images/heterogeneous_neurite.png @@ -129,14 +133,11 @@ Neurite Neurite features have been extended to include a ``section_type`` argument, which can be used to apply a feature on a heterogeneous neurite. -.. code-block:: python +.. testcode:: [heterogeneous] from neurom import NeuriteType - from neurom import load_morphology from neurom.features.neurite import number_of_sections - m = load_morphology('tests/data/swc/heterogeneous_morphology.swc') - axon_carrying_dendrite = m.neurites[1] total_sections = number_of_sections(axon_carrying_dendrite) @@ -145,6 +146,10 @@ Neurite features have been extended to include a ``section_type`` argument, whic print(total_sections, basal_sections, axon_sections) +.. testoutput:: [heterogeneous] + + 9 4 5 + Not specifying a ``section_type`` is equivalent to passing ``NeuriteType.all`` and it will use all sections as done historically. Morphology @@ -152,14 +157,10 @@ Morphology Morphology features have been extended to include the ``use_subtrees`` flag, which allows to use the sub-neurites. -.. code-block:: python +.. testcode:: [heterogeneous] - from neurom import NeuriteType - from neurom import load_morphology from neurom.features.morphology import number_of_neurites - m = load_morphology('tests/data/swc/heterogeneous_morphology.swc') - total_neurites_wout_subneurites = number_of_neurites(m) total_neurites_with_subneurites = number_of_neurites(m, use_subtrees=True) @@ -175,7 +176,7 @@ Morphology features have been extended to include the ``use_subtrees`` flag, whi print("C:", number_of_basal_neurites_wout, number_of_basal_neurites_with) -Prints:: +.. testoutput:: [heterogeneous] A: 3 4 B: 0 1 @@ -193,15 +194,18 @@ features.get ``features.get`` can be used with respect to what has been mentioned above for neurite and morphology features. -.. code-block:: python +.. testcode:: [heterogeneous] from neurom import features - from neurom import load_morphology - m = load_morphology('tests/data/swc/heterogeneous_morphology.swc') + n_neurites = features.get("number_of_neurites", m, use_subtrees=True) + n_sections = features.get("number_of_sections", m, section_type=NeuriteType.axon) + + print(f"Neurites: {n_neurites}, Sections: {n_sections}") + +.. testoutput:: [heterogeneous] - features.get("number_of_neurites", m, use_subtrees=True) - features.get("number_of_sections", m, section_type=NeuriteType.axon) + Neurites: 4, Sections: 5 Conventions & Incompatibilities ------------------------------- diff --git a/doc/source/migration.rst b/doc/source/migration.rst index b1661241..89135cd5 100644 --- a/doc/source/migration.rst +++ b/doc/source/migration.rst @@ -36,12 +36,12 @@ Migration to v3 version - ``neurom.view.viewer`` is deprecated. To get the same results as before, use the replacement: - .. code-block:: python + .. testcode:: import neurom as nm # instead of: from neurom import viewer from neurom.view import matplotlib_impl, matplotlib_utils - m = nm.load_morphology('some/data/path/morph_file.asc') + m = nm.load_morphology('tests/data/swc/Neuron.swc') # instead of: viewer.draw(m) matplotlib_impl.plot_morph(m) @@ -56,12 +56,13 @@ Migration to v3 version fig, ax = matplotlib_utils.get_figure() matplotlib_impl.plot_dendrogram(m, ax) matplotlib_utils.plot_style(fig=fig, ax=ax) - matplotlib_utils.save_plot(fig=fig, output_path=output_path) + matplotlib_utils.save_plot(fig=fig, output_path="output-directory-path") + # for other plots like `plot_morph` it is the same, you just need to call `plot_morph` instead # of `plot_dendrogram`. # instead of `plotly.draw` - from neurom import plotly_impl + from neurom.view import plotly_impl plotly_impl.plot_morph(m) # for 2d plotly_impl.plot_morph3d(m) # for 3d @@ -117,4 +118,4 @@ Migration to v2 version - 2 point soma - non-sequential ids - script ``morph_check`` and ``morph_stats`` changed to ``neurom check`` and ``neurom stats`` - correspondingly. \ No newline at end of file + correspondingly. diff --git a/doc/source/quickstart.rst b/doc/source/quickstart.rst index d3d72488..5f56e3bf 100644 --- a/doc/source/quickstart.rst +++ b/doc/source/quickstart.rst @@ -57,12 +57,12 @@ Extract morphometrics with :func:`neurom.features.get` Analyze morphologies via :func:`neurom.features.get`. This way you can get things like segment lengths, section lengths, etc. -.. code:: +.. testcode:: import neurom as nm - m = nm.load_morphology('some/data/path/morph_file0.swc') + m = nm.load_morphology('tests/data/swc/Neuron.swc') m_ap_seg_len = nm.features.get('segment_lengths', m, neurite_type=nm.APICAL_DENDRITE) - pop = nm.load_morphologies('some/data/path') + pop = nm.load_morphologies('tests/data/valid_set/') pop_ap_seg_len = nm.features.get('segment_lengths', pop, neurite_type=nm.APICAL_DENDRITE) For more details see :ref:`features`. @@ -76,12 +76,11 @@ neurite or a list of neurites. It allows to optionally pass a function to be mapped onto each neurite, as well as a neurite filter function. In this example, we apply a simple user defined function to the apical dendrites in a population: -.. code:: +.. testcode:: import neurom as nm def user_func(neurite): - print('Analysing neurite', neurite) return len(neurite.points) stuff = [x for x in nm.iter_neurites(pop, user_func, lambda n : n.type == nm.APICAL_DENDRITE)] diff --git a/doc/source/validation.rst b/doc/source/validation.rst index 770e878c..d919a1c2 100644 --- a/doc/source/validation.rst +++ b/doc/source/validation.rst @@ -36,7 +36,7 @@ NeuroM uses MorphIO for reading/writing of morphologies. The rule is be less rig If there is a problem with morphology then NeuroM rather print a warning about instead of raising an error. If you want validate morphologies as strictly as possible then -.. code-block:: python +.. testcode:: [validation] import morphio morphio.set_raise_warnings(True) @@ -44,15 +44,15 @@ an error. If you want validate morphologies as strictly as possible then This will make MorphIO (hence NeuroM as well) raise warnings as errors. You might want to skip some warnings at all. For example, zero diameter is ok to have in your morpology. Then you can: -.. code-block:: python +.. testcode:: [validation] try: morphio.set_raise_warnings(True) # warnings you are not interested in morphio.set_ignored_warning(morphio.Warning.zero_diameter, True) - m = morphio.Morphology('path/to/morph') + m = morphio.Morphology('tests/data/swc/soma_zero_radius.swc') finally: morphio.set_ignored_warning(morphio.Warning.zero_diameter, False) morphio.set_raise_warnings(False) -For more documentation on that topic refer to ``__. \ No newline at end of file +For more documentation on that topic refer to ``__. From cf8a9e0e2aa4e8f19948fe5b389ee3c1942c2e78 Mon Sep 17 00:00:00 2001 From: Eleftherios Zisis Date: Tue, 10 May 2022 18:36:04 +0200 Subject: [PATCH 07/15] Remove deprecated viewer code from documentation --- doc/source/examples.rst | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/doc/source/examples.rst b/doc/source/examples.rst index 87285da0..b077d801 100644 --- a/doc/source/examples.rst +++ b/doc/source/examples.rst @@ -48,7 +48,7 @@ Here we load a morphology and obtain some information from it: >>> ax_sec_len = nm.get('section_lengths', m, neurite_type=nm.AXON) -Morphology visualization with the :py:mod:`neurom.viewer` module +Morphology visualization with the :py:mod:`neurom.view` module **************************************************************** Here we visualize a morphology: @@ -57,12 +57,10 @@ Here we visualize a morphology: .. doctest:: [examples] >>> # Initialize m as above - >>> from neurom import viewer - >>> fig, ax = viewer.draw(m) - >>> fig.show() - >>> - >>> fig, ax = viewer.draw(m, mode='3d') # valid modes '2d', '3d', 'dendrogram' - >>> fig.show() + >>> from neurom.view import plot_morph, plot_morph3d, plot_dendrogram + >>> plot_morph(m) + >>> plot_morph3d(m) + >>> plot_dendrogram(m) Advanced iterator-based feature extraction example ************************************************** From 879f914ccce50f1474d7e743e95d5700c438cd7c Mon Sep 17 00:00:00 2001 From: Eleftherios Zisis Date: Tue, 10 May 2022 18:46:23 +0200 Subject: [PATCH 08/15] Use only paths --- doc/source/conf.py | 5 ----- doc/source/features.rst | 10 +++++----- neurom/core/morphology.py | 4 ++-- neurom/core/types.py | 2 +- neurom/features/__init__.py | 2 +- neurom/features/morphology.py | 4 ++-- neurom/features/neurite.py | 2 +- neurom/features/population.py | 2 +- 8 files changed, 13 insertions(+), 18 deletions(-) diff --git a/doc/source/conf.py b/doc/source/conf.py index 82734041..9fc6dd76 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -63,11 +63,6 @@ 'sphinx.ext.doctest', ] -# code that will be executed for each test -doctest_global_setup = """ -morphology_path = "tests/data/swc/Neuron.swc" -morphologies_dir = "tests/data/valid_set/" -""" # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] diff --git a/doc/source/features.rst b/doc/source/features.rst index 982df417..054081f1 100644 --- a/doc/source/features.rst +++ b/doc/source/features.rst @@ -53,7 +53,7 @@ An example for ``neurite``: from neurom import load_morphology, features from neurom.features.neurite import max_radial_distance - m = load_morphology(morphology_path) + m = load_morphology("tests/data/swc/Neuron.swc") # valid input rd = max_radial_distance(m.neurites[0]) @@ -80,7 +80,7 @@ within the population. from neurom import load_morphology, load_morphologies, features - m = load_morphology(morphology_path) + m = load_morphology("tests/data/swc/Neuron.swc") # a single number features.get('number_of_segments', m.neurites[0]) @@ -88,7 +88,7 @@ within the population. # a single number that is a sum for all `m.neurites`. features.get('number_of_segments', m) - pop = load_morphologies(morphologies_dir) + pop = load_morphologies("tests/data/valid_set") # a list of numbers features.get('number_of_segments', pop) @@ -99,7 +99,7 @@ if a list is returned then the feature results are concatenated. from neurom import load_morphology, load_morphologies, features - m = load_morphology(morphology_path) + m = load_morphology("tests/data/swc/Neuron.swc") # a list of lengths in a neurite features.get('section_lengths', m.neurites[0]) @@ -107,7 +107,7 @@ if a list is returned then the feature results are concatenated. # a flat list of lengths in a morphology, no separation among neurites features.get('section_lengths', m) - pop = load_morphologies(morphologies_dir) + pop = load_morphologies("tests/data/valid_set") # a flat list of lengths in a population, no separation among morphologies features.get('section_lengths', pop) diff --git a/neurom/core/morphology.py b/neurom/core/morphology.py index 96941705..ed2dc0fe 100644 --- a/neurom/core/morphology.py +++ b/neurom/core/morphology.py @@ -255,7 +255,7 @@ def iter_neurites( >>> from neurom.core.morphology import iter_neurites >>> from neurom import load_morphologies - >>> pop = load_morphologies(morphologies_dir) + >>> pop = load_morphologies("tests/data/valid_set") >>> n_points = [n for n in iter_neurites(pop, lambda x : len(x.points))] Get the number of points in each axon in a morphology population @@ -263,7 +263,7 @@ def iter_neurites( >>> import neurom as nm >>> from neurom.core.morphology import iter_neurites >>> from neurom import load_morphologies - >>> pop = load_morphologies(morphologies_dir) + >>> pop = load_morphologies("tests/data/valid_set") >>> filter = lambda n : n.type == nm.AXON >>> mapping = lambda n : len(n.points) >>> n_points = [n for n in iter_neurites(pop, mapping, filter)] diff --git a/neurom/core/types.py b/neurom/core/types.py index 6a3718be..ed78bc4c 100644 --- a/neurom/core/types.py +++ b/neurom/core/types.py @@ -86,7 +86,7 @@ def tree_type_checker(*ref): >>> import neurom >>> from neurom.core.types import NeuriteType, tree_type_checker >>> from neurom.core.morphology import Section, iter_neurites - >>> m = neurom.load_morphology(morphology_path) + >>> m = neurom.load_morphology("tests/data/swc/Neuron.swc") >>> >>> tree_filter = tree_type_checker(NeuriteType.axon, NeuriteType.basal_dendrite) >>> it = iter_neurites(m, filt=tree_filter) diff --git a/neurom/features/__init__.py b/neurom/features/__init__.py index 0a1b066f..fdbf2588 100644 --- a/neurom/features/__init__.py +++ b/neurom/features/__init__.py @@ -32,7 +32,7 @@ Obtain some morphometrics >>> import neurom >>> from neurom import features - >>> m = neurom.load_morphology(morphology_path) + >>> m = neurom.load_morphology("tests/data/swc/Neuron.swc") >>> ap_seg_len = features.get('segment_lengths', m, neurite_type=neurom.APICAL_DENDRITE) >>> ax_sec_len = features.get('section_lengths', m, neurite_type=neurom.AXON) """ diff --git a/neurom/features/morphology.py b/neurom/features/morphology.py index eaaa867d..439fb69c 100644 --- a/neurom/features/morphology.py +++ b/neurom/features/morphology.py @@ -35,9 +35,9 @@ >>> import neurom >>> from neurom import features ->>> m = neurom.load_morphology(morphology_path) +>>> m = neurom.load_morphology("tests/data/swc/Neuron.swc") >>> result = features.get('soma_surface_area', m) ->>> population = neurom.load_morphologies(morphologies_dir) +>>> population = neurom.load_morphologies("tests/data/valid_set") >>> result = features.get('sholl_crossings', population) For more details see :ref:`features`. diff --git a/neurom/features/neurite.py b/neurom/features/neurite.py index 4ed24188..afcd5952 100644 --- a/neurom/features/neurite.py +++ b/neurom/features/neurite.py @@ -35,7 +35,7 @@ >>> import neurom >>> from neurom import features ->>> m = neurom.load_morphology(morphology_path) +>>> m = neurom.load_morphology("tests/data/swc/Neuron.swc") >>> max_radial_distances1 = features.get('max_radial_distance', m.neurites) >>> max_radial_distances2 = features.get('max_radial_distance', m.neurites[0]) >>> max_radial_distances3 = features.get('max_radial_distance', m) diff --git a/neurom/features/population.py b/neurom/features/population.py index b49d1c9d..95e0efed 100644 --- a/neurom/features/population.py +++ b/neurom/features/population.py @@ -33,7 +33,7 @@ >>> import neurom >>> from neurom import features ->>> pop = neurom.load_morphologies(morphologies_dir) +>>> pop = neurom.load_morphologies("tests/data/valid_set") >>> frequencies = features.get('sholl_frequency', pop) For more details see :ref:`features`. From c1b6cac177adda299ab0da83fb720231a97a3062 Mon Sep 17 00:00:00 2001 From: Eleftherios Zisis Date: Wed, 11 May 2022 16:14:24 +0200 Subject: [PATCH 09/15] Comment out stuff --- doc/source/features.rst | 5 +---- doc/source/migration.rst | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/doc/source/features.rst b/doc/source/features.rst index 054081f1..82382474 100644 --- a/doc/source/features.rst +++ b/doc/source/features.rst @@ -59,10 +59,7 @@ An example for ``neurite``: rd = max_radial_distance(m.neurites[0]) # invalid input - try: - rd = max_radial_distance(m) - except Exception as e: - pass + # rd = max_radial_distance(m) # valid input rd = features.get('max_radial_distance', m) diff --git a/doc/source/migration.rst b/doc/source/migration.rst index 89135cd5..05425c28 100644 --- a/doc/source/migration.rst +++ b/doc/source/migration.rst @@ -56,7 +56,7 @@ Migration to v3 version fig, ax = matplotlib_utils.get_figure() matplotlib_impl.plot_dendrogram(m, ax) matplotlib_utils.plot_style(fig=fig, ax=ax) - matplotlib_utils.save_plot(fig=fig, output_path="output-directory-path") + # matplotlib_utils.save_plot(fig=fig, output_path="output-directory-path") # for other plots like `plot_morph` it is the same, you just need to call `plot_morph` instead # of `plot_dendrogram`. From 97e0f288263b4a2d2d4e358cd4195f1b38396bcb Mon Sep 17 00:00:00 2001 From: Eleftherios Zisis Date: Thu, 12 May 2022 13:20:47 +0200 Subject: [PATCH 10/15] Use sphinx-build cli --- doc/Makefile | 220 ------------------------------------------ doc/clean.sh | 2 - doc/make.bat | 263 --------------------------------------------------- tox.ini | 10 +- 4 files changed, 4 insertions(+), 491 deletions(-) delete mode 100644 doc/Makefile delete mode 100755 doc/clean.sh delete mode 100644 doc/make.bat diff --git a/doc/Makefile b/doc/Makefile deleted file mode 100644 index c3dff82b..00000000 --- a/doc/Makefile +++ /dev/null @@ -1,220 +0,0 @@ -# Copyright (c) 2015, Ecole Polytechnique Federale de Lausanne, Blue Brain Project -# All rights reserved. -# -# This file is part of NeuroM -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# 3. Neither the name of the copyright holder nor the names of -# its contributors may be used to endorse or promote products -# derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY -# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -# Makefile for Sphinx documentation -# - -# You can set these variables from the command line. -SPHINXOPTS = -SPHINXBUILD = sphinx-build -PAPER = -BUILDDIR = build - -# User-friendly check for sphinx-build -ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1) -$(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/) -endif - -# Internal variables. -PAPEROPT_a4 = -D latex_paper_size=a4 -PAPEROPT_letter = -D latex_paper_size=letter -ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source -# the i18n builder cannot share the environment and doctrees with the others -I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source - -.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest coverage gettext - -help: - @echo "Please use \`make ' where is one of" - @echo " html to make standalone HTML files" - @echo " dirhtml to make HTML files named index.html in directories" - @echo " singlehtml to make a single large HTML file" - @echo " pickle to make pickle files" - @echo " json to make JSON files" - @echo " htmlhelp to make HTML files and a HTML help project" - @echo " qthelp to make HTML files and a qthelp project" - @echo " applehelp to make an Apple Help Book" - @echo " devhelp to make HTML files and a Devhelp project" - @echo " epub to make an epub" - @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" - @echo " latexpdf to make LaTeX files and run them through pdflatex" - @echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx" - @echo " text to make text files" - @echo " man to make manual pages" - @echo " texinfo to make Texinfo files" - @echo " info to make Texinfo files and run them through makeinfo" - @echo " gettext to make PO message catalogs" - @echo " changes to make an overview of all changed/added/deprecated items" - @echo " xml to make Docutils-native XML files" - @echo " pseudoxml to make pseudoxml-XML files for display purposes" - @echo " linkcheck to check all external links for integrity" - @echo " doctest to run all doctests embedded in the documentation (if enabled)" - @echo " coverage to run coverage check of the documentation (if enabled)" - -clean: - rm -rf $(BUILDDIR)/* - -html: - $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html - @echo - @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." - -dirhtml: - $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml - @echo - @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." - -singlehtml: - $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml - @echo - @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." - -pickle: - $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle - @echo - @echo "Build finished; now you can process the pickle files." - -json: - $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json - @echo - @echo "Build finished; now you can process the JSON files." - -htmlhelp: - $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp - @echo - @echo "Build finished; now you can run HTML Help Workshop with the" \ - ".hhp project file in $(BUILDDIR)/htmlhelp." - -qthelp: - $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp - @echo - @echo "Build finished; now you can run "qcollectiongenerator" with the" \ - ".qhcp project file in $(BUILDDIR)/qthelp, like this:" - @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/NeuroM.qhcp" - @echo "To view the help file:" - @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/NeuroM.qhc" - -applehelp: - $(SPHINXBUILD) -b applehelp $(ALLSPHINXOPTS) $(BUILDDIR)/applehelp - @echo - @echo "Build finished. The help book is in $(BUILDDIR)/applehelp." - @echo "N.B. You won't be able to view it unless you put it in" \ - "~/Library/Documentation/Help or install it in your application" \ - "bundle." - -devhelp: - $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp - @echo - @echo "Build finished." - @echo "To view the help file:" - @echo "# mkdir -p $$HOME/.local/share/devhelp/NeuroM" - @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/NeuroM" - @echo "# devhelp" - -epub: - $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub - @echo - @echo "Build finished. The epub file is in $(BUILDDIR)/epub." - -latex: - $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex - @echo - @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." - @echo "Run \`make' in that directory to run these through (pdf)latex" \ - "(use \`make latexpdf' here to do that automatically)." - -latexpdf: - $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex - @echo "Running LaTeX files through pdflatex..." - $(MAKE) -C $(BUILDDIR)/latex all-pdf - @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." - -latexpdfja: - $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex - @echo "Running LaTeX files through platex and dvipdfmx..." - $(MAKE) -C $(BUILDDIR)/latex all-pdf-ja - @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." - -text: - $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text - @echo - @echo "Build finished. The text files are in $(BUILDDIR)/text." - -man: - $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man - @echo - @echo "Build finished. The manual pages are in $(BUILDDIR)/man." - -texinfo: - $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo - @echo - @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo." - @echo "Run \`make' in that directory to run these through makeinfo" \ - "(use \`make info' here to do that automatically)." - -info: - $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo - @echo "Running Texinfo files through makeinfo..." - make -C $(BUILDDIR)/texinfo info - @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo." - -gettext: - $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale - @echo - @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale." - -changes: - $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes - @echo - @echo "The overview file is in $(BUILDDIR)/changes." - -linkcheck: - $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck - @echo - @echo "Link check complete; look for any errors in the above output " \ - "or in $(BUILDDIR)/linkcheck/output.txt." - -doctest: - $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest - @echo "Testing of doctests in the sources finished, look at the " \ - "results in $(BUILDDIR)/doctest/output.txt." - -coverage: - $(SPHINXBUILD) -b coverage $(ALLSPHINXOPTS) $(BUILDDIR)/coverage - @echo "Testing of coverage in the sources finished, look at the " \ - "results in $(BUILDDIR)/coverage/python.txt." - -xml: - $(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml - @echo - @echo "Build finished. The XML files are in $(BUILDDIR)/xml." - -pseudoxml: - $(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml - @echo - @echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml." diff --git a/doc/clean.sh b/doc/clean.sh deleted file mode 100755 index 49f8ce18..00000000 --- a/doc/clean.sh +++ /dev/null @@ -1,2 +0,0 @@ -rm -Rf neurom -rm -Rf _build diff --git a/doc/make.bat b/doc/make.bat deleted file mode 100644 index 2137681f..00000000 --- a/doc/make.bat +++ /dev/null @@ -1,263 +0,0 @@ -@ECHO OFF - -REM Command file for Sphinx documentation - -if "%SPHINXBUILD%" == "" ( - set SPHINXBUILD=sphinx-build -) -set BUILDDIR=build -set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% source -set I18NSPHINXOPTS=%SPHINXOPTS% source -if NOT "%PAPER%" == "" ( - set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS% - set I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS% -) - -if "%1" == "" goto help - -if "%1" == "help" ( - :help - echo.Please use `make ^` where ^ is one of - echo. html to make standalone HTML files - echo. dirhtml to make HTML files named index.html in directories - echo. singlehtml to make a single large HTML file - echo. pickle to make pickle files - echo. json to make JSON files - echo. htmlhelp to make HTML files and a HTML help project - echo. qthelp to make HTML files and a qthelp project - echo. devhelp to make HTML files and a Devhelp project - echo. epub to make an epub - echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter - echo. text to make text files - echo. man to make manual pages - echo. texinfo to make Texinfo files - echo. gettext to make PO message catalogs - echo. changes to make an overview over all changed/added/deprecated items - echo. xml to make Docutils-native XML files - echo. pseudoxml to make pseudoxml-XML files for display purposes - echo. linkcheck to check all external links for integrity - echo. doctest to run all doctests embedded in the documentation if enabled - echo. coverage to run coverage check of the documentation if enabled - goto end -) - -if "%1" == "clean" ( - for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i - del /q /s %BUILDDIR%\* - goto end -) - - -REM Check if sphinx-build is available and fallback to Python version if any -%SPHINXBUILD% 2> nul -if errorlevel 9009 goto sphinx_python -goto sphinx_ok - -:sphinx_python - -set SPHINXBUILD=python -m sphinx.__init__ -%SPHINXBUILD% 2> nul -if errorlevel 9009 ( - echo. - echo.The 'sphinx-build' command was not found. Make sure you have Sphinx - echo.installed, then set the SPHINXBUILD environment variable to point - echo.to the full path of the 'sphinx-build' executable. Alternatively you - echo.may add the Sphinx directory to PATH. - echo. - echo.If you don't have Sphinx installed, grab it from - echo.http://sphinx-doc.org/ - exit /b 1 -) - -:sphinx_ok - - -if "%1" == "html" ( - %SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html - if errorlevel 1 exit /b 1 - echo. - echo.Build finished. The HTML pages are in %BUILDDIR%/html. - goto end -) - -if "%1" == "dirhtml" ( - %SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml - if errorlevel 1 exit /b 1 - echo. - echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml. - goto end -) - -if "%1" == "singlehtml" ( - %SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml - if errorlevel 1 exit /b 1 - echo. - echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml. - goto end -) - -if "%1" == "pickle" ( - %SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle - if errorlevel 1 exit /b 1 - echo. - echo.Build finished; now you can process the pickle files. - goto end -) - -if "%1" == "json" ( - %SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json - if errorlevel 1 exit /b 1 - echo. - echo.Build finished; now you can process the JSON files. - goto end -) - -if "%1" == "htmlhelp" ( - %SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp - if errorlevel 1 exit /b 1 - echo. - echo.Build finished; now you can run HTML Help Workshop with the ^ -.hhp project file in %BUILDDIR%/htmlhelp. - goto end -) - -if "%1" == "qthelp" ( - %SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp - if errorlevel 1 exit /b 1 - echo. - echo.Build finished; now you can run "qcollectiongenerator" with the ^ -.qhcp project file in %BUILDDIR%/qthelp, like this: - echo.^> qcollectiongenerator %BUILDDIR%\qthelp\NeuroM.qhcp - echo.To view the help file: - echo.^> assistant -collectionFile %BUILDDIR%\qthelp\NeuroM.ghc - goto end -) - -if "%1" == "devhelp" ( - %SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp - if errorlevel 1 exit /b 1 - echo. - echo.Build finished. - goto end -) - -if "%1" == "epub" ( - %SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub - if errorlevel 1 exit /b 1 - echo. - echo.Build finished. The epub file is in %BUILDDIR%/epub. - goto end -) - -if "%1" == "latex" ( - %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex - if errorlevel 1 exit /b 1 - echo. - echo.Build finished; the LaTeX files are in %BUILDDIR%/latex. - goto end -) - -if "%1" == "latexpdf" ( - %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex - cd %BUILDDIR%/latex - make all-pdf - cd %~dp0 - echo. - echo.Build finished; the PDF files are in %BUILDDIR%/latex. - goto end -) - -if "%1" == "latexpdfja" ( - %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex - cd %BUILDDIR%/latex - make all-pdf-ja - cd %~dp0 - echo. - echo.Build finished; the PDF files are in %BUILDDIR%/latex. - goto end -) - -if "%1" == "text" ( - %SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text - if errorlevel 1 exit /b 1 - echo. - echo.Build finished. The text files are in %BUILDDIR%/text. - goto end -) - -if "%1" == "man" ( - %SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man - if errorlevel 1 exit /b 1 - echo. - echo.Build finished. The manual pages are in %BUILDDIR%/man. - goto end -) - -if "%1" == "texinfo" ( - %SPHINXBUILD% -b texinfo %ALLSPHINXOPTS% %BUILDDIR%/texinfo - if errorlevel 1 exit /b 1 - echo. - echo.Build finished. The Texinfo files are in %BUILDDIR%/texinfo. - goto end -) - -if "%1" == "gettext" ( - %SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale - if errorlevel 1 exit /b 1 - echo. - echo.Build finished. The message catalogs are in %BUILDDIR%/locale. - goto end -) - -if "%1" == "changes" ( - %SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes - if errorlevel 1 exit /b 1 - echo. - echo.The overview file is in %BUILDDIR%/changes. - goto end -) - -if "%1" == "linkcheck" ( - %SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck - if errorlevel 1 exit /b 1 - echo. - echo.Link check complete; look for any errors in the above output ^ -or in %BUILDDIR%/linkcheck/output.txt. - goto end -) - -if "%1" == "doctest" ( - %SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest - if errorlevel 1 exit /b 1 - echo. - echo.Testing of doctests in the sources finished, look at the ^ -results in %BUILDDIR%/doctest/output.txt. - goto end -) - -if "%1" == "coverage" ( - %SPHINXBUILD% -b coverage %ALLSPHINXOPTS% %BUILDDIR%/coverage - if errorlevel 1 exit /b 1 - echo. - echo.Testing of coverage in the sources finished, look at the ^ -results in %BUILDDIR%/coverage/python.txt. - goto end -) - -if "%1" == "xml" ( - %SPHINXBUILD% -b xml %ALLSPHINXOPTS% %BUILDDIR%/xml - if errorlevel 1 exit /b 1 - echo. - echo.Build finished. The XML files are in %BUILDDIR%/xml. - goto end -) - -if "%1" == "pseudoxml" ( - %SPHINXBUILD% -b pseudoxml %ALLSPHINXOPTS% %BUILDDIR%/pseudoxml - if errorlevel 1 exit /b 1 - echo. - echo.Build finished. The pseudo-XML files are in %BUILDDIR%/pseudoxml. - goto end -) - -:end diff --git a/tox.ini b/tox.ini index bdff5ec5..12d373c1 100644 --- a/tox.ini +++ b/tox.ini @@ -17,7 +17,6 @@ envlist = deps = {[base]testdeps} extras = plotly commands = - sphinx-build -b doctest -d {toxinidir}/doc/build/doctrees {toxinidir}/doc/source {toxinidir}/doc/build/doctest pytest {posargs} [testenv:lint] @@ -58,12 +57,11 @@ basepython=python3.8 changedir = doc extras = docs commands = - # remove autosummary output - rm -rf {toxinidir}/doc/source/_neurom_build - make clean - make html SPHINXOPTS=-W + # remove autosummary output and cleanup + rm -rf {toxinidir}/doc/source/_neurom_build {toxinidir}/doc/build/* + sphinx-build -W -b doctest {toxinidir}/doc/source {toxinidir}/doc/build/doctest + sphinx-build -W -b html {toxinidir}/doc/source {toxinidir}/doc/build/html whitelist_externals = - make rm [testenv:tutorial] From 7deb84eb438e385f157cd928bf3345374e8a6482 Mon Sep 17 00:00:00 2001 From: Eleftherios Zisis Date: Mon, 30 May 2022 08:50:49 +0200 Subject: [PATCH 11/15] Remove changedir --- tox.ini | 1 - 1 file changed, 1 deletion(-) diff --git a/tox.ini b/tox.ini index 12d373c1..d19936a8 100644 --- a/tox.ini +++ b/tox.ini @@ -54,7 +54,6 @@ commands = [testenv:docs] basepython=python3.8 -changedir = doc extras = docs commands = # remove autosummary output and cleanup From b5cda235745bcaca6df1984080fdb124f43338e9 Mon Sep 17 00:00:00 2001 From: Eleftherios Zisis Date: Tue, 31 May 2022 11:32:42 +0200 Subject: [PATCH 12/15] Remove sphinx dep --- tox.ini | 1 - 1 file changed, 1 deletion(-) diff --git a/tox.ini b/tox.ini index d19936a8..885adea3 100644 --- a/tox.ini +++ b/tox.ini @@ -3,7 +3,6 @@ name = neurom testdeps = mock pytest>3.0 - sphinx [tox] envlist = From 05300a98affd4b435bd8a46a88c7bbe2da905a4f Mon Sep 17 00:00:00 2001 From: Eleftherios Zisis Date: Mon, 6 Jun 2022 15:44:17 +0200 Subject: [PATCH 13/15] Update doc/source/developer.rst Co-authored-by: Adrien Berchet --- doc/source/developer.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/developer.rst b/doc/source/developer.rst index 0c9eed74..ff1b8d6a 100644 --- a/doc/source/developer.rst +++ b/doc/source/developer.rst @@ -60,7 +60,7 @@ individually: .. code-block:: bash $ tox -e py38-lint # runs only pylint - $ tox -e py38-docs # run only documentation check + $ tox -e py38-docs # run only documentation check and build the doc $ tox -e py38-coverage # run only coverage check $ tox -e py38 # run only the tests From 3641e54ff42f29d9986fd9aff1a470e81bf1e3f0 Mon Sep 17 00:00:00 2001 From: Eleftherios Zisis Date: Mon, 6 Jun 2022 15:44:36 +0200 Subject: [PATCH 14/15] Update doc/source/examples.rst Co-authored-by: Adrien Berchet --- doc/source/examples.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/examples.rst b/doc/source/examples.rst index b077d801..0d7c24bc 100644 --- a/doc/source/examples.rst +++ b/doc/source/examples.rst @@ -36,7 +36,7 @@ Examples installation. Analysis with :py:mod:`neurom` -*********************************** +****************************** Here we load a morphology and obtain some information from it: From 97651368cfe147e16f2d67a76e21512666481ae0 Mon Sep 17 00:00:00 2001 From: Eleftherios Zisis Date: Mon, 6 Jun 2022 15:44:51 +0200 Subject: [PATCH 15/15] Update doc/source/examples.rst Co-authored-by: Adrien Berchet --- doc/source/examples.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/examples.rst b/doc/source/examples.rst index 0d7c24bc..33eff652 100644 --- a/doc/source/examples.rst +++ b/doc/source/examples.rst @@ -49,7 +49,7 @@ Here we load a morphology and obtain some information from it: Morphology visualization with the :py:mod:`neurom.view` module -**************************************************************** +************************************************************** Here we visualize a morphology: