From 52f6530493e2d0ab3422d0fe1941e2e0dfc33993 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Thu, 11 Jan 2024 17:25:52 +0000 Subject: [PATCH] Testing: Avoid comparing floats as strings (SD-88343) --- tests/bufr_extract_headers.sh | 2 +- tests/grib_tigge_conversions1.sh | 11 +++++++---- tests/grib_tigge_conversions2.sh | 11 +++++++---- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/tests/bufr_extract_headers.sh b/tests/bufr_extract_headers.sh index ad6e2b534..32cd620ec 100755 --- a/tests/bufr_extract_headers.sh +++ b/tests/bufr_extract_headers.sh @@ -203,7 +203,7 @@ tropical_cyclone.bufr tros_31.bufr " -KEYS='localLongitude1,localLatitude1,localLongitude2,localLatitude2,localNumberOfObservations,satelliteID,restricted' +KEYS='typicalDate,localNumberOfObservations,satelliteID,restricted' for bf in ${bufr_files}; do input=${data_dir}/bufr/$bf $EXEC ${test_dir}/bufr_extract_headers $KEYS $input > $temp1 diff --git a/tests/grib_tigge_conversions1.sh b/tests/grib_tigge_conversions1.sh index fc7c75a33..0147738f8 100755 --- a/tests/grib_tigge_conversions1.sh +++ b/tests/grib_tigge_conversions1.sh @@ -31,18 +31,21 @@ fi # --- Do I want to exclude any file pattern from the comparison ? exclusion_pattern="tcw|ssr|str|skt|cap|ci|ttr|st|sm|sd|slhf|sshf" +# Some very small floating-point differences shown for these +blacklist="-b iDirectionIncrementInDegrees,jDirectionIncrementInDegrees" + for file in ${dir}/tigge_[a-e]*.grib; do exclude=`echo $file | awk " /$exclusion_pattern/ {print \"found\";} "` if [ -z "$exclude" ]; then rm -f ${temp1} ${temp2} # 2 to 1 conversion check - ${tools_dir}/grib_set -s editionNumber=1 ${file} ${temp1} 2> $REDIRECT > $REDIRECT - ${tools_dir}/grib_compare -P -c data:n,geography:n ${temp1} ${file} 2> $REDIRECT > $REDIRECT + ${tools_dir}/grib_set -s editionNumber=1 ${file} ${temp1} + ${tools_dir}/grib_compare $blacklist -P -c data:n,geography:n ${temp1} ${file} # 1 to 2 conversion check - ${tools_dir}/grib_set -s editionNumber=2 ${temp1} ${temp2} 2> $REDIRECT > $REDIRECT - ${tools_dir}/grib_compare -P -c shortName,data:n,geography:n ${temp2} ${file} 2> $REDIRECT > $REDIRECT + ${tools_dir}/grib_set -s editionNumber=2 ${temp1} ${temp2} + ${tools_dir}/grib_compare $blacklist -P -c shortName,data:n,geography:n ${temp2} ${file} fi done diff --git a/tests/grib_tigge_conversions2.sh b/tests/grib_tigge_conversions2.sh index 3d80771e6..73b7a5455 100755 --- a/tests/grib_tigge_conversions2.sh +++ b/tests/grib_tigge_conversions2.sh @@ -30,18 +30,21 @@ fi # --- Do I want to exclude any file pattern from the comparison ? exclusion_pattern="tcw|ssr|str|skt|cap|ci|ttr|st|sm|sd|slhf|sshf" +# Some very small floating-point differences shown for these +blacklist="-b iDirectionIncrementInDegrees,jDirectionIncrementInDegrees" + for file in ${dir}/tigge_[f-z]*.grib; do exclude=`echo $file | awk " /$exclusion_pattern/ {print \"found\";} "` if [ -z "$exclude" ]; then rm -f ${temp1} ${temp2} # 2 to 1 conversion check - ${tools_dir}/grib_set -s editionNumber=1 ${file} ${temp1} 2> $REDIRECT > $REDIRECT - ${tools_dir}/grib_compare -P -c data:n,geography:n ${temp1} ${file} 2> $REDIRECT > $REDIRECT + ${tools_dir}/grib_set -s editionNumber=1 ${file} ${temp1} + ${tools_dir}/grib_compare $blacklist -P -c data:n,geography:n ${temp1} ${file} # 1 to 2 conversion check - ${tools_dir}/grib_set -s editionNumber=2 ${temp1} ${temp2} 2> $REDIRECT > $REDIRECT - ${tools_dir}/grib_compare -P -c shortName,data:n,geography:n ${temp2} ${file} 2> $REDIRECT > $REDIRECT + ${tools_dir}/grib_set -s editionNumber=2 ${temp1} ${temp2} + ${tools_dir}/grib_compare $blacklist -P -c shortName,data:n,geography:n ${temp2} ${file} fi done