ruby-numo / numo-narray

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

Unexpected result for map #181

Closed ankane closed 2 years ago

ankane commented 3 years ago

Hi, it looks like map tries to return the same Numo type.

a = Numo::Int64.cast([1, 2, 3])
a.map { |v| v + 0.5 }  # returns Numo::Int64 with [1, 2, 3]
a.map { |v| "#{v}!!" } # errors with TypeError (no implicit conversion of String into Integer)

It would be nice if map looked at the result type. This way, it could support any transformation (like Ruby does).