Changing except Error type to match no files found#2226
Changing except Error type to match no files found#2226jeylau merged 2 commits intoDeepLabCut:mainfrom nattse:main
Conversation
If there are no filtered files, `pd.read_hdf(glob.glob('/some/path/*filtered.h5')[0])` will raise an IndexError as a result of indexing the empty list returned by glob, which will prevent read_hdf from raising the expected FileNotFoundError. I cannot think of any way that glob will return a list of length > 0 but the contents lead to a nonexistent .h5 file
If df_cam1 and df_cam2 have different lengths (i.e. video frames don't perfectly match), np.reshape will fail at attempting to fit df_cam2 to a df_cam1-sized array
|
Second commit addresses #2205. If videos from camera-1 and camera-2 differ in length, the resulting .h5 tracking files will also differ in length. Original code reads both camera .h5 files and attempts to reshape them according to camera-1 array size, resulting in a ValueError when camera-2 data is not of the same size. However, any difference in video length is already addressed in triangulation.py, which creates a 3d.h5 file that contains as many frames as the shortest video. Therefore, we can slice both 2D tracking arrays according to the 3d.h5 data size and then reshape, knowing that their sizes will match. Example of my own run-in with this issue below; camera-1 video had 3575 frames and camera-2 video had 3576 frames. |
|
Really great catch @nattse, thank you so much for troubleshooting this one! |

If there are no filtered files,
pd.read_hdf(glob.glob('/some/path/*filtered.h5')[0])will raise an IndexError as a result of indexing the empty list returned by glob, which will precede/prevent read_hdf from raising the expected FileNotFoundError. I cannot think of any way that glob will return a list of length > 0 but the contents lead to a nonexistent .h5 file