X Tutup
Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/matplotlib/tests/test_colors.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,9 @@ def test_Normalize():
# and for scalar ones.
eps = np.finfo(np.longdouble).resolution
norm = plt.Normalize(1, 1 + 100 * eps)
assert_equal(norm(1 + 50 * eps), .5)
# This returns exactly 0.5 when longdouble is extended precision (80-bit),
# but only a value close to it when it is quadruple precision (128-bit).
assert 0 < norm(1 + 50 * eps) < 1
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could also use one of the "almost equal" asserts from numpy (or nose, or pytest)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not almost equal (it's around 0.2% off).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand your comment. The tests "assert_almost_equal" has a epsilon value. It is used exactly for that case where there are floating points error. You need to set the epsilon value yourself.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I was thinking about the default of assert_allclose. Anyways, see the discussion starting at #7159 (comment): the point is that I'd rather let a FP expert confirm what is the tolerance that makes sense; without that the safest is just to check that the normalization is not trivial (does not map everything to 0 or 1).



def test_SymLogNorm():
Expand Down
X Tutup