navis-org / navis

Python library for analysis of neuroanatomical data.
https://navis.readthedocs.io
GNU General Public License v3.0
80 stars 29 forks source link

Add tags=None to TreeNeurons #109

Closed clbarnes closed 1 year ago

clbarnes commented 1 year ago

Some navis functions expect TreeNeurons to have a tags attribute, or at least check whether it exists, presumably to catch subclasses like CatmaidNeurons. This effectively blesses that tag representation, so we may as well include it in the base class. For me at least, it's convenient to be able to represent tags without needing the live-fetching elements from CatmaidNeurons, so this change adds tags = None to the TreeNeuron class definition, and has other functions check whether it's non-None before trying to read anything from it. Having an optional attribute for tags, rather than an empty dict, means you can distinguish between untagged neurons and neurons which happen to have 0 tags; but having a firm attribute in place for it makes type checkers more happy.

schlegelp commented 1 year ago

Looks good to me. Feel free to merge when happy.