tests: Add unit tests for Paragraph alignment#4614
tests: Add unit tests for Paragraph alignment#4614Hangeerh wants to merge 3 commits intoManimCommunity:mainfrom
Conversation
behackl
left a comment
There was a problem hiding this comment.
Tests seem fine to me, thanks for your contribution! I've left one request for a change with the assert statements, but other than that I'm happy to merge this.
| def float_eq(a: float, b: float, delta: float = 1e-2): | ||
| return abs(a - b) <= delta |
There was a problem hiding this comment.
I'd rather use np.testing.assert_almost_equal with digits set to something reasonable over a custom numerical comparison method. Could you please change the asserts accordingly and remove float_eq?
There was a problem hiding this comment.
I have changed it to use numpy.testing.assert_almost_equal
This replaces the previous custom float comparison function with a numpy function.
|
I've swapped out the previous custom function to use I chose to compare up to two decimal places, because the width of one of the underlying |
Overview:
Added unit tests for Paragraph alignment. The changes implement a portion of features proposed in issue 2839, specifically tests for changes introduced in Fixed bad text slicing for lines in :class:.Paragraph #2721 .
Motivation and Explanation: Why and how do your changes improve the library?
Further Information and Comments
We test for left alignment by getting the underlying
VMobjectFromSVGPathfor the first character of each line, and comparing them using a custom float comparison funcition.Similarly when testing for right alignment, we compare the last letter of each line.
When testing for center alignment, we compute the average of the left of the first character and the right of the last character in each line. This is supposed to give us an estimate of where the middle of the line is. We then compare them for each line.
Reviewer Checklist