Commit ee01683a authored by Marco Kurzynski's avatar Marco Kurzynski
Browse files

fixed compare.py

parent 08aa4e78
#!/usr/bin/env python3.8
#!/usr/bin/env python3
import sys
from difflib import unified_diff
......@@ -7,8 +7,6 @@ import numpy as np
from argparse import ArgumentParser
from pathlib import PosixPath
from PIL import Image
from glob import glob
from subprocess import run
from collections import Counter
from itertools import chain
import netCDF4 as nc
......@@ -49,8 +47,10 @@ def compare_nc(nc1, nc2, percent_error=0.0, ignore=[]):
except KeyError:
print(f"{tcolor.GREEN} Dimension {key} missing{tcolor.ENDC}")
ret = -1
if len(nc1.ncattrs()) != len(nc2.ncattrs()):
print(f'{tcolor.GREEN} Number of attributes differ{tcolor.ENDC}')
c = Counter(attr for attr in nc1.ncattrs() + nc2.ncattrs())
if 1 in c.values(): # if 1 in values, that means an attr appeared in one nc file
print(f'{tcolor.GREEN} Attributes differ: {[attr for attr in c.keys() if c[attr] == 1]}{tcolor.ENDC}')
ret = -1
# if test have failed, return now
......@@ -228,9 +228,9 @@ def main(argv=sys.argv[1:]):
files1 = sorted(get_files(input1.iterdir()))
files2 = sorted(get_files(input2.iterdir()))
# check which files are in both directories
counter = dict(Counter(file.name for file in files1 + files2))
c = Counter(file.name for file in files1 + files2)
for fname, count in counter.items():
for fname, count in c.items():
if count == 1:
final_ret = -1
for f in files1 + files2:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment