You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by GitBox <gi...@apache.org> on 2021/07/16 14:05:08 UTC
[GitHub] [beam] jrmccluskey commented on a change in pull request #15175: [BEAM-12548] Implement EqualsFloat test helper
jrmccluskey commented on a change in pull request #15175:
URL: https://github.com/apache/beam/pull/15175#discussion_r671281436
##########
File path: sdks/go/pkg/beam/testing/passert/floats.go
##########
@@ -26,6 +26,56 @@ import (
"github.com/apache/beam/sdks/go/pkg/beam/internal/errors"
)
+// EqualsFloat checks that two PCollections of floats are equal, with each element
+// being within a specified threshold of its corresponding element. Both PCollections
+// are loaded into memory, sorted, and compared element by element.
+func EqualsFloat(s beam.Scope, observed, expected beam.PCollection, threshold float64) {
+ s = s.Scope(fmt.Sprintf("passert.EqualsFloat[%v]", threshold))
+ beam.ParDo0(s, &thresholdFn{threshold: threshold}, beam.Impulse(s), beam.SideInput{Input: observed}, beam.SideInput{Input: expected})
+}
+
+type thresholdFn struct {
+ threshold float64
Review comment:
Done
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org