Open schlegelp opened 2 years ago
It's not impossible to have paths with newlines or which look like URLs, but they're pretty rare.
As an aside, as there are lots of failure modes for this very general function, maybe it's worth some bespoke errors replacing some of the ValueErrors?
I fully agree. That said: the BaseReader
class is already a pretty complex thing and I'm a bit reluctant to add to that.
My suggested solution would still correctly check most file paths which is an improvement over what's there right now. I'm tempted to add this and see if I can add some more useful error messages (e.g. for malformed SWC files).
navis.read_swc
will throw very unhelpfulValueErrors
(via pandas) when the input is a non-existing (file)path (e.g. in case of a typo). Try for example this:The reason being that strings are first tested for being folder and files, and failing that will be treated as SWC strings without any additional checks and balances.
I had a look at both
BaseReader
andSwcReader
, and the easiest way, I think, to catch these would be add a quick check right at the start ofnavis.read_swc
(beforeSwcReader.read_any
is called). Something like this:Now this seems to work reasonable well but I'm worried that there is some corner case I'm not thinking about. Thoughts @clbarnes ?