From dd6b6427efa77d01e4e5ddb24e4c10f846054850 Mon Sep 17 00:00:00 2001 From: Joel Nothman Date: Mon, 25 Feb 2019 18:34:29 +0100 Subject: [PATCH] TST test was relying on arch-dependent casting of NaN --- sklearn/datasets/tests/test_openml.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sklearn/datasets/tests/test_openml.py b/sklearn/datasets/tests/test_openml.py index 2f58d746f7c6c..84f87297c13b1 100644 --- a/sklearn/datasets/tests/test_openml.py +++ b/sklearn/datasets/tests/test_openml.py @@ -17,6 +17,7 @@ _retry_with_clean_cache) from sklearn.utils.testing import (assert_warns_message, assert_raise_message) +from sklearn.utils import is_scalar_nan from urllib.error import HTTPError from sklearn.datasets.tests.test_common import check_return_X_y from functools import partial @@ -37,8 +38,8 @@ def decode_column(data_bunch, col_idx): # XXX: This would be faster with np.take, although it does not # handle missing values fast (also not with mode='wrap') cat = data_bunch.categories[col_name] - result = [cat[idx] if 0 <= idx < len(cat) else None for idx in - data_bunch.data[:, col_idx].astype(int)] + result = [None if is_scalar_nan(idx) else cat[int(idx)] + for idx in data_bunch.data[:, col_idx]] return np.array(result, dtype='O') else: # non-nominal attribute