-
Notifications
You must be signed in to change notification settings - Fork 52
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
xarray serialization error when using observed custom distribution #256
Comments
I have seen this before, and I don't totally understand why this happens. In the short term, I'd recommend using the trace.to_netcdf(
filename=...,
groups=["posterior", "log_likelihood", "sample_stats"],
) Here's a simpler snippet that fails with the same issue: import pymc3 as pm
import exoplanet as xo
with pm.Model() as model:
ecc = pm.Uniform("ecc")
xo.eccentricity.kipping13("ecc_prior", fixed=True, observed=ecc)
trace = pm.sample(return_inferencedata=True)
trace.to_netcdf("test") This could be used to debug and find a longer term solution. |
@dfm Thank you very much for the quick reply, the boiled down version and the workaround. I would still be curious to know if trace.observed_data can also be saved / how the custom exoplanet distributions would need to be changed. |
The issue is somehow related to the fact that ecc = xo.eccentricity.kipping13("ecc_prior", fixed=True) Perhaps there's some other PyMC3 trickery that we could use, but I don't know what it would look like! |
I see. I played around some more and found that the problem of xarray serialization is not limited to the custom distributions of exoplanet but also occurs for celerite2.theano.GaussianProcess objects under certain circumstance:
raises the error
However, there is no error if |
Yes. This is exactly the same issue. The "observed data" isn't a constant if it depends on the model! |
You are right of course, I just wanted to point out that the problem is not limited to the custom distribution of exoplanet. |
Haha good point. The celerite2 design (mistakes?) are the same and also my own :D |
Somewhat off-topic: On-topic: |
Thanks! If you're interested in a Julia version, there has been some work on implementing at least some parts over in: https://github.com/JuliaAstro/Transits.jl |
Thanks for pointing out these projects, I will have a look at them! |
|
Describe the bug
Unable to save traces to file, which is essential for running code on a cluster.
To Reproduce
Follow the case study Fitting TESS data (https://gallery.exoplanet.codes/tutorials/tess/) --
except using
lc = lc_file.remove_nans().remove_outliers().normalize()
instead oflc = lc_file.remove_nans().normalize().remove_outliers()
, as the first order of transformations raised an unrelated error in my case.After sampling, try to save the trace as one commonly saves arviz.InferenceData objects:
trace.to_netcdf('results')
.This will raise the following error
Expected behavior
I expect the trace to be saved, as usual. I can individually save
However, the same error is caused when trying to save
trace.observed_data.to_netcdf('observed_data')
My setup
Has anyone encountered this problem before, knows how to solve it, or has a suggestion for a workaround?
Thank you very much in advance.
The text was updated successfully, but these errors were encountered: