Open mmaelicke opened 8 months ago
Hi @mmaelicke,
That's strange...
I get the same Sphinx error locally, it is failing at the "Custom model" example V.plot()
, but if I run the code of the user guide separately it works (and I had the custom_model.png
figure saved locally in savefig/
, so it used to pass).
Looking into it in more details...
Here's the code that fails in Sphinx, does it also run for you or am I missing something environment/setup-wise?
import skgstat as skg
import numpy as np
coords, vals = skg.data.pancake(N=200).get('sample')
V = skg.Variogram(
coords,
vals,
n_lags=25
)
V.maxlag = 500
# Build a custom model by applying the @variogram decorator (here adding a linear term to a spherical model)
from skgstat.models import variogram, spherical
@variogram
def custom_model(h, r1, c1, a):
return spherical(h, r1, c1) + h * a
V.model = custom_model
# We define the bounds for r1, c1 and a
bounds_custom = [(0, 0, 0), (np.max(V.bins), np.max(V.experimental), 2)]
V.fit(bounds=bounds_custom)
V.plot()
Looking at the error again (third argument missing in spherical
, while three are passed), it looks like the @variogram
decorator might be the cause and behaving differently in the ipython
code cell than elsewhere (similarly as @savefig
that is used to record the figures?).
I don't have much experience with ipython
in Sphinx... Do you have any idea how to address this?
I also double-checked and I did add tests for the plotting of custom models, so should in principle always work: https://github.com/mmaelicke/scikit-gstat/blob/main/skgstat/tests/test_variogram.py#L1460
I'll check the code and run the sphinx build in a clean build. Possible, that I also had some images cached...
I will try to free my calendar this week a bit and investigate more into this. A possible fix would be to shift the examples to sphinx_gallery examples, which I implemented way later into the docs (the tutorials are written that way). For the case, that the ipython directive in sphinx was the cause.... We'll see
It seems to be related to this: https://github.com/ipython/ipython/issues/13531 which was fixed in ipython 8.15 or 8.16 and above. But using a clean sphinx install with ipython 8.20, still getting the error...
Hey @rhugonnet,
The docs are not compiling anymore and I finally found the time to have a look at that. To me it seems like the the standard plotting routine has an issue, when calling the
Variogram.fitted_model
throughVariogram.transform
. It is one of theV.plot();
statements indocs/userguide/variogram.rst
. It started failing after we implemented the sum of models. I can't really tell which of the plot statements causes the error, but we added to that file, so I suspect it is one of the newly added plotting of sum of models. Here is the traceback of building the docs locally:@rhugonnet I am a bit lost here. Do you have any idea, what exactly is going wrong here?