ruby-numo / numo-narray

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

The name of a method corresponding to numpy.maximum #61

Open masa16 opened 7 years ago

masa16 commented 7 years ago

Numpy has confusing two functions: numpy.max and numpy.maximum. Numo::NArray#max() method is same as numpy.max. Now I need to define the specification of a method corresponding to numpy.maximum. Current ideas:

Numo::NArray.max(a,b,...)
Numo::Nanika.max(a,b,...) # Nanika is a module with an appropriate name.
Numo.max(a,b,...)
a.max(b)
Try2Code commented 7 years ago

Hi! IMO pointwise max/min operations should be public class methods of the corresponding class (NArray,NMatrix,...).

Numo.max would suggests an operation on objetcs of different Numo-classes

hth

masa16 commented 7 years ago

I consider Numo module is dedicated to Numo::NArray class objects. This is similar to Math module that calculates with Float objects.

Try2Code commented 7 years ago

Ah, I see - I thought Numo would be a module for NArray and NMatrix. Will there be no Numo::NMatrix in the future?

masa16 commented 7 years ago

I cannot afford to maintain so many classes, so do not consider something like Numo::NMatrix.

Try2Code commented 7 years ago

No Problem - NArray is multidimensional out of the box. I was just asking, because some time ago I ran into problems with building gsl-bindings. The gem I used supported NArray or NMatrix based builds, but using NMatrix from sciruby. This clashed (at least IMO) with the NMatrix class from "the old" narray implementation. anyhow ... since you created Numo::GSL, this issue is solved ;-)

Try2Code commented 7 years ago

back to the topic - My favourites are both

Numo.max(a,b,...)
a.max(b)

I guess it's rather easy to let a.max(b) make use of Numo.max(a,b) in order to stay with a single implementation.