try: from AutoFeedback.plotchecks import check_plot except: import subprocess import sys subprocess.check_call([sys.executable, "-m", "pip", "install", "AutoFeedback"]) from AutoFeedback.plotchecks import check_plot from AutoFeedback.plotclass import line from AutoFeedback.randomclass import randomvar import unittest from main import * x = np.linspace(2,201,200) var = randomvar( 0.5, variance=1/12, dist="chi2", isinteger=False, meanconv=True ) line1=line( x, var ) axislabels=["Number of random variables", "Sample variance"] class UnitTests(unittest.TestCase) : def test_variables(self) : assert(check_plot([line1],explabels=axislabels,explegend=False,output=True))
try: import AutoFeedback.plotchecks as pc from AutoFeedback.plotclass import line except: import subprocess import sys subprocess.check_call( [sys.executable, "-m", "pip", "install", "AutoFeedback"]) import AutoFeedback.plotchecks as pc from AutoFeedback.plotclass import line import unittest from main import * xvals = np.linspace(0, 29, 30) yvals = xvals * xvals line1 = line(xvals, yvals) axislabels = ["Index", "Square"] class UnitTests(unittest.TestCase): def test_fib(self): assert (pc.check_plot([line1], explabels=axislabels, explegend=False, output=True))
class tmod: plt.plot([0, 1, 2], [0, 1, 4], 'r-', label='quadratic') plt.plot([0.5, 1.5], [1.5, 2.5], 'bD', label='linear') plt.legend() plt.axis([-1, 1, -2, 2]) plt.xlabel('x') plt.ylabel('y') plt.title('z') fighand = plt.gca() line_data,axes_data,labels,legend_data = \ pc.extract_plot_elements(fighand,lines=True,axislabels=True,axes=True,legend=True) l1, l2 = line_data[0], line_data[1] line1=line([0,1,2],[0,1,4],linestyle=['-','solid'],\ colour=['r','red',(1.0,0.0,0.0,1)],\ label='quadratic') line2=line([0.5,1.5],[1.5,2.5],marker=['D','d'],\ colour=['b','blue',(0.0,0.0,1.0,1)],\ label='linear') axislabels = ["x", "y", "z"] axeslimits = [-1, 1, -2, 2] class ExtractTests(unittest.TestCase): def test_legend_extract(self): assert (tmod.legend_data == ['quadratic', 'linear']) def test_axes_extract(self):
import subprocess import sys subprocess.check_call( [sys.executable, "-m", "pip", "install", "AutoFeedback"]) from AutoFeedback.plotchecks import check_plot from AutoFeedback.plotclass import line from AutoFeedback.randomclass import randomvar import unittest from main import * x, expect, variance, isi = np.linspace(1, 50, 50), np.zeros(50), np.zeros(50), [] for i in range(50): expect[i], variance[i] = 0.5, 1 / 12 / (i + 1) isi.append(False) y = randomvar(expect, variance=variance, dist="chi2", dof=9, isinteger=isi) line1 = line(x, y) axislabels = ["Number of variables used to calculate mean", "Variance"] class UnitTests(unittest.TestCase): def test_variables(self): assert (check_plot([line1], explabels=axislabels, explegend=False, output=True))
try: from AutoFeedback.plotchecks import check_plot except: import subprocess import sys subprocess.check_call( [sys.executable, "-m", "pip", "install", "AutoFeedback"]) from AutoFeedback.plotchecks import check_plot from AutoFeedback.plotclass import line import unittest from main import * myx = np.loadtxt("data.dat") myx.sort() myy = range(1, len(myx) + 1) myy = [a / len(myx) for a in myy] line1 = line(myx, myy) axislabels = ["x", "cumulative distribution"] class UnitTests(unittest.TestCase): def test_plot(self): assert (check_plot([line1], explabels=axislabels, explegend=False, output=True))