tBuLi / symfit

Symbolic Fitting; fitting as it should be.
http://symfit.readthedocs.org
MIT License
236 stars 19 forks source link

Add Ipython/jupyter latex printing #332

Closed Jhsmit closed 3 years ago

Jhsmit commented 3 years ago

This PR implemements _repr_latex_ on symfit models, enabling latex rendering of models in Jupyter notebooks.

Old behavior:

image

New behavior:

y = Variable('y')
x = Variable('x')
a = Parameter('a_1')
b = Parameter('b')
y2 = Variable('y2')
mu = Parameter('mu_2')
sig = Parameter('sigma')

g = Gaussian(x, mu, sig)

model = Model({
    y: a*x+b,
    y2: g
})

image

t = Variable('t')
k = Variable('k')
a = Parameter('A')
b = Parameter('B')

model_dict = {
    D(a, t): - k * a**2,
    D(b, t): k * a**2,
}

model = Model(model_dict)

image