Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2df7b8c

Browse files
committed
Merge pull request numpy#3868 from charris/forwardport-1.9-3859
Forwardport 1.9 3859
2 parents 0cfa4ed + 488930a commit 2df7b8c

File tree

2 files changed

+36
-35
lines changed

2 files changed

+36
-35
lines changed

doc/release/1.8.0-notes.rst

Lines changed: 35 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@ NumPy 1.8.0 Release Notes
33

44
This release supports Python 2.6 -2.7 and 3.2 - 3.3.
55

6-
76
Highlights
87
==========
98

10-
Python 2 and Python 3 are supported by the same code base. The
11-
2to3 fixer is no longer run.
12-
13-
9+
* Python 2 and Python 3 are supported by the same code base. The
10+
2to3 fixer is no longer run.
11+
* ``full`` and ``full_like`` to create value initialized arrays.
12+
* ``partition`` partial sorting via selection.
13+
* inplace fancy indexing for ufuncs with the ``.at`` method.
14+
* Numerous performance improvements in many areas.
1415

1516
Dropped Support
1617
===============
@@ -178,7 +179,8 @@ Advanced indexing using `np.newaxis`
178179

179180
It is now possible to use `np.newaxis`/`None` together with index
180181
arrays instead of only in simple indices. This means that
181-
``array[np.newaxis, [0, 1]]`` will now work as expected.
182+
``array[np.newaxis, [0, 1]]`` will now work as expected and select the first
183+
two rows while prepending a new axis to the array.
182184

183185
New functions `full` and `full_like`
184186
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -191,11 +193,17 @@ New functions `partition` and `argpartition`
191193

192194
New functions to partially sort arrays via a selection algorithm.
193195

194-
Partial sorting moves the value of selected elements into their position if the
195-
array would be sorted. In the resulting array all elements smaller than the
196-
sorted elements will placed before the it and all equal or greater behind it.
197-
This has a linear time complexity of ``O(n)`` compared to ``O(n log(n))`` of a
198-
full sort.
196+
A ``partition`` by index ``k`` moves the ``k`` smallest element to the front of
197+
an array. All elements before ``k`` are then smaller or equal than the value
198+
in position ``k`` and all elements following ``k`` are then greater or equal
199+
than the value in position ``k``. The ordering of the values within these
200+
bounds is undefined.
201+
A sequence of indices can be provided to sort all of them into their sorted
202+
position at once iterative partitioning.
203+
This can be used to efficiently obtain order statistics like median or
204+
percentiles of samples.
205+
``partition`` has a linear time complexity of ``O(n)`` while a full sort has
206+
``O(n log(n))``.
199207

200208
New functions `nanmean`, `nanvar` and `nanstd`
201209
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -285,6 +293,22 @@ reduces its time complexity from O(n log(n)) to O(n).
285293
If used with the `overwrite_input` option the array will now only be partially
286294
sorted instead of fully sorted.
287295

296+
297+
Overrideable operand flags in ufunc C-API
298+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
299+
When creating a ufunc, the default ufunc operand flags can be overridden
300+
via the new op_flags attribute of the ufunc object. For example, to set
301+
the operand flag for the first input to read/write:
302+
303+
PyObject \*ufunc = PyUFunc_FromFuncAndData(...);
304+
ufunc->op_flags[0] = NPY_ITER_READWRITE;
305+
306+
This allows a ufunc to perform an operation in place. Also, global nditer flags
307+
can be overridden via the new iter_flags attribute of the ufunc object.
308+
For example, to set the reduce flag for a ufunc:
309+
310+
ufunc->iter_flags = NPY_ITER_REDUCE_OK;
311+
288312
Changes
289313
=======
290314

@@ -327,8 +351,6 @@ One new function has been added to the ufunc C-API that allows to register
327351
an inner loop for user types using the descr.
328352
* PyUFunc_RegisterLoopForDescr
329353

330-
331-
332354
Deprecations
333355
============
334356

@@ -342,24 +364,3 @@ deprecated. Previously float indices and function arguments such as axes or
342364
shapes were truncated to integers without warning. For example
343365
`arr.reshape(3., -1)` or `arr[0.]` will trigger a deprecation warning in
344366
NumPy 1.8., and in some future version of NumPy they will raise an error.
345-
346-
C-API
347-
~~~~~
348-
349-
None
350-
351-
New Features
352-
============
353-
354-
When creating a ufunc, the default ufunc operand flags can be overridden
355-
via the new op_flags attribute of the ufunc object. For example, to set
356-
the operand flag for the first input to read/write:
357-
358-
PyObject \*ufunc = PyUFunc_FromFuncAndData(...);
359-
ufunc->op_flags[0] = NPY_ITER_READWRITE;
360-
361-
This allows a ufunc to perform an operation in place. Also, global nditer flags
362-
can be overridden via the new iter_flags attribute of the ufunc object.
363-
For example, to set the reduce flag for a ufunc:
364-
365-
ufunc->iter_flags = NPY_ITER_REDUCE_OK;

doc/source/reference/c-api.iterator.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ is used to control the memory layout of the allocated result, typically
204204
* Make a copy of the iternext function pointer and
205205
* a few other variables the inner loop needs.
206206
*/
207-
iternext = NpyIter_GetIterNext(iter);
207+
iternext = NpyIter_GetIterNext(iter, NULL);
208208
innerstride = NpyIter_GetInnerStrideArray(iter)[0];
209209
itemsize = NpyIter_GetDescrArray(iter)[0]->elsize;
210210
/*

0 commit comments

Comments
 (0)