X Tutup
Skip to content

Less stringent normalization test for float128.#7167

Merged
tacaswell merged 1 commit intomatplotlib:masterfrom
anntzer:fix-normalize-test-on-quadruple-precision
Sep 24, 2016
Merged

Less stringent normalization test for float128.#7167
tacaswell merged 1 commit intomatplotlib:masterfrom
anntzer:fix-normalize-test-on-quadruple-precision

Conversation

@anntzer
Copy link
Copy Markdown
Contributor

@anntzer anntzer commented Sep 23, 2016

cf #7159. I decided to go the less stringent way.

@NelleV NelleV changed the title Less stringent normalization test for float128. [MRG+1] Less stringent normalization test for float128. Sep 23, 2016
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).

@tacaswell tacaswell merged commit dc855ed into matplotlib:master Sep 24, 2016
tacaswell added a commit that referenced this pull request Sep 24, 2016
…-precision

TST: Less stringent normalization test for float128.
@tacaswell
Copy link
Copy Markdown
Member

backported to v2.x as 2e12ac9

@anntzer anntzer deleted the fix-normalize-test-on-quadruple-precision branch September 30, 2016 02:45
@QuLogic QuLogic added this to the 2.0 (style change major release) milestone Sep 30, 2016
@QuLogic QuLogic changed the title [MRG+1] Less stringent normalization test for float128. Less stringent normalization test for float128. Oct 16, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

X Tutup