diff --git a/wres-config/src/wres/config/yaml/DeclarationUtilities.java b/wres-config/src/wres/config/yaml/DeclarationUtilities.java index 1f0d9b031..994220a80 100644 --- a/wres-config/src/wres/config/yaml/DeclarationUtilities.java +++ b/wres-config/src/wres/config/yaml/DeclarationUtilities.java @@ -891,22 +891,26 @@ public static EvaluationDeclaration removeFeaturesWithoutThresholds( EvaluationD Set thresholds = DeclarationUtilities.getInbandThresholds( declaration ); - // Get the names of features with thresholds + // Get the names of features with thresholds that were read from a source and not generated by the software: + // see GitHub #429 Set leftFeatureNamesWithThresholds = thresholds.stream() .filter( n -> n.featureNameFrom() - == DatasetOrientation.LEFT ) + == DatasetOrientation.LEFT + && !n.generated() ) .map( n -> n.feature() .getName() ) .collect( Collectors.toSet() ); Set rightFeatureNamesWithThresholds = thresholds.stream() .filter( n -> n.featureNameFrom() - == DatasetOrientation.RIGHT ) + == DatasetOrientation.RIGHT + && !n.generated() ) .map( n -> n.feature() .getName() ) .collect( Collectors.toSet() ); Set baselineFeatureNamesWithThresholds = thresholds.stream() .filter( n -> n.featureNameFrom() - == DatasetOrientation.BASELINE ) + == DatasetOrientation.BASELINE + && !n.generated() ) .map( n -> n.feature() .getName() ) .collect( Collectors.toSet() ); diff --git a/wres-config/test/wres/config/yaml/DeclarationUtilitiesTest.java b/wres-config/test/wres/config/yaml/DeclarationUtilitiesTest.java index cb51255e6..199460f74 100644 --- a/wres-config/test/wres/config/yaml/DeclarationUtilitiesTest.java +++ b/wres-config/test/wres/config/yaml/DeclarationUtilitiesTest.java @@ -776,7 +776,7 @@ void testIsReadableFileReturnsFalseForInvalidPath() - some_file.csv predicted: - another_file.csv - """; + """; FileSystem fileSystem = FileSystems.getDefault(); assertFalse( DeclarationUtilities.isReadableFile( fileSystem, path ) ); @@ -1184,6 +1184,9 @@ void testRemoveFeaturesWithoutThresholds() Geometry baseline = Geometry.newBuilder() .setName( "baz" ) .build(); + Geometry allDataGeometry = Geometry.newBuilder() + .setName( "qux" ) + .build(); // Tuple foo-bar-baz GeometryTuple one = GeometryTuple.newBuilder() @@ -1204,6 +1207,13 @@ void testRemoveFeaturesWithoutThresholds() .setBaseline( left ) .build(); + // Tuple qux + GeometryTuple four = GeometryTuple.newBuilder() + .setLeft( allDataGeometry ) + .setRight( allDataGeometry ) + .setBaseline( allDataGeometry ) + .build(); + Threshold threshold = Threshold.newBuilder() .setLeftThresholdValue( 1 ) .build(); @@ -1225,8 +1235,12 @@ void testRemoveFeaturesWithoutThresholds() .feature( baseline ) .featureNameFrom( DatasetOrientation.BASELINE ) .build(); + wres.config.yaml.components.Threshold allDataThreshold = + ThresholdBuilder.builder( DeclarationUtilities.GENERATED_ALL_DATA_THRESHOLD ) + .feature( allDataGeometry ) + .build(); - Set geometryTuples = Set.of( one, two, three ); + Set geometryTuples = Set.of( one, two, three, four ); Features features = FeaturesBuilder.builder() .geometries( geometryTuples ) .build(); @@ -1243,7 +1257,8 @@ void testRemoveFeaturesWithoutThresholds() .featureGroups( featureGroups ) .thresholds( Set.of( wrappedThresholdOne, wrappedThresholdTwo, - wrappedThresholdThree ) ) + wrappedThresholdThree, + allDataThreshold ) ) .build(); EvaluationDeclaration actual = DeclarationUtilities.removeFeaturesWithoutThresholds( declaration ); @@ -1263,7 +1278,8 @@ void testRemoveFeaturesWithoutThresholds() .featureGroups( expectedFeatureGroups ) .thresholds( Set.of( wrappedThresholdOne, wrappedThresholdTwo, - wrappedThresholdThree ) ) + wrappedThresholdThree, + allDataThreshold ) ) .build(); assertEquals( expected, actual ); @@ -1274,11 +1290,11 @@ void testRemoveFeaturesWithoutThresholdsRemovesNoFeaturesWhenEachFeatureHasAThre { // Tests GitHub issue #319 Geometry oneObserved = Geometry.newBuilder() - .setName( "one_observed" ) - .build(); + .setName( "one_observed" ) + .build(); Geometry onePredicted = Geometry.newBuilder() - .setName( "one_predicted" ) - .build(); + .setName( "one_predicted" ) + .build(); Geometry twoObserved = Geometry.newBuilder() .setName( "two_observed" ) .build(); diff --git a/wres-reading/src/wres/reading/wrds/thresholds/WrdsThresholdReader.java b/wres-reading/src/wres/reading/wrds/thresholds/WrdsThresholdReader.java index 92a0ea4a5..44afc769e 100644 --- a/wres-reading/src/wres/reading/wrds/thresholds/WrdsThresholdReader.java +++ b/wres-reading/src/wres/reading/wrds/thresholds/WrdsThresholdReader.java @@ -704,7 +704,8 @@ private static void validate( URI uri, Set thresholdNamesWithoutFeatures = new TreeSet<>( thresholdFeatureNames ); thresholdNamesWithoutFeatures.removeAll( featureNames.keySet() ); - if ( ( !featureNamesWithoutThresholds.isEmpty() || !thresholdNamesWithoutFeatures.isEmpty() ) + if ( ( !featureNamesWithoutThresholds.isEmpty() + || !thresholdNamesWithoutFeatures.isEmpty() ) && LOGGER.isWarnEnabled() ) { LOGGER.warn( "{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}",