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

Columnar vectors / NumPy difference #528

Open
wolfv opened this issue Nov 8, 2017 · 1 comment
Open

Columnar vectors / NumPy difference #528

wolfv opened this issue Nov 8, 2017 · 1 comment

Comments

@wolfv
Copy link
Member

wolfv commented Nov 8, 2017

This:

>>> b
array([[ 1.],
       [ 1.],
       [ 1.]])
>>> b[0] = 10
>>> b
array([[ 10.],
       [  1.],
       [  1.]])
>>> b[2] = 100
>>> b
array([[  10.],
       [   1.],
       [ 100.]])

works in numpy, but not in xtensor (because the stride of the first dimension is 0). We should either fix this, or document it somewhere.

@SylvainCorlay SylvainCorlay added Bug and removed Bug labels Nov 8, 2017
@JohanMabille
Copy link
Member

I think this is the intended behavior, b[i] is equivalent to b(i), and the behavior when there are less arguments than the number of dimension is to prepend them with 0.
This is required so that (a+b)(i0, ...., iN) = a(i0, ...., iN) + b(i0, ...., iN) is always true, whatever the shapes of a and b are.

But I agree that we should document it. Maybe something symmetric to the cheatsheet, with the differences between numpy and xtensor.

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

No branches or pull requests

3 participants