Skip to content

setitem with a value without axes names does not work #272

Open
@gdementen

Description

@gdementen
>>> dest = ndtest(3)
>>> dest
a  a0  a1  a2
    0   1   2
>>> dest[:'a1'] = ndrange(2)
ValueError: could not broadcast input array from shape (2,1) into shape (2)
>>> # ironically this works
>>> dest[:'a1'] = ndrange(2).data

>>> # this fails but I am unsure it should work.
>>> # We should match axis 0 with axis 0, etc. so that I think it should work, even though that is different from numpy.
>>> dest = ndtest((4, 3))
>>> dest[['a0', 'a1']] = ndrange(2)
ValueError: could not broadcast input array from shape (2,1,1) into shape (2,3)
>>> dest[:'a1'] = ndrange(2)
ValueError: could not broadcast input array from shape (2,1,1) into shape (2,3)

>>> dest[['a0', 'a1']] = ndrange(2).data
ValueError: could not broadcast input array from shape (2) into shape (2,3)
>>> dest[:'a1'] = ndrange(2).data
ValueError: could not broadcast input array from shape (2) into shape (2,3)

>>> # this works only without advanced indexing, making things even more confusing
>>> dest = ndtest((4, 2, 2))
>>> dest
 a  b\c  c0  c1
a0   b0   0   1
a0   b1   2   3
a1   b0   4   5
a1   b1   6   7
a2   b0   8   9
a2   b1  10  11
a3   b0  12  13
a3   b1  14  15
>>> v = zeros((3, 2))
>>> v
{0}*\{1}*    0    1
        0  0.0  0.0
        1  0.0  0.0
        2  0.0  0.0

# works
>>> dest['a0:a2', 'b1'] = v.data
# fails
>>> dest['a0:a2', 'b1'] = v
ValueError: could not broadcast input array from shape (3,2,1,1) into shape (3,2)
# fails
>>> dest['a0,a2,a1', 'b1'] = v.data
ValueError: shape mismatch: value array of shape (3,2) could not be broadcast to indexing result of shape (3,1,2)
# fails
>>> dest['a0,a2,a1', 'b1'] = v

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions