ruby-numo / numo-narray

Ruby/Numo::NArray - New NArray class library
http://ruby-numo.github.io/narray/
BSD 3-Clause "New" or "Revised" License
415 stars 41 forks source link

Can't reshape to ndim 0 #166

Closed ankane closed 2 years ago

ankane commented 4 years ago

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
masa16 commented 4 years ago

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

ankane commented 4 years ago

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.