shogun icon indicating copy to clipboard operation
shogun copied to clipboard

auto dispatch create methods in python

Open karlnapf opened this issue 4 years ago • 1 comments

We have get for python, which automatically returns the correct type, i.e. get('my_vector') and get('my_int') return a numpy array and an int respectively.

Now, why don't we do the same thing for creating shogun objects via factories? (In Python)

create_kernel('GaussianKernel') -> create('GaussianKernel')

That should be possible using exactly the same mechanics as in get, or do I get this wrong? @gf712 Maybe you can provide pointers for a student to do this

karlnapf avatar Apr 06 '20 17:04 karlnapf

Hmmm, this would be more complicated, because we call get with a visitor pattern, so we have Any to visit on. What you need is a way to dispatch with sgobject to the “base” class. Will have to think about it! Otherwise there is the naive with a try except for loop in Python..

gf712 avatar Apr 06 '20 21:04 gf712