Skip to content

Commit 770011b

Browse files
fix(model): improve debug report for reading results
1 parent bd83064 commit 770011b

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

honeybee_display/model.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -511,14 +511,25 @@ def _read_sensor_grid_result(result_folder):
511511
result_file = os.path.join(result_folder, f)
512512
break
513513
if result_file is not None:
514-
print(f'Loading results for {grid_id} with {sensor_count} sensors. Starting from line {st_ln}.')
514+
print(
515+
f'Loading results for {grid_id} with {sensor_count} sensors. '
516+
f'Starting from line {st_ln}.'
517+
)
515518
with open(result_file) as inf:
516519
for _ in range(st_ln):
517520
next(inf)
518-
for _ in range(sensor_count):
521+
for count in range(sensor_count):
519522
try:
520-
results.append(float(next(inf)))
521-
except StopIteration:
523+
value = float(next(inf))
524+
except (StopIteration, ValueError):
522525
content = pathlib.Path(result_file).read_text()
523-
raise ValueError(f'Failed to load the results. Here is the content of the file: {content}')
526+
ln_count = len(content.split())
527+
raise ValueError(
528+
f'Failed to load the results for {grid_id} '
529+
f'with {sensor_count} sensors. Sensor id: {count}\n'
530+
f'Here is the content of the file with {ln_count} values:\n'
531+
f'## Start of the file\n{content}\n## End of the file.'
532+
)
533+
else:
534+
results.append(value)
524535
return results

0 commit comments

Comments
 (0)