[NumPy-Tickets] [NumPy] #870: np.asarray does not create new array view when different but compatible type code is passed in the dtype argument
NumPy Trac
numpy-tickets@scipy....
Thu Jan 21 10:26:22 CST 2010
#870: np.asarray does not create new array view when different but compatible
type code is passed in the dtype argument
-------------------------+--------------------------------------------------
Reporter: damian.eads | Owner: stefan
Type: defect | Status: accepted
Priority: normal | Milestone:
Component: numpy.core | Version: none
Keywords: |
-------------------------+--------------------------------------------------
Comment(by tihocan):
Replying to [comment:2 tihocan]:
> '''Another workaround'''
> I'm having the same problem and found that using .view instead of giving
a dtype to asarray may do the trick. Example:
>
> {{{
> Y=numpy.asarray(X).view(numpy.intc)
> }}}
Sorry, the code above is not a good idea, you need to give a dtype to
asarray as well in case a conversion is needed. Correct version:
{{{
Y=numpy.asarray(X, dtype=numpy.inc).view(numpy.intc)
}}}
--
Ticket URL: <http://projects.scipy.org/numpy/ticket/870#comment:3>
NumPy <http://projects.scipy.org/numpy>
My example project
More information about the NumPy-Tickets
mailing list