diff --git a/wres-config/src/wres/config/yaml/DeclarationInterpolator.java b/wres-config/src/wres/config/yaml/DeclarationInterpolator.java index 13520e57e..884cc61e0 100644 --- a/wres-config/src/wres/config/yaml/DeclarationInterpolator.java +++ b/wres-config/src/wres/config/yaml/DeclarationInterpolator.java @@ -1883,6 +1883,8 @@ private static Metric addThresholdsToMetric( Map test = parametersBuilder.thresholds() + .stream() + .filter( t -> !t.generated() ) + .collect( Collectors.toSet() ); + + if ( test.size() == 1 + && test.iterator() + .next() + .threshold() + .equals( DeclarationUtilities.ALL_DATA_THRESHOLD.threshold() ) ) { LOGGER.debug( "The metric {} contained a threshold override for 'all data' only.", name ); globalThresholds = Map.of(); + overrideAllData = true; } } @@ -1919,14 +1920,10 @@ private static Metric addThresholdsToMetric( Map thresholds = Set.of( oneWrapped ); + + EvaluationDeclaration declaration = EvaluationDeclarationBuilder.builder() + .left( this.observedDataset ) + .right( this.predictedDataset ) + .probabilityThresholds( thresholds ) + .metrics( Set.of( metric, anotherMetric ) ) + .build(); + + VariableNames variableNames = new VariableNames( null, + null, + null, + null ); + DataTypes dataTypes = new DataTypes( null, null, null, null ); + TimeScale timeScale = TimeScale.newBuilder() + .setPeriod( com.google.protobuf.Duration.newBuilder().setSeconds( 64 ) ) + .setFunction( TimeScale.TimeScaleFunction.MEAN ) + .build(); + + EvaluationDeclaration interpolated = DeclarationInterpolator.interpolate( declaration, + dataTypes, + variableNames, + "foo", + timeScale, + false ); + + Metric expectedOne = + new Metric( MetricConstants.MEAN_ERROR, + MetricParametersBuilder.builder() + .thresholds( Set.of( DeclarationUtilities.ALL_DATA_THRESHOLD ) ) + .build() ); + + Metric expectedTwo = + new Metric( MetricConstants.MEAN_ABSOLUTE_ERROR, + MetricParametersBuilder.builder() + .thresholds( Set.of( DeclarationUtilities.GENERATED_ALL_DATA_THRESHOLD ) ) + .probabilityThresholds( thresholds ) + .build() ); + + Set expected = Set.of( expectedOne, expectedTwo ); + Set actual = interpolated.metrics(); + + assertEquals( expected, actual ); + } + // The testDeserializeAndInterpolate* tests are integration tests of deserialization plus interpolation @Test