SreeramaYeshwanthGowd opened a new pull request, #39443:
URL: https://github.com/apache/beam/pull/39443
### Problem
The `assert_that` matchers only offer exact equality through `equal_to`.
Pipelines that produce floating point results are awkward to assert, because
callers have to hand write an `equals_fn` in every test. Issue #18028 asks to
expand the set of matchers.
### Solution
Add `equal_to_approx`, an `assert_that` matcher that behaves like `equal_to`
for
ordering and membership but compares real number elements, including numbers
nested in tuples or lists, with `math.isclose` using configurable `rel_tol`
and
`abs_tol`. All other elements are compared with `==`. It is a thin wrapper
over
the existing `equal_to(equals_fn=...)` mechanism and adds no new dependency.
### Testing
Added unit tests in `util_test.py` covering values within and outside
tolerance
(including a nested value outside tolerance), nested tuples and lists,
`rel_tol`
and `abs_tol`, non numeric passthrough, and an empty PCollection.
Fixes #18028
------------------------
Thank you for your contribution! Follow this checklist to help us
incorporate your contribution quickly and easily:
- [x] Mention the appropriate issue in your description (for example:
`addresses #123`), if applicable. This will automatically add a link to the
pull request in the issue. If you would like the issue to automatically close
on merging the pull request, comment `fixes #<ISSUE NUMBER>` instead.
- [x] Update `CHANGES.md` with noteworthy changes.
- [ ] If this contribution is large, please file an Apache [Individual
Contributor License Agreement](https://www.apache.org/licenses/icla.pdf).
See the [Contributor Guide](https://beam.apache.org/contribute) for more
tips on [how to make review process
smoother](https://github.com/apache/beam/blob/master/CONTRIBUTING.md#make-the-reviewers-job-easier).
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]