Skip to content

Commit

Permalink
👨‍🌾 Fix NaN values bound numpy windows version (#182)
Browse files Browse the repository at this point in the history
* Replaced equal_nan for numpy<1.19

Signed-off-by: Crola1702 <cristobal.arroyo@ekumenlabs.com>
  • Loading branch information
Crola1702 authored and clalancette committed Nov 7, 2022
1 parent db6c5b8 commit 0172e75
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions rosidl_generator_py/test/test_interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -505,11 +505,16 @@ def test_arrays():
# NaN
arr_of_float32_with_nan = numpy.array([-1.33, math.nan, 1.33], dtype=numpy.float32)
setattr(msg, 'float32_values', arr_of_float32_with_nan)
assert numpy.array_equal(arr_of_float32_with_nan, msg.float32_values, equal_nan=True)
arr_with_nan = numpy.isnan(arr_of_float32_with_nan)
assert numpy.shape(arr_of_float32_with_nan) == numpy.shape(msg.float32_values) and (
numpy.asarray(arr_of_float32_with_nan[~arr_with_nan] ==
msg.float32_values[~arr_with_nan]).all())
arr_of_float64_with_nan = numpy.array([-1.66, math.nan, 1.66], dtype=numpy.float64)
setattr(msg, 'float64_values', arr_of_float64_with_nan)
assert numpy.array_equal(arr_of_float64_with_nan, msg.float64_values, equal_nan=True)

arr_with_nan = numpy.isnan(arr_of_float64_with_nan)
assert numpy.shape(arr_of_float64_with_nan) == numpy.shape(msg.float64_values) and (
numpy.asarray(arr_of_float64_with_nan[~arr_with_nan] ==
msg.float64_values[~arr_with_nan]).all())
# Inf
arr_of_float32_with_inf = numpy.array([-math.inf, 5.5, math.inf], dtype=numpy.float32)
setattr(msg, 'float32_values', arr_of_float32_with_inf)
Expand Down

0 comments on commit 0172e75

Please sign in to comment.