NeurodataWithoutBorders / pynwb

A Python API for working with Neurodata stored in the NWB Format
https://pynwb.readthedocs.io
Other
178 stars 84 forks source link

request: `nwbfile.create_electrode_table_region` should take type `range` #350

Open bendichter opened 6 years ago

bendichter commented 6 years ago

Low priority, but this would be a nice little usability improvement.

When I try

all_table_region = nwbfile.create_electrode_table_region(
    range(electrode_counter), 'all electrodes')

I get

TypeError: incorrect type for 'region' (got 'range', expected 'slice, list, tuple or RegionReference')

I can fix this by wrapping range in list, but it would be nice if pynwb handled this kind of thing.

oruebel commented 6 years ago

@bendichter this I think at least in part a Python 2 vs. 3 issue. In Python 2 range is a list and in 3 its an iterator (i.e., what xrange is in Python2). Because of this it is not uncommon in Py3 that you have to do list(range(...)).

bendichter commented 6 years ago

Yeah that's true

neuromusic commented 6 years ago

@oruebel would it be reasonable to request that it takes any iterable?

bendichter commented 6 years ago

I'd also like NWB objects to accept pandas.Series objects. Again, I can get it in with np.array(series), but it would be more usable if these objects accepted iterators.

neuromusic commented 6 years ago

in general, broader support for duck typing in pynwb would make the package way more user friendly