Skip to content

Commit

Permalink
- drop support for writing Dotprops to SWCs
Browse files Browse the repository at this point in the history
  • Loading branch information
schlegelp committed Feb 14, 2024
1 parent cd4be35 commit caba243
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
4 changes: 3 additions & 1 deletion docs/source/whats_new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ repository.
-
* - dev
- ongoing
- - BREAKING: dropped support for Python 3.8, per `NEP 29 <https://numpy.org/neps/nep-0029-deprecation_policy.html>`_
- - BREAKING:
- dropped support for Python 3.8, per `NEP 29 <https://numpy.org/neps/nep-0029-deprecation_policy.html>`_
- :func:`navis.write_swc` does not anymore support writing `Dotprops`
- Additions:
- new property ``Treenode.surface_area``
- new functions :func:`navis.read_parquet` and :func:`navis.write_parquet`
Expand Down
22 changes: 14 additions & 8 deletions navis/io/swc_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ def write_swc(x: 'core.NeuronObject',
Parameters
----------
x : TreeNeuron | Dotprops | NeuronList
x : TreeNeuron | NeuronList
If multiple neurons, will generate a single SWC file
for each neuron (see also ``filepath``).
filepath : str | pathlib.Path | list thereof
Expand Down Expand Up @@ -509,15 +509,21 @@ def write_swc(x: 'core.NeuronObject',
>>> navis.write_swc(nl, tmp_dir / 'skel-{neuron.name}[email protected]')
"""
# Make sure inputs are only TreeNeurons or Dotprops
# Make sure inputs are only TreeNeurons
if isinstance(x, core.NeuronList):
for n in x:
if not isinstance(n, (core.TreeNeuron, core.Dotprops)):
raise TypeError('Can only write TreeNeurons or Dotprops to SWC '
f', not "{type(n)}"')
elif not isinstance(x, (core.TreeNeuron, core.Dotprops)):
raise TypeError('Can only write TreeNeurons or Dotprops to SWC, not '
f'"{type(x)}"')
if not isinstance(n, core.TreeNeuron):
msg = f'Can only write TreeNeurons to SWC, not "{type(n)}"'
if isinstance(n, core.Dotprops):
msg += (". For Dotprops, you can use either `navis.write_nrrd`"
" or `navis.write_parquet`.")
raise TypeError(msg)
elif not isinstance(x, core.TreeNeuron):
msg = f'Can only write TreeNeurons to SWC, not "{type(n)}"'
if isinstance(n, core.Dotprops):
msg += (". For Dotprops, you can use either `navis.write_nrrd`"
" or `navis.write_parquet`.")
raise TypeError(msg)

writer = base.Writer(write_func=_write_swc, ext='.swc')

Expand Down

0 comments on commit caba243

Please sign in to comment.