Skip to content

Commit

Permalink
output_checksums are now a defaultdict[str, list[any]]
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeGat committed Feb 21, 2024
1 parent a9b65f3 commit 9080dc8
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions test/models/accessom2.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

# NOTE for developers: `f90nml` is imported implicitly when this code is running in
# the `Payu` conda environment.
from collections import defaultdict
import f90nml
import re
from pathlib import Path
Expand Down Expand Up @@ -55,7 +56,15 @@ def extract_checksums(self,
# [chksum] htr 928360042410663049
pattern = r'\[chksum\]\s+(.+)\s+(-?\d+)'

output_checksums: dict[str, any] = {}
# checksums outputted in form:
# {
# "ht": ["-2390360641069121536"],
# "hu": ["6389284661071183872"],
# "htr": ["928360042410663049"]
# }
# with potential for multiple checksums for one key.
output_checksums: dict[str, list[any]] = defaultdict(list)

with open(output_filename) as f:
for line in f:
# Check for checksum pattern match
Expand All @@ -64,7 +73,8 @@ def extract_checksums(self,
# Extract values
field = match.group(1).strip()
checksum = match.group(2).strip()
output_checksums[field] = checksum

output_checksums[field].append(checksum)

if schema_version is None:
schema_version = DEFAULT_SCHEMA_VERSION
Expand Down

0 comments on commit 9080dc8

Please sign in to comment.