#/usr/bin/python

""" Baseline example that needs to be beaten """

import numpy as np
import matplotlib.pyplot as plt

x, y, yerr = np.loadtxt("data/data.txt", unpack=True)

A = np.vstack((np.ones_like(x), x)).T
C = np.diag(yerr * yerr)
cov = np.linalg.inv(np.dot(A.T, np.linalg.solve(C, A)))
b_ls, m_ls = np.dot(cov, np.dot(A.T, np.linalg.solve(C, y)))

fig, ax = plt.subplots()
ax.errorbar(x, y, yerr=yerr, c="k", fmt="o")
x_range = np.array([min(x), max(x)])
ax.plot(x_range, m_ls * x_range + b_ls, c="#666666", lw=2, zorder=-100)
ax.set_xlabel("x")
ax.set_ylabel("y")
fig.savefig("assets/result.png")

print m_ls, b_ls

@@ -61,16 +61,26 @@
 en %22%22%22%0A%0A
+import os%0A
 import n
@@ -619,16 +619,294 @@
 rint
- m_ls, b_ls
+(%22Results of m, b: (%7B0:.4f%7D %7B1:.4f%7D)%22.format(m_ls, b_ls))%0A%0A# Let's store result parameters in environment variables, and we will deal%0A# with more complex values (e.g., uncertainties, etc) later%0Aos.environ%5B%22RESULT_M%22%5D = %22%7B0:.5f%7D%22.format(m_ls)%0Aos.environ%5B%22RESULT_B%22%5D = %22%7B0:.5f%7D%22.format(b_ls)
 %0A

Add RESULT_M and RESULT_B to environment varaible [ci skip]