Commit e9eed9b9 authored by Philipp Gast's avatar Philipp Gast
Browse files

tests now working (2 new). ready for merge

parent cfbbbda3
......@@ -94,7 +94,8 @@ from .test import myTest
from .test import test100
from .test import test200, test201, test202
from .test import test300, test301, test302, test303, test304, test305
from .test import test306, test307, test308, test309, test310
from .test import test306, test307, test308, test309, test310, test311
from .test import test312
from .test import test400, test401, test402, test403
from .test import test500, test501, test502, test503, test504
from .test import test505, test506, test507, test508
......@@ -104,7 +105,8 @@ from .test import test600
testList = [test100,
test201, test202,
test300, test301, test302, test303, test304, test305,
test306, test307, test308, test309, test310,
test306, test307, test308, test309, test310, test311,
test312,
test400, test401, test402,
test503, test506, test500, test507, test501, test502,
test504, test505, test508,
......
......@@ -186,22 +186,26 @@ class MyFig(Figure):
return False
# test if an axes with that name is already present
for ax in self.get_axes() :
if ax.name == name :
for pax in self.get_axes() :
if pax.name == name :
print(SEVR + " an axes with that name is already present")
return False
Figure.add_axes(self, ax)
return True
# GET AXES BY NAME -------------------------------------------------
def getAxesByName(self, name):
for ax in self.get_axes() :
if ax.name == name :
return ax
else :
return None
#if the name is correct we should never get here.
print(SEVR + "The axes name ",name," was not found")
return None
# SET RAW DATA -----------------------------------------------------
def set_rawdata(self, rawdata):
......
from .myIOs import readStupidData, readStupidData2
from .axTest1 import AxTest1
from .figTest import FigTest2
from .figTest import FigTest3
from .figTest import FigTest1, FigTest2
from .tests import myTest
......@@ -10,7 +9,8 @@ from .tests import myTest
from .tests import test100
from .tests import test200, test201, test202
from .tests import test300, test301, test302, test303, test304, test305
from .tests import test306, test307, test308, test309, test310
from .tests import test306, test307, test308, test309, test310, test311
from .tests import test312
from .tests import test400, test401, test402, test403
from .tests import test500, test501, test502, test503, test504
from .tests import test505, test506, test507, test508
......
......@@ -71,32 +71,8 @@ from .. import MyFig
from .axTest1 import AxTest1
class FigTest1(MyFig):
# Set the size of the Figure in inch
# (private variable can not be updated)
FIGSIZE = (8., 6.)
# def declareAliases(self):
# self.aliases = {'xRange_p1': (self.ax1, "xRange"),
# 'xRange_p2': (self.ax2, "xRange")}
# return(True)
def addAxes(self):
ratio = 6. / 8. # height/width of the axes (in inch)
frame1 = [0.1, 0.1, 0.4, 0.8] # part of the fig that is available
frame2 = [0.6, 0.1, 0.4, 0.8] # part of the fig that is available
self.add_axes(AxTest1(self, ratio, frame1))
self.add_axes(AxTest1(self, ratio, frame2))
# Class MyFig Overwriting Matplotlib.figure.Figure
class FigTest2(MyFig):
class FigTest1(MyFig): # Fig with one Axes
# Set the size of the Figure in inch
# (private variable can not be updated)
......@@ -107,15 +83,14 @@ class FigTest2(MyFig):
ratio = 6. / 8. # height/width of the axes (in inch)
frame1 = [0.1, 0.1, 0.8, 0.8] # part of the fig that is available
self.add_axes(AxTest1(self, ratio, frame1))
self.add_axes(AxTest1(self, ratio, frame1),"p1")
class FigTest3(MyFig):
class FigTest2(MyFig): # Fig with two Axes
# Set the size of the Figure in inch
# (private variable can not be updated)
FIGSIZE = (8., 6.)
def addAxes(self):
ratio = 6. / 8. # height/width of the axes (in inch)
......
......@@ -6,7 +6,7 @@ from .. import SEVR, WARN, DBUG, SPCE
from .. import G_RAWDATAS, _G_WINDOWS
from . import readStupidData, readStupidData2
from . import FigTest2, AxTest1
from . import FigTest1,FigTest2, AxTest1
from .. import window_exists, getCurrentWindowIDs
from .. import getFigOnWindow, getWindow
......@@ -81,10 +81,10 @@ def test200(debug):
data.data = [0, 0, 1, 1] # Dummy data
if(debug):
print(DBUG + "try to create FigTest2.")
print(DBUG + "try to create FigTest1.")
# create a figure
fig = FigTest2((data,), dpi=75.)
fig = FigTest1((data,), dpi=75.)
# set ratio and frameRect
ratio = 4. / 6. # float
......@@ -168,7 +168,7 @@ def test201(debug):
G_RAWDATAS.update({'data': MyData()})
# create the environment
fig = FigTest2((G_RAWDATAS['data'],))
fig = FigTest1((G_RAWDATAS['data'],))
# create the axis
ax = AxTest1(fig, 6. / 8., [0, 0, 1, 1])
......@@ -193,7 +193,7 @@ def test202(debug):
# create the environment
G_RAWDATAS.update({'data': MyData()})
fig = FigTest2((G_RAWDATAS['data'],))
fig = FigTest1((G_RAWDATAS['data'],))
# create the axis
ax = AxTest1(fig, 6. / 8., [0, 0, 1, 1])
......@@ -226,7 +226,7 @@ def test300(debug):
data1 = readStupidData('data1')
data2 = readStupidData2('data2')
fig = FigTest2((data1,))
fig = FigTest1((data1,))
fig.update(rawdata=(data2,))
......@@ -250,7 +250,7 @@ def test301(debug):
data1 = readStupidData('data1')
fig = FigTest2((data1,))
fig = FigTest1((data1,))
if debug:
print(DBUG + "Try to print MyFig with data1 in myplotlib/img/test301.png")
......@@ -276,7 +276,7 @@ def test302(debug):
data1 = readStupidData('data1')
fig = FigTest2((data1,))
fig = FigTest1((data1,))
if debug:
print(DBUG + "Try to print MyFig with data1 in myplotlib/img/test302.eps")
......@@ -299,7 +299,7 @@ def test303(debug):
data1 = readStupidData('data1')
fig = FigTest2((data1,))
fig = FigTest1((data1,))
if debug:
print(DBUG + "Try to print MyFig with data1 in a non existing file.")
......@@ -322,7 +322,7 @@ def test304(debug):
data1 = readStupidData('data1')
fig = FigTest2((data1,))
fig = FigTest1((data1,))
if debug:
print(DBUG + "Try to print MyFig with data1 in myplotlib/img/test304.eps")
......@@ -348,7 +348,7 @@ def test305(debug):
data1 = readStupidData('data1')
fig = FigTest2((data1,))
fig = FigTest1((data1,))
if debug:
print(DBUG + "Try to print MyFig with data1 in myplotlib/img/test305.png")
......@@ -374,7 +374,7 @@ def test306(debug):
data1 = readStupidData('data1')
fig = FigTest2((data1,))
fig = FigTest1((data1,))
if debug:
print(DBUG + "Try to print MyFig with data1 in myplotlib/img/test306.png")
......@@ -402,7 +402,7 @@ def test307(debug):
# TEST 3.08: test MyFig::plot
def test308(debug):
fig = FigTest2(('Non-Existing-Data',), debug=False)
fig = FigTest1(('Non-Existing-Data',), debug=False)
if(debug):
print(DBUG + "test without data: ")
......@@ -449,7 +449,7 @@ def test309(debug):
status = True
fig = FigTest2(('dummy',), fignum=-12, reformat=True, debug=False, formatted=True)
fig = FigTest1(('dummy',), fignum=-12, reformat=True, debug=False, formatted=True)
if fig.fignum != -12:
status = False
......@@ -477,7 +477,7 @@ def test310(debug):
# create environment
data = readStupidData('data1')
fig = FigTest2((data,))
fig = FigTest1((data,))
# save current axis
ax = fig.get_axes()[0]
......@@ -494,6 +494,53 @@ def test310(debug):
return(status)
# TEST 3.11: test if the correct number of axes are present (EXPECTED: TRUE)
def test311(debug):
status = True
# create environment
data = readStupidData('data1')
fig = FigTest2(data) # use one4all method
if len(fig.get_axes()) != 2 : status=False # sounds like a stupid test but I had that problem :-S
return(status)
# TEST 3.12: test if alias behavior is correct (EXPECTED: TRUE)
def test312(debug):
status = True
# create environment
data = readStupidData('data1')
fig = FigTest2(data) # use one4all method
fig.update(xRange_p1=(0,2)) # using an alias
fig.update(yRange=(0,2)) # without using an alias
# update figure
fig.plot()
# get axes
ax1=fig.getAxesByName('p1')
ax2=fig.getAxesByName('p2')
print(data.data)
if ax1.get_xlim() != (0.0, 2.0) : status = False
if ax1.get_ylim() != (0.0, 2.0) : status = False
if ax2.get_xlim() != (-1.0, 1.0) : status = False
if ax2.get_ylim() != (0.0, 2.0) : status = False
if debug :
print(DBUG+'ax1 [x_min,xmax] : ', ax1.get_xlim())
print(DBUG+'ax1 [y_min,ymax] : ', ax1.get_ylim())
print(DBUG+'ax2 [x_min,xmax] : ', ax2.get_xlim())
print(DBUG+'ax2 [y_min,ymax] : ', ax2.get_ylim())
return(status)
# TEST 4.00: test MyWin (EXPECTED: TRUE)
def test400(debug):
......@@ -501,7 +548,7 @@ def test400(debug):
status = True
data1 = readStupidData('data1')
fig = FigTest2((data1,))
fig = FigTest1((data1,))
win = MyWin(fig)
try:
......@@ -526,7 +573,7 @@ def test401(debug):
# create figure
data1 = readStupidData('data1')
fig = FigTest2((data1,))
fig = FigTest1((data1,))
if debug:
print(DBUG + "An object MyFig with data1 has been created.")
......@@ -557,7 +604,7 @@ def test402(debug):
data1 = readStupidData('data1')
data2 = readStupidData2('data2')
fig = FigTest2((data1,))
fig = FigTest1((data1,))
formerAxes = fig.get_axes()[0]
if(debug): print(DBUG + "Created a MyFig object with data1.")
......@@ -603,7 +650,7 @@ def test403(debug):
data1 = readStupidData('data1')
data2 = readStupidData2('data2')
fig = FigTest2((data1,))
fig = FigTest1((data1,))
if(debug):
print(DBUG + "Put a MyFig into a MyWin with data1")
......@@ -638,7 +685,7 @@ def test503(debug):
status = True
data = readStupidData('data1')
fig = FigTest2((data,))
fig = FigTest1((data,))
win = MyWin(fig)
if(getFigOnWindow(0) != fig):
......@@ -657,7 +704,7 @@ def test506(debug):
status = True
data = readStupidData('data1')
fig = FigTest2((data,))
fig = FigTest1((data,))
win = MyWin(fig)
closeWindow(0)
......@@ -678,7 +725,7 @@ def test500(debug):
status = True
data = readStupidData('data1')
print2screen(FigTest2, (data,))
print2screen(FigTest1, (data,))
fig = getFigOnWindow(0)
if(fig.rawdata != (data,)):
status = False
......@@ -696,8 +743,8 @@ def test507(debug):
status = True
data = readStupidData('data1')
print2screen(FigTest2, (data,), fignum=1)
print2screen(FigTest2, (data,), fignum=4)
print2screen(FigTest1, (data,), fignum=1)
print2screen(FigTest1, (data,), fignum=4)
closeAllWindows()
......@@ -715,10 +762,10 @@ def test501(debug):
status = True
data = readStupidData('data1')
print2screen(FigTest2, (data,), fignum=1)
print2screen(FigTest2, (data,), fignum=24)
print2screen(FigTest2, (data,), fignum=4)
print2screen(FigTest2, (data,), fignum=1)
print2screen(FigTest1, (data,), fignum=1)
print2screen(FigTest1, (data,), fignum=24)
print2screen(FigTest1, (data,), fignum=4)
print2screen(FigTest1, (data,), fignum=1)
IDs = getCurrentWindowIDs()
......@@ -739,7 +786,7 @@ def test502(debug):
status = True
data = readStupidData('data1')
win = MyWin(FigTest2((data,)), fignum=2)
win = MyWin(FigTest1((data,)), fignum=2)
if(win != getWindow(2)):
status = False
......@@ -757,7 +804,7 @@ def test504(debug):
data1 = readStupidData('data1')
data2 = readStupidData2('data2')
fig1 = FigTest2((data1,))
fig1 = FigTest1((data1,))
win = drawFigOnWindow(fig1, 12)
......@@ -773,7 +820,7 @@ def test504(debug):
status = False
if(debug): print(DBUG + "The canvas of fig1 is not the one of the window.")
fig2 = FigTest2((data2,))
fig2 = FigTest1((data2,))
if(win != drawFigOnWindow(fig2, 12)):
status = False
......@@ -813,7 +860,7 @@ def test505(debug):
data1 = readStupidData('data1')
data2 = readStupidData2('data2')
print2screen(FigTest2, (data1,))
print2screen(FigTest1, (data1,))
giveDataToWindow((data2,), 0)
win = getWindow(0)
......@@ -849,8 +896,8 @@ def test508(debug):
data1 = readStupidData('data1')
if debug:
print(DBUG + "Try to print FigTest2 with data1 in myplotlib/img/test508.png")
status = print2file(FigTest2, (data1,), "./myplotlib/img/test508.png")
print(DBUG + "Try to print FigTest1 with data1 in myplotlib/img/test508.png")
status = print2file(FigTest1, (data1,), "./myplotlib/img/test508.png")
if not os.path.exists("./myplotlib/img/test508.png"):
status = False
......@@ -867,7 +914,7 @@ def test600(debug):
data = readStupidData('data1')
fig = FigTest2((data,))
fig = FigTest1((data,))
win = MyWin(fig)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment