pynwb
pynwb copied to clipboard
request: `nwbfile.create_electrode_table_region` should take type `range`
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 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(...))
.
Yeah that's true
@oruebel would it be reasonable to request that it takes any iterable?
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.
in general, broader support for duck typing in pynwb would make the package way more user friendly