[Proposal] Change behavior of [] when ndim > 1
ankane opened this issue ยท 4 comments
ankane commented
Hi, thanks for this great project!
I wanted to get your thoughts on changing the behavior of []
to match both Ruby arrays and Numpy when ndim
> 1. Currently, Numo returns a single value with []
regardless of the number of dimensions. It's easier to demonstrate on a 2d array.
require "numo/narray"
a = Numo::NArray.asarray([[1, 2, 3], [4, 5, 6]])
p a[0] # 1
With Ruby arrays, you get an array back (the entire row).
b = [[1, 2, 3], [4, 5, 6]]
p b[0] # [1, 2, 3]
Same with NumPy.
import numpy as np
x = np.array([[1, 2, 3], [4, 5, 6]])
print(x[0]) # [1 2 3]
I personally find the Ruby array/NumPy behavior much more intuitive. Let me know your thoughts. This change would not be backwards compatible.
kojix2 commented
Hi, ankane !
According to Twitter, Tanaka-san is busy moving from Ibaraki Prefecture to Kanagawa Prefecture these days. ๐ ๐ ๐
I think he will reply when things settle down...
ankane commented
orlando-labs commented
ankane commented
Cleaning up stale issues