Open skirpichev opened 3 months ago
Clones of assertFloatsAreIdentical() are scattered across the CPython tests: https://github.com/python/cpython/blob/d8f82432a36178a2376cc2d0984b02bb03f6d55f/Lib/test/test_complex.py#L74 https://github.com/python/cpython/blob/d8f82432a36178a2376cc2d0984b02bb03f6d55f/Lib/test/test_cmath.py#L68 https://github.com/python/cpython/blob/d8f82432a36178a2376cc2d0984b02bb03f6d55f/Lib/test/test_float.py#L1069 https://github.com/python/cpython/blob/d8f82432a36178a2376cc2d0984b02bb03f6d55f/Lib/test/test_capi/test_getargs.py#L440
Maybe it's worth to have a dedicated check?
Or a special kwarg for the assertEqual method, to workaround NAN and -0.0 values for floats/complexes.
NAN
-0.0
Edit:
Or at least some support from Lib/test/support... I was adding similar helper yet in another test file and that looks odd.
Numpy has numpy.testing.assert_equal():
>>> np.testing.assert_equal([0.0], [+0.0]) >>> np.testing.assert_equal([0.0], [-0.0]) Traceback (most recent call last): ... AssertionError: Items are not equal: item=0 ACTUAL: 0.0 DESIRED: -0.0 >>> np.testing.assert_equal([np.nan], [np.nan]) >>> np.testing.assert_equal([0.0], [np.nan]) Traceback (most recent call last): ... AssertionError: Items are not equal: item=0 ACTUAL: 0.0 DESIRED: nan
This is a minor feature, which does not need previous discussion elsewhere
No response
pr is ready: https://github.com/python/cpython/pull/121071 (it implements the last option: methods added to test.support)
Feature or enhancement
Proposal:
Clones of assertFloatsAreIdentical() are scattered across the CPython tests: https://github.com/python/cpython/blob/d8f82432a36178a2376cc2d0984b02bb03f6d55f/Lib/test/test_complex.py#L74 https://github.com/python/cpython/blob/d8f82432a36178a2376cc2d0984b02bb03f6d55f/Lib/test/test_cmath.py#L68 https://github.com/python/cpython/blob/d8f82432a36178a2376cc2d0984b02bb03f6d55f/Lib/test/test_float.py#L1069 https://github.com/python/cpython/blob/d8f82432a36178a2376cc2d0984b02bb03f6d55f/Lib/test/test_capi/test_getargs.py#L440
Maybe it's worth to have a dedicated check?
Or a special kwarg for the assertEqual method, to workaround
NAN
and-0.0
values for floats/complexes.Edit:
Or at least some support from Lib/test/support... I was adding similar helper yet in another test file and that looks odd.
Numpy has numpy.testing.assert_equal():
Has this already been discussed elsewhere?
This is a minor feature, which does not need previous discussion elsewhere
Links to previous discussion of this feature:
No response
Linked PRs