Commit 1255d850 authored by Yori Fournier's avatar Yori Fournier
Browse files

Merge branch '65-CI-script' into 'dev'

Resolve "TEST: Make the CI script ready for the tests"

Closes #65

See merge request !48
parents 716e8d42 1d8c5f3a
Pipeline #425 passed with stage
in 3 minutes and 3 seconds
from matplotlib import rcParams
# BACKEND: u'TKAgg', u'GTKAgg', u'WXAgg', u'Qt4Agg', u'MacOSX'
rcParams['backend'] = u'TKAgg'
# FONT
rcParams['font.family'] = 'serif'
rcParams['font.size'] = '22'
try:
rcParams['text.usetex'] = True # need dvipng, ghostscript, and Agg
except:
print(WARN + "I couls not set the LaTeX font sorry...")
# LINES
rcParams['lines.linewidth'] = 1.5
rcParams['lines.markersize'] = 6
# AXES
rcParams['axes.linewidth'] = 1.5
# TICKS
rcParams['xtick.major.pad'] = 10.
rcParams['xtick.major.size'] = 10.
rcParams['ytick.major.pad'] = 8.
rcParams['ytick.major.size'] = 10.
rcParams['xtick.minor.size'] = 5.
rcParams['ytick.minor.size'] = 5.
# Not compatible with old version of matplotlib
try:
rcParams['xtick.major.width'] = 1.5
rcParams['ytick.major.width'] = 1.5
rcParams['xtick.minor.width'] = 1.5
rcParams['ytick.minor.width'] = 1.5
rcParams['xtick.minor.visible'] = False
rcParams['ytick.minor.visible'] = False
except:
pass
# DPI
rcParams['figure.dpi'] = 75.0
myplotlib_server_client:
before_script:
- apt-get update -q -y
- apt-get install python-dev python-tk -q -y
- wget https://bootstrap.pypa.io/get-pip.py
- python get-pip.py
- python -m pip --version
- python -m pip install --upgrade pip
- python -m pip install -U matplotlib
myplotlib_import_local_latex_tkagg:
script:
- apt-get update -q -y
- apt-get install python-dev python-tk -q -y
- wget https://bootstrap.pypa.io/get-pip.py
- python get-pip.py
- python -m pip --version
- python -m pip install --upgrade pip
- python -m pip install -U matplotlib
- git name-rev --name-only HEAD
- ls -l
- cd test/localhost
- ./setup_test_folder.sh
- ./setup_test_folder.sh -r latex-tkagg
- python import_test.py
- ./clean_test_folder.sh
myplotlib_import_network_latex_tkagg:
script:
- git name-rev --name-only HEAD
- ls -l
- cd test/network
- ./setup_test_folder.sh -r latex-tkagg
- python test_com_nogl.py
- ./clean_test_folder.sh
......@@ -62,8 +62,6 @@ from matplotlib.backends.backend_tkagg import FigureManagerTkAgg, FigureCanvasTk
# Test mpl version:
from matplotlib import __version__ as mplvers
print('VERSION of Matplotlib:' + str(mplvers))
if int(mplvers.replace('.','')[:3]) < 150 :
import six
from six.moves import tkinter as Tk
......
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# ================= FILE HEADER ========================================
#
# myplotlib v3.0.1,
#
# @file myAxes.py
# @author Yori 'AGy' Fournier
# @licence CC-BY-SA
#
# MyAxes class: Overlay of matplotlib Axes class
# It is done such that the user can concentrate on
# the important aspect of the figure and not the
# technical part. It consists of a constructor,
# that requires a Figure, the ratio of the xaxis over
# the yaxis, and the frame in which the figure
# should be plotted.
#
# @Class MyAxes
#
# @Constructor(self, fig, ratio, frame, +user defined kw):
#
# @section Functions
#
# - plotting: this is the overwritten function
# from Axes. It is called by it's
# parent-figure's function .plot()
#
# - formatRawData: it computes out of the rawData
# given as argument some quantities that
# are returned as a dictionary and
# become accessable for plotting.
#
# @section History
#
# v 0.0.0 - MyAxes class for the myplotlib module, consists
# of a constructor, a pltting function and
# formatRawData.
#
# ======================================================================
#
#
# IMPORT ---------------------------------------------------------------
from myplotlib import MyAxes
from myplotlib import DBUG, SPCE, INFO, WARN, SEVR
D_XRANGE = None
D_YRANGE = None
D_LOGY = False
D_LOGX = False
# Class MyAxes Overwriting Matplotlib.figure.Axes
class AxTest(MyAxes):
# DECLARE KEYWORDS -------------------------------------------------
def declareKeywords(self):
self.keywords = {'xRange': D_XRANGE,
'yRange': D_YRANGE}
return(True)
# FORMATTING -------------------------------------------------------
def formatRawData(self, rawdata):
# give value to data a dict
# with xdata, ydata1, zdata, ydata2 ...
try:
self.data = {'xdata': [rawdata.data[0], rawdata.data[1]],
'ydata': [rawdata.data[2], rawdata.data[3]]}
except(TypeError, KeyError, IndexError):
print(SEVR + 'The Raw Data could not be formatted --> EXIT')
return(False)
if(self.fig.debug):
print(DBUG + 'I formatted the raw data!')
return(True)
def plotting(self):
xRange = self.keywords.get('xRange')
yRange = self.keywords.get('yRange')
try:
self.plot(self.data['xdata'], self.data['ydata'])
except KeyError:
print(SEVR + 'The formatting of the data was apparently wrong. --> EXIT')
return(False)
if (xRange): self.set_xlim(xRange)
if (yRange): self.set_ylim(yRange)
return(True)
# IMPORT ---------------------------------------------------------------
from myplotlib import MyFig
from axTest import AxTest
class FigTest(MyFig):
FIGSIZE = (8., 6.)
def addAxes(self):
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(AxTest(self, ratio, frame1), "p1")
......@@ -2,3 +2,11 @@ import sys
sys.path.insert(0, './')
import myplotlib as mpl
from myIOs import readStupidData
from axTest import AxTest
from figTest import FigTest
data = readStupidData()
fig = FigTest((data,))
# win = mpl.MyWin(fig) # requires a DISPLAY not yet available with the current runner (Jochen works one it).
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# ================= FILE HEADER ========================================
#
# myplotlib v3.0.1,
#
# @file myIOs.py
# @author Yori 'AGy' Fournier
# @licence CC-BY-SA
#
# myIOs module: a few Input/Output functions for testing
#
# @function readStupidData
#
# create some stupid data format them as myData format
# and add then in G_RAWDATA such that they could be used
# by myAxes and myFig.
#
# @function readStupidData2
#
# same as readStupidData just with another identifier
#
# @section History
#
# v 0.0.0 - myIOs class for the myplotlib module.
#
# ======================================================================
#
#
# IMPORT ---------------------------------------------------------------
DBUG = False
D_IPATH=''
from myplotlib import MyData
# READ STUPID DATA -----------------------------------------------------
def readStupidData(ipath=D_IPATH, *args, **kwargs):
debug = kwargs.get('debug', 0)
lrawdata = MyData()
lrawdata.name = str(ipath)
lrawdata.data = [-1., 1., 1, -1.]
if(debug):
print(DBUG + 'I read the raw data with readStupidData')
return(lrawdata)
# READ STUPID DATA 2 ---------------------------------------------------
def readStupidData2(ipath=D_IPATH, *args, **kwargs):
debug = kwargs.get('debug', 0)
lrawdata = MyData()
lrawdata.name = str(ipath)
lrawdata.data = [-1., 1., -2., 2.]
if(debug):
print(DBUG + 'I read the raw data with readStupidData2')
return(lrawdata)
......@@ -2,4 +2,5 @@
# On the virtual local host
cd myplotlib
cp ../../../.configs/tests/rconfig-latex-tkagg.py rconfig.py
find ../../../ -maxdepth 1 -name "*.py" -exec ln -s {} . \;
import threading
from serverside.myIOs import readStupidData
from serverside.figTest import FigTest as FigTests
from clientside.figTest import FigTest as FigTestc
SERVER_IOFUNCTIONS = {'readStupidData': readStupidData}
SERVER_FIGURES = {'FigTest': FigTests}
import serverside.myplotlib as mpl_server
import clientside.myplotlib as mpl_client
server = mpl_server.MplServer2(port=50803, knownFunctions=SERVER_IOFUNCTIONS, knownFigures=SERVER_FIGURES)
client = mpl_client.MplClient2()
# Start a thread with the server -- that thread will then start one
# more thread for each request
server_thread = threading.Thread(target=server.serve_forever)
# Exit the server thread when the main thread terminates
server_thread.daemon = True
server_thread.start()
print "Server loop running in thread:", server_thread.name
client.connect(('', 50803))
client.readData('readStupidData', 'data1')
fig = client.newSyncFigure(FigTestc, ('data1',))
Markdown is supported
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