Skip to content

SetItem for multiple Ids not working #514

Closed

Description

@MaxOmlor
[Test]
    public void MultiIdSetItem()
    {
        var a = np.arange(5);
        Debug.Log($"a = {a}");
        var ids = np.array(new int[] { 1, 3 });
        Debug.Log($"ids = {ids}");
        var newValues = np.array(new int[] { 10, 20 });
        Debug.Log($"newValues = {newValues}");

        a[ids] = newValues;
        Debug.Log($"after set item: a = {a}");
        
        var expected = np.array(new[] { 0, 10, 2, 20, 4 });
        Assert.AreEqual(expected, a);
    }

Output:

Expected and actual are both <NumSharp.NDArray>
  Values differ at index [1]
  Expected: 10
  But was:  1
---
a = [0, 1, 2, 3, 4]
ids = [1, 3]
newValues = [10, 20]
after set item: a = [0, 1, 2, 3, 4]

Activity

  1. Nucs commented on Apr 12, 2026

    @Nucs
    Member

    SetItem for multiple indices now works correctly:

    var arr = np.zeros(5);
    var indices = np.array(new[] { 0, 2, 4 });
    arr[indices] = 99;  // [99, 0, 99, 0, 99]

    Resolved via #600, #602, #603, #596.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions