pynwb icon indicating copy to clipboard operation
pynwb copied to clipboard

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

Open bendichter opened this issue 7 years ago • 5 comments

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.

bendichter avatar Feb 01 '18 21:02 bendichter

@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(...)).

oruebel avatar Feb 01 '18 21:02 oruebel

Yeah that's true

bendichter avatar Feb 01 '18 21:02 bendichter

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

neuromusic avatar Feb 01 '18 21:02 neuromusic

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.

bendichter avatar Feb 20 '18 20:02 bendichter

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

neuromusic avatar Feb 20 '18 20:02 neuromusic