pynapple-org / pynapple

PYthon Neural Analysis Package :pineapple:
https://pynapple.org/
MIT License
262 stars 61 forks source link

Create a TsGroup from an iterable of Ts/Tsd objects #305

Closed eschombu closed 1 month ago

eschombu commented 3 months ago

It doesn't seem to make a ton of sense to me to require that users manually package their timestamp/series objects into a dict when creating TsGroup objects, since the keys are required to be unique integers. I would guess that the vast majority of the time, users would be just doing {0: ts0, 1: ts1, ...}. Sure, this can be easily done by saying data = dict(enumerate(ts_list)), but why not just allow the user to say data = ts_list and do the dict creation automatically?

If the change described above is not desired, the second commit is probably still worth including. It ensures that the keys in .data and .index are in the same order by doing this:

data = {k: data[k] for k in self.index}

This might not be assured if bypass_check == True.

I added some tests for the new functionality. Again, any and all feedback/concerns/thoughts are welcome!

gviejo commented 2 months ago

You can check the linting with the following commands :

black --check pynapple
isort --check pynapple --profile black
flake8 pynapple --max-complexity 10
coverage run --source=pynapple --branch -m pytest tests/
coverage report -m
eschombu commented 1 month ago

Reformatted with black, hopefully all good now. Let me know if you have any further comments/requests/suggestions.

gviejo commented 1 month ago

Great thanks Eric