Skip to content

Commit 8bddedd

Browse files
Merge pull request #431 from NOAA-OWP/issue429
Ignore the software-generated "all data" threshold when eliminating f…
2 parents 8de9878 + d42317a commit 8bddedd

File tree

3 files changed

+34
-13
lines changed

3 files changed

+34
-13
lines changed

wres-config/src/wres/config/yaml/DeclarationUtilities.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -891,22 +891,26 @@ public static EvaluationDeclaration removeFeaturesWithoutThresholds( EvaluationD
891891

892892
Set<Threshold> thresholds = DeclarationUtilities.getInbandThresholds( declaration );
893893

894-
// Get the names of features with thresholds
894+
// Get the names of features with thresholds that were read from a source and not generated by the software:
895+
// see GitHub #429
895896
Set<String> leftFeatureNamesWithThresholds = thresholds.stream()
896897
.filter( n -> n.featureNameFrom()
897-
== DatasetOrientation.LEFT )
898+
== DatasetOrientation.LEFT
899+
&& !n.generated() )
898900
.map( n -> n.feature()
899901
.getName() )
900902
.collect( Collectors.toSet() );
901903
Set<String> rightFeatureNamesWithThresholds = thresholds.stream()
902904
.filter( n -> n.featureNameFrom()
903-
== DatasetOrientation.RIGHT )
905+
== DatasetOrientation.RIGHT
906+
&& !n.generated() )
904907
.map( n -> n.feature()
905908
.getName() )
906909
.collect( Collectors.toSet() );
907910
Set<String> baselineFeatureNamesWithThresholds = thresholds.stream()
908911
.filter( n -> n.featureNameFrom()
909-
== DatasetOrientation.BASELINE )
912+
== DatasetOrientation.BASELINE
913+
&& !n.generated() )
910914
.map( n -> n.feature()
911915
.getName() )
912916
.collect( Collectors.toSet() );

wres-config/test/wres/config/yaml/DeclarationUtilitiesTest.java

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -776,7 +776,7 @@ void testIsReadableFileReturnsFalseForInvalidPath()
776776
- some_file.csv
777777
predicted:
778778
- another_file.csv
779-
""";
779+
""";
780780

781781
FileSystem fileSystem = FileSystems.getDefault();
782782
assertFalse( DeclarationUtilities.isReadableFile( fileSystem, path ) );
@@ -1184,6 +1184,9 @@ void testRemoveFeaturesWithoutThresholds()
11841184
Geometry baseline = Geometry.newBuilder()
11851185
.setName( "baz" )
11861186
.build();
1187+
Geometry allDataGeometry = Geometry.newBuilder()
1188+
.setName( "qux" )
1189+
.build();
11871190

11881191
// Tuple foo-bar-baz
11891192
GeometryTuple one = GeometryTuple.newBuilder()
@@ -1204,6 +1207,13 @@ void testRemoveFeaturesWithoutThresholds()
12041207
.setBaseline( left )
12051208
.build();
12061209

1210+
// Tuple qux
1211+
GeometryTuple four = GeometryTuple.newBuilder()
1212+
.setLeft( allDataGeometry )
1213+
.setRight( allDataGeometry )
1214+
.setBaseline( allDataGeometry )
1215+
.build();
1216+
12071217
Threshold threshold = Threshold.newBuilder()
12081218
.setLeftThresholdValue( 1 )
12091219
.build();
@@ -1225,8 +1235,12 @@ void testRemoveFeaturesWithoutThresholds()
12251235
.feature( baseline )
12261236
.featureNameFrom( DatasetOrientation.BASELINE )
12271237
.build();
1238+
wres.config.yaml.components.Threshold allDataThreshold =
1239+
ThresholdBuilder.builder( DeclarationUtilities.GENERATED_ALL_DATA_THRESHOLD )
1240+
.feature( allDataGeometry )
1241+
.build();
12281242

1229-
Set<GeometryTuple> geometryTuples = Set.of( one, two, three );
1243+
Set<GeometryTuple> geometryTuples = Set.of( one, two, three, four );
12301244
Features features = FeaturesBuilder.builder()
12311245
.geometries( geometryTuples )
12321246
.build();
@@ -1243,7 +1257,8 @@ void testRemoveFeaturesWithoutThresholds()
12431257
.featureGroups( featureGroups )
12441258
.thresholds( Set.of( wrappedThresholdOne,
12451259
wrappedThresholdTwo,
1246-
wrappedThresholdThree ) )
1260+
wrappedThresholdThree,
1261+
allDataThreshold ) )
12471262
.build();
12481263

12491264
EvaluationDeclaration actual = DeclarationUtilities.removeFeaturesWithoutThresholds( declaration );
@@ -1263,7 +1278,8 @@ void testRemoveFeaturesWithoutThresholds()
12631278
.featureGroups( expectedFeatureGroups )
12641279
.thresholds( Set.of( wrappedThresholdOne,
12651280
wrappedThresholdTwo,
1266-
wrappedThresholdThree ) )
1281+
wrappedThresholdThree,
1282+
allDataThreshold ) )
12671283
.build();
12681284

12691285
assertEquals( expected, actual );
@@ -1274,11 +1290,11 @@ void testRemoveFeaturesWithoutThresholdsRemovesNoFeaturesWhenEachFeatureHasAThre
12741290
{
12751291
// Tests GitHub issue #319
12761292
Geometry oneObserved = Geometry.newBuilder()
1277-
.setName( "one_observed" )
1278-
.build();
1293+
.setName( "one_observed" )
1294+
.build();
12791295
Geometry onePredicted = Geometry.newBuilder()
1280-
.setName( "one_predicted" )
1281-
.build();
1296+
.setName( "one_predicted" )
1297+
.build();
12821298
Geometry twoObserved = Geometry.newBuilder()
12831299
.setName( "two_observed" )
12841300
.build();

wres-reading/src/wres/reading/wrds/thresholds/WrdsThresholdReader.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -704,7 +704,8 @@ private static void validate( URI uri,
704704
Set<String> thresholdNamesWithoutFeatures = new TreeSet<>( thresholdFeatureNames );
705705
thresholdNamesWithoutFeatures.removeAll( featureNames.keySet() );
706706

707-
if ( ( !featureNamesWithoutThresholds.isEmpty() || !thresholdNamesWithoutFeatures.isEmpty() )
707+
if ( ( !featureNamesWithoutThresholds.isEmpty()
708+
|| !thresholdNamesWithoutFeatures.isEmpty() )
708709
&& LOGGER.isWarnEnabled() )
709710
{
710711
LOGGER.warn( "{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}",

0 commit comments

Comments
 (0)