Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SetItem for multiple Ids not working #514

Open
MaxOmlor opened this issue Jun 3, 2024 · 0 comments
Open

SetItem for multiple Ids not working #514

MaxOmlor opened this issue Jun 3, 2024 · 0 comments

Comments

@MaxOmlor
Copy link

MaxOmlor commented Jun 3, 2024

[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]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant