Question regarding documentation of structured arrays
Hi, I found the following inconsistency between the advertised and the actual behviour of structured arrays: on http://docs.scipy.org/doc/numpy/user/basics.rec.html it says in the section "Accessing multiple fields at once" Notice that the fields are always returned in the same order regardless of the sequence they are asked for. Fortunately that does not seem to be the case in my simple test (see below). Is that a change in behaviour I can rely on or am I somehow lucky in this particular example? Thanks, Hanno In [596]: test_array = np.ones((10),dtype=[('a', float), ('b',float)]) In [597]: test_array Out[597]: array([(1.0, 1.0), (1.0, 1.0), (1.0, 1.0), (1.0, 1.0), (1.0, 1.0), (1.0, 1.0), (1.0, 1.0), (1.0, 1.0), (1.0, 1.0), (1.0, 1.0)], dtype=[('a', '<f8'), ('b', '<f8')]) In [598]: test_array['b']*=2 In [599]: test_array Out[599]: array([(1.0, 2.0), (1.0, 2.0), (1.0, 2.0), (1.0, 2.0), (1.0, 2.0), (1.0, 2.0), (1.0, 2.0), (1.0, 2.0), (1.0, 2.0), (1.0, 2.0)], dtype=[('a', '<f8'), ('b', '<f8')]) In [600]: test_array[['b','a']] Out[600]: array([(2.0, 1.0), (2.0, 1.0), (2.0, 1.0), (2.0, 1.0), (2.0, 1.0), (2.0, 1.0), (2.0, 1.0), (2.0, 1.0), (2.0, 1.0), (2.0, 1.0)], dtype=[('b', '<f8'), ('a', '<f8')]) In [601]: test_array[['a','b']] Out[601]: array([(1.0, 2.0), (1.0, 2.0), (1.0, 2.0), (1.0, 2.0), (1.0, 2.0), (1.0, 2.0), (1.0, 2.0), (1.0, 2.0), (1.0, 2.0), (1.0, 2.0)], dtype=[('a', '<f8'), ('b', '<f8')]) In [602]: test_ab = test_array[['a','b']] In [603]: test_ba = test_array[['b','a']] In [604]: test_ba Out[604]: array([(2.0, 1.0), (2.0, 1.0), (2.0, 1.0), (2.0, 1.0), (2.0, 1.0), (2.0, 1.0), (2.0, 1.0), (2.0, 1.0), (2.0, 1.0), (2.0, 1.0)], dtype=[('b', '<f8'), ('a', '<f8')]) In [605]: np.__version__ Out[605]: '1.6.1' -- Hanno Klemm klemm@phys.ethz.ch
Hi Hanno On Wed, Jul 24, 2013 at 11:46 AM, Hanno Klemm <klemm@phys.ethz.ch> wrote:
I found the following inconsistency between the advertised and the actual behviour of structured arrays:
on http://docs.scipy.org/doc/numpy/user/basics.rec.html it says in the section
"Accessing multiple fields at once" Notice that the fields are always returned in the same order regardless of the sequence they are asked for.
I can confirm the behavior you see under the latest development version. Would you mind filing a pull request against the docs? Stéfan
Hi Stefan, I would be happy to file a pull request against the docs if you (or somebody) could point me to a document on how and where to do that. Hanno On 24.07.2013 12:31, Stéfan van der Walt wrote:
Hi Hanno
On Wed, Jul 24, 2013 at 11:46 AM, Hanno Klemm <klemm@phys.ethz.ch> wrote:
I found the following inconsistency between the advertised and the actual behviour of structured arrays:
on http://docs.scipy.org/doc/numpy/user/basics.rec.html it says in the section
"Accessing multiple fields at once" Notice that the fields are always returned in the same order regardless of the sequence they are asked for.
I can confirm the behavior you see under the latest development version. Would you mind filing a pull request against the docs?
Stéfan _______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
-- Hanno Klemm klemm@phys.ethz.ch
Hallo Hanno On Wed, Jul 24, 2013 at 1:29 PM, Hanno Klemm <klemm@phys.ethz.ch> wrote:
I would be happy to file a pull request against the docs if you (or somebody) could point me to a document on how and where to do that.
The file you want to edit is here: https://github.com/numpy/numpy/blob/master/numpy/doc/structured_arrays.py#L1... You can click on the "edit" button, then GitHub will help you to make a pull request. Thanks! Stéfan
participants (2)
-
Hanno Klemm -
Stéfan van der Walt