Closed kojix2 closed 4 years ago
This is an aside from your proposal, but your example can be written without loop as
idx = narray.eq(0).where
narray[idx] = Float::NAN
mean = narray.mean(axis:0, nan:true)
axis = narray.new_narray.seq % narray.shape[1]
narray[idx] = mean[axis[idx]]
Wow, last two lines look like a magic.
The user who tries to execute anything with map
is me.
Hello.
Enhancement
map_over_axis
positive opinion
I want
map_over_axis
.This method will not very fast because it will be implemented in Ruby, not C.
map
orcollect
is one of the most popular methods among Rubyists. Block is an impressive feature of Ruby.But Narray is a library of matrix and vector operations. So
map
andcollect
may not always be recommended.Ruby accepts a variety of ideas. "apply" and "lambda".
We have
each_over_axis
, So it will bemap_over_axis
.a possible negative opinion
Users of narray should avoid using
map
. If you implement "map_over_axis", the rubyst will tend to try to compute everything with map, which in turn will impede their fast computation. As a scientific computational library, NArray should not introduce another paradigm such as Ruby array behavior. Once you add a bad idea, it's hard to undo. You should be consistent.I use https://miraitranslate.com/trial/