Skip to content

Commit

Permalink
Merge pull request #1456 from Windsooon/v1.11-preview
Browse files Browse the repository at this point in the history
Add explicit error messages
  • Loading branch information
papr authored Mar 1, 2019
2 parents f76b685 + 8fe6d29 commit 29e089e
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions pupil_src/shared_modules/update_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,22 +421,29 @@ def check_for_worldless_recording(rec_dir):
if fake_world["version"] == fake_world_version:
return

logger.warning("No world video found. Constructing an artificial replacement.")
eye_ts_files = glob.glob(os.path.join(rec_dir, "eye*_timestamps.npy"))

min_ts = np.inf
max_ts = -np.inf
for f in glob.glob(os.path.join(rec_dir, "eye*_timestamps.npy")):
for f in eye_ts_files:
try:
eye_ts = np.load(f)
assert len(eye_ts.shape) == 1
assert eye_ts.shape[0] > 1
min_ts = min(min_ts, eye_ts[0])
max_ts = max(max_ts, eye_ts[-1])
except (FileNotFoundError, AssertionError):
pass

error_msg = "Could not generate world timestamps from eye timestamps. This is an invalid recording."
assert -np.inf < min_ts < max_ts < np.inf, error_msg

logger.warning("No world video found. Constructing an artificial replacement.")
except AssertionError:
logger.debug(
(
"Ignoring {} since it does not conform with the expected format"
" (one-dimensional list with at least two entries)".format(f)
)
)
assert -np.inf < min_ts < max_ts < np.inf, (
"This recording is invalid because it does not contain any valid eye timestamp"
" files from which artifical world timestamps could be generated from."
)

frame_rate = 30
timestamps = np.arange(min_ts, max_ts, 1 / frame_rate)
Expand Down

0 comments on commit 29e089e

Please sign in to comment.