ros2 / rosidl_python

rosidl support for Python
Apache License 2.0
20 stars 45 forks source link

:man_farmer: Fix NaN values bound numpy windows version #182

Closed Crola1702 closed 2 years ago

Crola1702 commented 2 years ago

:fly: BugFix

Issue

Reference build: Nightly Windows Debug

Log output:

>       assert numpy.array_equal(arr_of_float32_with_nan, msg.float32_values, equal_nan=True)

C:\ci\ws\src\ros2\rosidl_python\rosidl_generator_py\test\test_interfaces.py:508: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

args = (array([-1.33,   nan,  1.33], dtype=float32), array([-1.33,   nan,  1.33], dtype=float32))
kwargs = {'equal_nan': True}

>   ???
E   TypeError: _array_equal_dispatcher() got an unexpected keyword argument 'equal_nan'

<__array_function__ internals>:4: TypeError

Investigation

The proposed solution changes this test behavior to support both numpy <= 1.18 and >= 1.19.

Selected implementation: https://github.com/rossbar/numpy/blob/main/numpy/core/numeric.py#L2475

asarray(a1[~a1nan] == a2[~a1nan]).all() # plus shape verification

Windows build: Build Status Linux aarch64 build:Build Status Linux build: Build Status

Blast545 commented 2 years ago

Do you think this approach is OK? @sloretz (tagging you as reviewer of the original PR)

fujitatomoya commented 2 years ago

@mergify backport humble

mergify[bot] commented 2 years ago

backport humble

❌ Command disallowed due to command restrictions in the Mergify configuration.

- [ ] `sender-permission>=write`
fujitatomoya commented 2 years ago

@Mergifyio backport humble

mergify[bot] commented 2 years ago

backport humble

❌ Command disallowed due to command restrictions in the Mergify configuration.

- [ ] `sender-permission>=write`