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) """ 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):