Description
The documentation says
Create an Array with one, two or three dimensions.
This is fine.
However, I wonder if the following code should be able to run silently (not even a warning).
use ndarray::array;
fn main() {
let a = array![
[
[[[2, 2]]],
[[[3, 1]]],
[[[5, 3]]],
[[[2, 2]]]
]
];
println!("An int array with shape {:?}: {:?}", a.shape(), a.ndim()); // Shape is [1, 4, 1]
}
Basically, what's happening is that some dimensions or parentheses are automatically ignored. I think this should at least be documented or maybe the macro should fail in those cases? I am happy to contribute to the documentation, if you think that's the way to go in this case. I am also opening this issue because, if we attempt to create a similar thing in numpy with e.g. the following code
import numpy as np
a = np.array(
[
[[[2, 2]]],
[[[3, 1]]],
[[[5, 3]]],
[[[2, 2]]]
]
)
print(a.shape)
We get a different shape: (4, 1, 1, 2)
.
Btw, I suppose there's no macro that allows us to create arrays from literals with more than 3 dimensions. Is that correct? Is there any reason why the macro only supports up to 3 dimensions? In machine learning, for example, it it's not rare to have multi-dimensional arrays with more than 3 dimensions, so I think that supporting the creation of arrays from literals with more than 3 dimensions would not be a bad idea.