Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

str of Matern32Kernels #146

Open
elloa opened this issue Jul 26, 2021 · 2 comments
Open

str of Matern32Kernels #146

elloa opened this issue Jul 26, 2021 · 2 comments

Comments

@elloa
Copy link

elloa commented Jul 26, 2021

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

@dfm
Copy link
Owner

dfm commented Jul 28, 2021

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!

@elloa
Copy link
Author

elloa commented Jul 29, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants