Hi, On Mon, Nov 13, 2023 at 7:41 AM Aaron Meurer <asmeu...@gmail.com> wrote: > > High level abstractions like .flat or boolean indexing / np.nonzero() > always use C ordering regardless of the underlying data. > > >>> list(np.asarray([[0, 1], [2, 3]]).flat) > [0, 1, 2, 3] > >>> list(np.asarray([[0, 1], [2, 3]], order='F').flat) > [0, 1, 2, 3]
Just in case it caused others to pause as it did me, here's the Boolean indexing demonstration: >>> c_arr = np.asarray([[0, 1], [2, 3]]) >>> f_arr = np.asarray([[0, 1], [2, 3]], order='F') >>> bool_arr = np.array([[False, True], [True, False]]) >>> c_arr[bool_arr] array([1, 2]) >>> f_arr[bool_arr] array([1, 2]) >>> c_arr[np.array(bool_arr, order='F')]. # Indexing array order is irrelevant array([1, 2]) >>> np.nonzero(c_arr < 3) (array([0, 0, 1]), array([0, 1, 0])) >>> np.nonzero(f_arr < 3) (array([0, 0, 1]), array([0, 1, 0])) Cheers, Matthew _______________________________________________ NumPy-Discussion mailing list -- numpy-discussion@python.org To unsubscribe send an email to numpy-discussion-le...@python.org https://mail.python.org/mailman3/lists/numpy-discussion.python.org/ Member address: arch...@mail-archive.com