From 73a74e9e9515ad76d652e998fc1e88074e8cd820 Mon Sep 17 00:00:00 2001 From: Allan Haldane Date: Thu, 29 Jan 2015 12:54:25 -0500 Subject: BUG: recarray __repr__ gives inaccurate representation In https://github.com/numpy/numpy/pull/5483, I solved the problem that a "recarray" and a "record array" (nomenclature defined in https://github.com/numpy/numpy/pull/5482) looked identical by making sure that a type's subclass was listed in the repr. However, recarrays are still represented using the function 'rec.array' even though this function technically creates record arrays, not recarrays. So I have updated recarray.__repr__. Setup: >>> a = np.array([(1,'ABC'), (2, "DEF")], dtype=[('foo', int), ('bar', 'S4')]) >>> recordarr = np.rec.array(a) >>> recarr = a.view(np.recarray) Behavior after https://github.com/numpy/numpy/pull/5483: >>> recordarr rec.array([(1, 'ABC'), (2, 'DEF')], dtype=(numpy.record, [('foo', '>> recarr rec.array([(1, 'ABC'), (2, 'DEF')], dtype=[('foo', '>> recordarr rec.array([(1, 'ABC'), (2, 'DEF')], dtype=[('foo', '>> recarr array([(1, 'ABC'), (2, 'DEF')], dtype=[('foo', '>> arr_records = arr.view(dtype(np.record, arr.dtype)) + >>> arr_records = arr.view(dtype((np.record, arr.dtype))) In documentation, the term 'structured array' will refer to objects of type np.ndarray with structured dtype, 'record array' will refer to structured -- cgit v1.2.1