[Numpy-discussion] silently ignored size mismatch (bug??)

Matthew Brett matthew.brett at gmail.com
Mon Oct 1 06:29:21 EDT 2012


Hi,

On Mon, Oct 1, 2012 at 9:04 AM, Pierre Haessig <pierre.haessig at crans.org> wrote:
> Hi,
>
> Le 28/09/2012 21:02, Neal Becker a écrit :
>> In [19]: u = np.arange (10)
>>
>> In [20]: v = np.arange (10)
>>
>> In [21]: u[v] = u
>>
>> In [22]: u[v] = np.arange(11)
>>
>> silence...
> I've same behavior with my numpy 1.6.2.
>
> It indeed looks strange that the end of the data vector is dropped in
> silence.

Same on numpy 1.4.1.  I also would have predicted an error in that
situation.  For example in matlab:

>> a = 1:10

a =

     1     2     3     4     5     6     7     8     9    10

>> b = 1:10

b =

     1     2     3     4     5     6     7     8     9    10

>> a(b) = 11:20

a =

    11    12    13    14    15    16    17    18    19    20

>> a(b) = 11:21
???  In an assignment  A(I) = B, the number of elements in B and
 I must be the same.

Is there any reason not to do that?

Best,

Matthew



More information about the NumPy-Discussion mailing list