ruby-numo/numo-narray

Can't reshape to ndim 0

ankane opened this issue · 2 comments

Trying to reshape to a 0-dimensional array raises ArgumentError: No argrument (with a small typo)

require "numo/narray"

x = Numo::NArray.cast([1])
p x.ndim
x2 = x.reshape # fails
p x2.ndim

numo-narray does not support creating 0-dimensional array. Why do you think you require 0-dimensional array?

It's possible to create a 0-dimensional array, so I thought Numo supported it.

x = Numo::NArray.cast(1)
x.ndim  # 0
x.shape # []

I ran into this while writing tests for Npy, which loads NumPy files.