Re: [Numpy-discussion] Second try: possible bug in assignment to complex array
Shall I file a bug report? Or is this fairly easy to fix? Mark On Fri, Aug 10, 2012 at 11:41 AM, josef.p...@gmail.com wrote: On Fri, Aug 10, 2012 at 10:00 AM, Travis Oliphant tra...@continuum.io wrote: On Aug 10, 2012, at 5:37 AM, Paul Anton Letnes wrote: On 10. aug. 2012, at 09:54, Mark Bakker wrote: I am giving this a second try. Can anybody help me out? I think there is a problem with assigning a 1D complex array of length one to a position in another complex array. Example: a = ones(1,'D') b = ones(1,'D') a[0] = b --- TypeError Traceback (most recent call last) ipython-input-37-0c4fc6d780e3 in module() 1 a[0] = b TypeError: can't convert complex to float This works correctly when a and b are real arrays: a = ones(1) b = ones(1) a[0] = b Bug or feature? The exact same thing happens on OS X 10.7.4, python 2.7.3, numpy 1.6.1. Looks like a bug to me - or at least very surprising behavior. This is definitely an inconsistency.The error seems more correct (though the error message needs improvement). Can someone try this on NumPy 1.5 and see if this inconsistency existed there as well. np.__version__ '1.5.1' a = np.ones(1,'D') b = np.ones(1,'D') a[0] = b Traceback (most recent call last): File stdin, line 1, in module TypeError: can't convert complex to float a = np.ones(1) b = np.ones(1) a[0] = b and a = np.ones(1,'D') b = 2*np.ones(1) a[0] = b a array([ 2.+0.j]) c = 3*np.ones(1, int) a[0] = c a array([ 3.+0.j]) Josef Thanks, -Travis Paul ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion -- next part -- An HTML attachment was scrubbed... URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20120810/05588327/attachment.html -- ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion End of NumPy-Discussion Digest, Vol 71, Issue 18 ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
[Numpy-discussion] Second try: possible bug in assignment to complex array
I am giving this a second try. Can anybody help me out? I think there is a problem with assigning a 1D complex array of length one to a position in another complex array. Example: a = ones(1,'D') b = ones(1,'D') a[0] = b --- TypeError Traceback (most recent call last) ipython-input-37-0c4fc6d780e3 in module() 1 a[0] = b TypeError: can't convert complex to float This works correctly when a and b are real arrays: a = ones(1) b = ones(1) a[0] = b Bug or feature? Thanks, Mark ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Second try: possible bug in assignment to complex array
Mark Bakker markbak at gmail.com writes: I think there is a problem with assigning a 1D complex array of length one to a position in another complex array. Example: a = ones(1,'D') b = ones(1,'D') a[0] = b --- TypeError Traceback (most recent call last) ipython-input-37-0c4fc6d780e3 in module() 1 a[0] = b TypeError: can't convert complex to float This works correctly when a and b are real arrays: a = ones(1) b = ones(1) a[0] = b Bug or feature? Thanks, Mark I can't help unfortunately, but I can confirm that I also see the problem on Win32 Python 2.7.3, numpy 1.6.2. As a workaround it appears that slicing works: In [15]: sys.version Out[15]: '2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)]' In [16]: sys.version Out[16]: '2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)]' In [17]: np.__version__ Out[17]: '1.6.2' In [18]: a = ones(1,'D') In [19]: b = 2*ones(1,'D') In [20]: a[0] = b --- TypeError Traceback (most recent call last) ipython-input-20-0c4fc6d780e3 in module() 1 a[0] = b TypeError: can't convert complex to float In [21]: a[0:1] = b In [22]: -Dave ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Second try: possible bug in assignment to complex array
Le vendredi 10 août 2012, Dave Hirschfeld a écrit : Mark Bakker markbak at gmail.com writes: I think there is a problem with assigning a 1D complex array of length one to a position in another complex array. Example: a = ones(1,'D') b = ones(1,'D') a[0] = b --- TypeError Traceback (most recent call last) ipython-input-37-0c4fc6d780e3 in module() 1 a[0] = b TypeError: can't convert complex to float I can't help unfortunately, but I can confirm that I also see the problem on Win32 Python 2.7.3, numpy 1.6.2. As a workaround it appears that slicing works: Same on debian (unstable), Python 2.7, numpy 1.6.2 In [5]: a[0] = b TypeError: can't convert complex to float In [6]: a[0] = b[0] Other workarounds : asscalar and squeeze In [7]: a[0] = np.asscalar(b) In [8]: a[0] = b.squeeze() -- Fabrice Silva ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Second try: possible bug in assignment to complex array
On 10. aug. 2012, at 09:54, Mark Bakker wrote: I am giving this a second try. Can anybody help me out? I think there is a problem with assigning a 1D complex array of length one to a position in another complex array. Example: a = ones(1,'D') b = ones(1,'D') a[0] = b --- TypeError Traceback (most recent call last) ipython-input-37-0c4fc6d780e3 in module() 1 a[0] = b TypeError: can't convert complex to float This works correctly when a and b are real arrays: a = ones(1) b = ones(1) a[0] = b Bug or feature? The exact same thing happens on OS X 10.7.4, python 2.7.3, numpy 1.6.1. Looks like a bug to me - or at least very surprising behavior. Paul ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Second try: possible bug in assignment to complex array
On Aug 10, 2012, at 5:37 AM, Paul Anton Letnes wrote: On 10. aug. 2012, at 09:54, Mark Bakker wrote: I am giving this a second try. Can anybody help me out? I think there is a problem with assigning a 1D complex array of length one to a position in another complex array. Example: a = ones(1,'D') b = ones(1,'D') a[0] = b --- TypeError Traceback (most recent call last) ipython-input-37-0c4fc6d780e3 in module() 1 a[0] = b TypeError: can't convert complex to float This works correctly when a and b are real arrays: a = ones(1) b = ones(1) a[0] = b Bug or feature? The exact same thing happens on OS X 10.7.4, python 2.7.3, numpy 1.6.1. Looks like a bug to me - or at least very surprising behavior. This is definitely an inconsistency.The error seems more correct (though the error message needs improvement). Can someone try this on NumPy 1.5 and see if this inconsistency existed there as well. Thanks, -Travis Paul ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Second try: possible bug in assignment to complex array
On Fri, Aug 10, 2012 at 10:00 AM, Travis Oliphant tra...@continuum.iowrote: On Aug 10, 2012, at 5:37 AM, Paul Anton Letnes wrote: On 10. aug. 2012, at 09:54, Mark Bakker wrote: I am giving this a second try. Can anybody help me out? I think there is a problem with assigning a 1D complex array of length one to a position in another complex array. Example: a = ones(1,'D') b = ones(1,'D') a[0] = b --- TypeError Traceback (most recent call last) ipython-input-37-0c4fc6d780e3 in module() 1 a[0] = b TypeError: can't convert complex to float This works correctly when a and b are real arrays: a = ones(1) b = ones(1) a[0] = b Bug or feature? The exact same thing happens on OS X 10.7.4, python 2.7.3, numpy 1.6.1. Looks like a bug to me - or at least very surprising behavior. This is definitely an inconsistency.The error seems more correct (though the error message needs improvement). Can someone try this on NumPy 1.5 and see if this inconsistency existed there as well. np.__version__ '1.5.1' a = np.ones(1,'D') b = np.ones(1,'D') a[0] = b Traceback (most recent call last): File stdin, line 1, in module TypeError: can't convert complex to float a = np.ones(1) b = np.ones(1) a[0] = b Josef Thanks, -Travis Paul ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Second try: possible bug in assignment to complex array
On Fri, Aug 10, 2012 at 11:41 AM, josef.p...@gmail.com wrote: On Fri, Aug 10, 2012 at 10:00 AM, Travis Oliphant tra...@continuum.iowrote: On Aug 10, 2012, at 5:37 AM, Paul Anton Letnes wrote: On 10. aug. 2012, at 09:54, Mark Bakker wrote: I am giving this a second try. Can anybody help me out? I think there is a problem with assigning a 1D complex array of length one to a position in another complex array. Example: a = ones(1,'D') b = ones(1,'D') a[0] = b --- TypeError Traceback (most recent call last) ipython-input-37-0c4fc6d780e3 in module() 1 a[0] = b TypeError: can't convert complex to float This works correctly when a and b are real arrays: a = ones(1) b = ones(1) a[0] = b Bug or feature? The exact same thing happens on OS X 10.7.4, python 2.7.3, numpy 1.6.1. Looks like a bug to me - or at least very surprising behavior. This is definitely an inconsistency.The error seems more correct (though the error message needs improvement). Can someone try this on NumPy 1.5 and see if this inconsistency existed there as well. np.__version__ '1.5.1' a = np.ones(1,'D') b = np.ones(1,'D') a[0] = b Traceback (most recent call last): File stdin, line 1, in module TypeError: can't convert complex to float a = np.ones(1) b = np.ones(1) a[0] = b and a = np.ones(1,'D') b = 2*np.ones(1) a[0] = b a array([ 2.+0.j]) c = 3*np.ones(1, int) a[0] = c a array([ 3.+0.j]) Josef Thanks, -Travis Paul ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion