Skip to content

Commit

Permalink
Use defaultdict to shorten code
Browse files Browse the repository at this point in the history
  • Loading branch information
berland committed Oct 24, 2023
1 parent 5500dc5 commit b100fb3
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions src/ert/gui/model/snapshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,17 +117,11 @@ def prerender(

if isinstance(snapshot, Snapshot):
metadata[SORTED_REALIZATION_IDS] = sorted(snapshot.reals.keys(), key=int)
metadata[SORTED_JOB_IDS] = defaultdict(dict)
for idx, _ in job_states.items():
real_id, job_id = idx
if real_id not in metadata[SORTED_JOB_IDS]:
metadata[SORTED_JOB_IDS][real_id] = []
metadata[SORTED_JOB_IDS] = defaultdict(list)
for (real_id, job_id), _ in job_states.items():
metadata[SORTED_JOB_IDS][real_id].append(job_id)

for idx, job_status in job_states.items():
real_id, job_id = idx

# partial snapshot may contain only information about job state
for (real_id, job_id), job_status in job_states.items():
if real_id in reals and reals[real_id].status:
metadata[REAL_STATUS_COLOR][real_id] = _QCOLORS[
state.REAL_STATE_TO_COLOR[reals[real_id].status]
Expand Down

0 comments on commit b100fb3

Please sign in to comment.