Re: [Numpy-discussion] [Numpy-svn] aada93: ENH: Add 'subok' parameter to PyArray_NewLikeArray...
On Tue, Mar 15, 2011 at 7:22 PM, nore...@github.com wrote: Branch: refs/heads/master Home: https://github.com/numpy/numpy Commit: aada93306acfb4e2eb816faf32652edf8825cf45 https://github.com/numpy/numpy/commit/aada93306acfb4e2eb816faf32652edf8825cf45 Author: Mark Wiebe mwwi...@gmail.com Date: 2011-03-15 (Tue, 15 Mar 2011) Changed paths: M doc/source/reference/c-api.array.rst M numpy/add_newdocs.py M numpy/core/numeric.py M numpy/core/src/multiarray/convert.c M numpy/core/src/multiarray/ctors.c M numpy/core/src/multiarray/multiarraymodule.c M numpy/core/src/umath/ufunc_object.c M numpy/core/tests/test_numeric.py Log Message: --- ENH: Add 'subok' parameter to PyArray_NewLikeArray, np.empty_like, np.zeros_like, and np.ones_like This way, the sub-type can be avoided if necessary. This helps mitigate, but doesn't fix, ticket #1753, by allowing b = np.empty_like(a, subok=False). I'm really not in a position to comment on the depths of the numpy API, but my understanding of np.any_like( ... ) was that it would create always normal ndarrays just taking shape and dtype from the given array. So what should the interpretation of subok be ? Can you elaborate ... ? Thanks, Sebastian Haase ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] [Numpy-svn] aada93: ENH: Add 'subok' parameter to PyArray_NewLikeArray...
On Tue, Mar 15, 2011 at 3:25 PM, Sebastian Haase seb.ha...@gmail.com wrote: On Tue, Mar 15, 2011 at 7:22 PM, nore...@github.com wrote: Branch: refs/heads/master Home: https://github.com/numpy/numpy Commit: aada93306acfb4e2eb816faf32652edf8825cf45 https://github.com/numpy/numpy/commit/aada93306acfb4e2eb816faf32652edf8825cf45 Author: Mark Wiebe mwwi...@gmail.com Date: 2011-03-15 (Tue, 15 Mar 2011) Changed paths: M doc/source/reference/c-api.array.rst M numpy/add_newdocs.py M numpy/core/numeric.py M numpy/core/src/multiarray/convert.c M numpy/core/src/multiarray/ctors.c M numpy/core/src/multiarray/multiarraymodule.c M numpy/core/src/umath/ufunc_object.c M numpy/core/tests/test_numeric.py Log Message: --- ENH: Add 'subok' parameter to PyArray_NewLikeArray, np.empty_like, np.zeros_like, and np.ones_like This way, the sub-type can be avoided if necessary. This helps mitigate, but doesn't fix, ticket #1753, by allowing b = np.empty_like(a, subok=False). I'm really not in a position to comment on the depths of the numpy API, but my understanding of np.any_like( ... ) was that it would create always normal ndarrays just taking shape and dtype from the given array. So what should the interpretation of subok be ? Can you elaborate ... ? Thanks, Sebastian Haase ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion I know that things like numpy.ma and pandas are directly impacted by this change-- in NumPy 1.6 many API functions cannot be used on subclasses because they discard any additional information you wish to be passed on (like the mask in a masked array, for example). ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] [Numpy-svn] aada93: ENH: Add 'subok' parameter to PyArray_NewLikeArray...
On Tue, Mar 15, 2011 at 12:25 PM, Sebastian Haase seb.ha...@gmail.comwrote: snip Log Message: --- ENH: Add 'subok' parameter to PyArray_NewLikeArray, np.empty_like, np.zeros_like, and np.ones_like This way, the sub-type can be avoided if necessary. This helps mitigate, but doesn't fix, ticket #1753, by allowing b = np.empty_like(a, subok=False). I'm really not in a position to comment on the depths of the numpy API, but my understanding of np.any_like( ... ) was that it would create always normal ndarrays just taking shape and dtype from the given array. So what should the interpretation of subok be ? Can you elaborate ... ? You're understanding is half-right. There was previously an inconsistency, where zeros_like and empty_like did what you expect, while ones_like kept the subtype, see this ticket: http://projects.scipy.org/numpy/ticket/929. Because ones_like is a ufunc, switching it to behave like the others did is much harder than going the other way, and intuitively I would expect *_like to produce a matrix when given a matrix, so I fixed it to preserve the subtype. This patch extends the functions to allow for a choice between the previous two behaviors. The parameter subok is exactly like subok in the array constructor, the name was chosen for consistency. -Mark ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion