From 6f67db728db390984cb2c447f2f3cc7b042afd87 Mon Sep 17 00:00:00 2001 From: robert Date: Fri, 7 Jun 2019 10:46:39 +0200 Subject: [PATCH 1/2] distmatrix: return numpy datatypes --- Orange/misc/distmatrix.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Orange/misc/distmatrix.py b/Orange/misc/distmatrix.py index e995e68fb40..4ded417378e 100644 --- a/Orange/misc/distmatrix.py +++ b/Orange/misc/distmatrix.py @@ -51,7 +51,7 @@ def __array_finalize__(self, obj): def __array_wrap__(self, out_arr, context=None): if out_arr.ndim == 0: # a single scalar - return out_arr.item() + return out_arr[()] return np.ndarray.__array_wrap__(self, out_arr, context) """ From 1fd6a65660ff5878a5ea1ab15c28a855cfb325d0 Mon Sep 17 00:00:00 2001 From: robert Date: Fri, 7 Jun 2019 10:49:35 +0200 Subject: [PATCH 2/2] tests: distmatrix returns numpy datatypes --- Orange/tests/test_distances.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Orange/tests/test_distances.py b/Orange/tests/test_distances.py index 65b07f8c40b..907b84a1950 100644 --- a/Orange/tests/test_distances.py +++ b/Orange/tests/test_distances.py @@ -186,6 +186,17 @@ def test_save(self): ["danny", "eve", "frank"]) self.assertEqual(m.axis, 0) + def test_numpy_type(self): + """GH-3658""" + data1 = np.array([1, 2], dtype=np.int64) + data2 = np.array([2, 3], dtype=np.int64) + dm1, dm2 = DistMatrix(data1), DistMatrix(data2) + + self.assertIsInstance(dm1.max(), np.int64) + self.assertNotIsInstance(dm1.max(), int) + with self.assertRaises(AssertionError): + np.testing.assert_array_equal(dm1, dm2) + # noinspection PyTypeChecker class TestEuclidean(TestCase):