george icon indicating copy to clipboard operation
george copied to clipboard

str of Matern32Kernels

Open elloa opened this issue 4 years ago • 2 comments

To string version of Matern32Kernels must be improved in order to allow copy and paste

On code: kernels.Matern32Kernel(metric=18.9, ndim=3) + kernels.Matern32Kernel(metric=1.2, ndim=3)

When printing kernel name:

Matern32Kernel(metric=**Metric**(1.6, ndim=3, axes=array([0, 1, 2]), bounds=[(None, None)]), block=None) + Matern32Kernel(metric=**Metric**(1.2, ndim=3, axes=array([0, 1, 2]), bounds=[(None, None)]), block=None)

Bold emphasis on wrong printing

MWE

from george import kernels
k = kernels.Matern32Kernel(metric=18.9, ndim=3) + kernels.Matern32Kernel(metric=1.2, ndim=3)
print(str(k))

ERROR:

from george import kernels
k1 = kernels.Matern32Kernel(metric=Metric(1.6, ndim=3, axes=array([0, 1, 2]), bounds=[(None, None)]), block=None)

NameError: name 'Metric' is not defined

elloa avatar Jul 26 '21 20:07 elloa

While it's true that there is an issue here, this report is not it. Yes, you need to import Metric if you want to copy and paste the __repr__, just numpy arrays and everything else!

The real issue is somewhere deep in the modeling protocol:

from george import kernels
k = kernels.Matern32Kernel(metric=18.9, ndim=3)
print(str(k))
# prints: 
#   >>> Matern32Kernel(metric=Metric(18.9, ndim=3, axes=array([0, 1, 2]), bounds=[(None, None)]), block=None)

Then:

from george.kernels import Matern32Kernel
from george.metrics import Metric
from numpy import array
Matern32Kernel(metric=Metric(18.9, ndim=3, axes=array([0, 1, 2]), bounds=[(None, None)]), block=None)

which should work, but fails with the error:

AttributeError: 'Metric' object has no attribute 'log_M_0_0'

It's not high on my priority list to fix this, but I'm happy to keep it open in case someone else wants to take a look!

dfm avatar Jul 28 '21 23:07 dfm

@dfm Thanks for properly addressing the error report. Newbie here.

elloa avatar Jul 29 '21 13:07 elloa