Unlike np.s_, our own special slices by_id and by_index do not support scalar integers to select a single train by ID or index:
run.select_trains(np.s_[0])
<extra_data.DataCollection for 81 sources and 1 trains>
run.select_trains(by_index[0])
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
Cell In[130], line 1
----> 1 run.select_trains(by_index[0])
File ~/code/EXtra-data/extra_data/reader.py:1091, in DataCollection.select_trains(self, train_range)
1071 def select_trains(self, train_range):
1072 """Select a subset of trains from this data.
1073
1074 Slice trains by position within this data::
(...)
1089 If given train IDs do not overlap with the trains in this data.
1090 """
-> 1091 new_train_ids = select_train_ids(self.train_ids, train_range)
1093 sources_data = {
1094 src: srcdata._only_tids(new_train_ids)
1095 for src, srcdata in self._sources_data.items()
1096 }
1098 files = set().union(*[sd.files for sd in sources_data.values()])
File ~/code/EXtra-data/extra_data/read_machinery.py:135, in select_train_ids(train_ids, sel)
133 return sorted(np.asarray(train_ids)[sel])
134 else:
--> 135 raise TypeError(type(sel))
TypeError: <class 'int'>
run.select_trains(by_id[run.train_ids[0]])
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
Cell In[131], line 1
----> 1 run.select_trains(by_id[run.train_ids[0]])
File ~/code/EXtra-data/extra_data/reader.py:1091, in DataCollection.select_trains(self, train_range)
1071 def select_trains(self, train_range):
1072 """Select a subset of trains from this data.
1073
1074 Slice trains by position within this data::
(...)
1089 If given train IDs do not overlap with the trains in this data.
1090 """
-> 1091 new_train_ids = select_train_ids(self.train_ids, train_range)
1093 sources_data = {
1094 src: srcdata._only_tids(new_train_ids)
1095 for src, srcdata in self._sources_data.items()
1096 }
1098 files = set().union(*[sd.files for sd in sources_data.values()])
File ~/code/EXtra-data/extra_data/read_machinery.py:135, in select_train_ids(train_ids, sel)
133 return sorted(np.asarray(train_ids)[sel])
134 else:
--> 135 raise TypeError(type(sel))
TypeError: <class 'extra_data.read_machinery.by_id'>
Unlike
np.s_
, our own special slicesby_id
andby_index
do not support scalar integers to select a single train by ID or index:run.select_trains(np.s_[0])
run.select_trains(by_index[0])
run.select_trains(by_id[run.train_ids[0]])