pynapple-org / pynapple

PYthon Neural Analysis Package :pineapple:
https://pynapple-org.github.io/pynapple/
MIT License
243 stars 59 forks source link

`load_file` should work with pathlib #299

Open billbrod opened 1 month ago

billbrod commented 1 month ago

Hi pynapple devs. When calling pynapple.load_file with pathlib.Path (as opposed to a string), pynapple raises an AttributeError because it tries to call path.endswith:

import pynapple as nap
import pathlib

p = pathlib.Path('test_file.npz')
nap.load_files(p)

(This came up for me because of some code I'm writing for nemos to download data in our examples, using pooch)

An easy fix would be to just call path.as_posix() to convert pathlib.Path objects to string, but using the Path objects directly under the hood will probably make many things easier.