Commit 91975266 authored by Yori Fournier's avatar Yori Fournier
Browse files

Merge branch '88-cleanning-pep8-compilance' into 'dev'

Almost Resolve "CLEANNING: PEP8 compilance"

See merge request !59
parents 0443382a 1fc7e78e
Pipeline #515 passed with stage
in 12 minutes and 22 seconds
from .myData import MyData
from .mpl_data import MplData
from matplotlib import rcParams
# FORM -----------------------------------------------------------------
......@@ -14,7 +14,7 @@ D_FIGNUM = 0 # default figure number
D_FIGSIZE = (8., 6.) # default figure size
D_REFORMAT = True # default reformat value
D_FORMATTED = False # default formatted value
D_RAWDATA = MyData() # default raw data
D_RAWDATA = MplData() # default raw data
D_INPUTARG = 'current' # default Input argument
# myIOs
......
from .myData import MyData
from .mpl_data import MplData
from matplotlib import rcParams
# FORM -----------------------------------------------------------------
......@@ -14,7 +14,7 @@ D_FIGNUM = 0 # default figure number
D_FIGSIZE = (8., 6.) # default figure size
D_REFORMAT = True # default reformat value
D_FORMATTED = False # default formatted value
D_RAWDATA = MyData() # default raw data
D_RAWDATA = MplData() # default raw data
D_INPUTARG = 'current' # default Input argument
# myIOs
......
from .myData import MyData
from .mpl_data import MplData
from matplotlib import rcParams
# FORM -----------------------------------------------------------------
......@@ -14,7 +14,7 @@ D_FIGNUM = 0 # default figure number
D_FIGSIZE = (8., 6.) # default figure size
D_REFORMAT = True # default reformat value
D_FORMATTED = False # default formatted value
D_RAWDATA = MyData() # default raw data
D_RAWDATA = MplData() # default raw data
D_INPUTARG = 'current' # default Input argument
# myIOs
......
from .myData import MyData
from .mpl_data import MplData
# TECHNICAL ------------------------------------------------------------
D_VERSION='v5'
......@@ -19,7 +19,7 @@ D_FIGNUM = 0 # default figure number
D_FIGSIZE = (8., 6.) # default figure size
D_REFORMAT = True # default reformat value
D_FORMATTED = False # default formatted value
D_RAWDATA = MyData() # default raw data
D_RAWDATA = MplData() # default raw data
D_INPUTARG = 'current' # default Input argument
# myIOs
......
......@@ -6,6 +6,7 @@ before_script:
- python -m pip --version
- python -m pip install --upgrade pip
- python -m pip install -U matplotlib
- python -m pip install pep8
myplotlib_import_local_latex_tkagg:
script:
......@@ -15,13 +16,14 @@ myplotlib_import_local_latex_tkagg:
- ./setup_test_folder.sh -r latex-tkagg
- python import_test.py
- python -m tests
- python -m tutorials
- ./clean_test_folder.sh
myplotlib_test_mytool:
script:
- git name-rev --name-only HEAD
- ls -l
- cd mytool
- cd mpl_toolbox/
- cp ../.configs/tests/config-local.py ../config.py
- python -m tests
- python -m tutorials
......@@ -35,3 +37,11 @@ myplotlib_import_network_latex_tkagg:
- python test_com_nogl.py
- python -m tests
- ./clean_test_folder.sh
myplotlib_test_pep8:
script:
- git name-rev --name-only HEAD
- ls -l
- cd test
- python -m comp_pep8
allow_failure: true
......@@ -38,24 +38,40 @@ from .config import D_HIERARCHY
import os as os
import numpy as np
np.set_printoptions(threshold='nan')
from signal import Signal, Query, Status, Answer
from mpl_unpickler import MplUnpickler
np.set_printoptions(threshold='nan')
# matplotlib import for client/local -----------------------------------
if D_HIERARCHY in ('CLIENT', 'client', 'LOCAL', 'local'):
if D_HIERARCHY in ('CLIENT', 'client'):
print(INFO+'Import '+__package__+' as a client.')
print(INFO + 'Import ' + __package__ + ' as a client.')
else:
print(INFO+'Import '+__package__+' for local use.')
print(INFO + 'Import ' + __package__ + ' for local use.')
# Test mpl version:
from matplotlib import __version__ as mplvers
if int(mplvers.replace('.','')[:3]) < 143 :
print('\n\n' + WARN + 72*'=' + '\n' + SPCE + 'The matplotlib version you are using is not supported.\n' + SPCE + 'Most of myplotlib should work, but some stuff may not.\n' + SPCE + 'ex: expect an error with test203\n' + SPCE + 72*'=' + '\n\n')
if int(mplvers.replace('.', '')[:3]) < 143:
print(
'\n\n' +
WARN +
72 *
'=' +
'\n' +
SPCE +
'The matplotlib version you are using is not supported.\n' +
SPCE +
'Most of myplotlib should work, but some stuff may not.\n' +
SPCE +
'ex: expect an error with test203\n' +
SPCE +
72 *
'=' +
'\n\n')
# matplotlib
from matplotlib.pyplot import figure
......@@ -70,18 +86,19 @@ if D_HIERARCHY in ('CLIENT', 'client', 'LOCAL', 'local'):
from .config import D_HOST, D_PORT
from socket import socket, AF_INET, SOCK_STREAM
elif D_HIERARCHY in ('SERVER', 'server'):
print(INFO+'Import '+__package__+' as a server.')
if DBUG:
print(INFO + 'Import ' + __package__ + ' as a server.')
from .config import D_HOST, D_PORT
from socket import socket, AF_INET, SOCK_STREAM, SOL_SOCKET, SO_REUSEADDR
else:
print(SEVR+'the value of D_HIERARCHY has to be SERVER or CLIENT')
else:
print(SEVR + 'the value of D_HIERARCHY has to be SERVER or CLIENT')
raise ImportError
# myplotlib
from .myData import MyData
from .mpl_data import MplData
# CONFIGURATION --------------------------------------------------------
from .config import D_FIGNUM, D_FIGSIZE, D_REFORMAT, D_FORMATTED
......@@ -91,70 +108,64 @@ from .config import D_OPATH, D_OFORMAT
from .config import D_DEBUG
if D_HIERARCHY in ('CLIENT', 'client', 'LOCAL', 'local'):
from .rconfig import rcParams
if D_HIERARCHY in ('CLIENT', 'client'):
# MyAxes: Overlay on matplotlib.Axes class
from .myAxes_client import MyAxes_client as MyAxes
# MyFig: Overlay on matplotlib.Figure class
from .myFig_client import MyFig_client as MyFig
# MplAxes: Overlay on matplotlib.Axes class
from .mpl_axes_client import MplAxesClient as MplAxes
from .progressbar import ProgressBar
from .mpl_grid import Grid, VerticalGrid, HorizontalGrid
from .mplClient import MplClient
from .mplClient2 import MplClient2
# MplFig: Overlay on matplotlib.Figure class
from .mpl_fig_client import MplFigClient as MplFig
elif(D_HIERARCHY in ('SERVER', 'server')):
from .progressbar import ProgressBar
# MyAxes: Overlay on matplotlib.Axes class
from .myAxes_server import MyAxes_server as MyAxes
from .mpl_client import MplClient
# MyFig: Overlay on matplotlib.Figure class
from .myFig_server import MyFig_server as MyFig
elif(D_HIERARCHY in ('SERVER', 'server')):
# from .test import FigTestServer
# from .test import FigTest
# MplAxes: Overlay on matplotlib.Axes class
from .mpl_axes_server import MplAxesServer as MplAxes
# for testing purpose
# from .test import readStupidData, readStupidData2
from .mpl_grid import Grid, VerticalGrid, HorizontalGrid
# MplFig: Overlay on matplotlib.Figure class
from .mpl_fig_server import MplFigServer as MplFig
SERVER_IOFUNCTIONS = {
# 'readStupidData': readStupidData,
# 'readStupidData2': readStupidData2
# 'readStupidData': readStupidData,
# 'readStupidData2': readStupidData2
}
SERVER_FIGURES = {
#'FigTest': FigTest
}
from .mplServer import MplServer
from .mplServer2 import MplServer2, MplHandler
from .mpl_server import MplServer, MplHandler
elif D_HIERARCHY in ('LOCAL', 'local'):
# MyAxes: Overlay on matplotlib.Axes class
from .myAxes import MyAxes
# MyFig: Overlay on matplotlib.Figure class
from .myFig import MyFig
# MplAxes: Overlay on matplotlib.Axes class
from .mpl_axes import MplAxes
from .mplGrid import Grid, VerticalGrid, HorizontalGrid
# MplFig: Overlay on matplotlib.Figure class
from .mpl_grid import Grid, VerticalGrid, HorizontalGrid
from .mpl_fig import MplFig
from .empty_fig import EmptyFig
from .empty_axes import EmptyAxes
else:
print(SEVR+'the value of D_HIERARCHY has to be SERVER, CLIENT or LOCAL')
raise ImportError
print(SEVR + 'the value of D_HIERARCHY has to be SERVER, CLIENT or LOCAL')
raise ImportError
if D_HIERARCHY in ('CLIENT', 'client', 'LOCAL', 'local'):
_G_WINDOWS = []
# MyWin: Overlay on matplotlib.FigureManager class
if rcParams['backend'] == u'TkAgg':
from .myWin_TkAgg import MyWin_TkAgg as MyWin
......@@ -167,24 +178,5 @@ if D_HIERARCHY in ('CLIENT', 'client', 'LOCAL', 'local'):
elif rcParams['backend'] == u'MacOSX':
from .myWin_MacOSx import MyWin_MacOSx as MyWin
else:
print(SEVR + "The backend you choosed is not supported interactive mode not available")
# myTool.*: interface functions to use myplotlib interactively
#from .mytool import print2file # need to make tools for server ?? or just put them in client/local
#from .mytool import FigOneAxes
#if D_HIERARCHY in ('CLIENT', 'client', 'LOCAL', 'local'):
# from .mytool import print2file # need to make tools for server ?? or just put them in client/local
# from .mytool import FigOneAxes
# from .mytool import window_exists, getCurrentWindowIDs
# from .mytool import print2file, print2screen, printListCurrentWindows
# from .mytool import getWindow, getFigOnWindow, drawFigOnWindow, giveDataToWindow
# from .mytool import closeWindow, closeAllWindows
# TESTS ----------------------------------------------------------------
# from .test import myTest
# from .test import testList
# from .test import FigTest
print(SEVR + """The backend you choosed is not
supported interactive mode not available""")
......@@ -35,8 +35,8 @@ from . import D_HIERARCHY
from . import INFO, SPCE, DBUG
if D_HIERARCHY in ('CLIENT', 'client', 'local', 'LOCAL'):
from . import myTest, testList
from .test import __dict__ as availTests
from . import myTest
from .test import __dict__ as avail_tests
else:
from socket import socket, AF_INET, SOCK_STREAM
from . import D_HOST, D_PORT
......@@ -48,9 +48,9 @@ import getopt
run4Plot = False
arg4Plot = ''
run4Test = False
debug = False
debug = False
# GET PASSED OPTIONS ---------------------------------------------------
# GET PASSED OPTIONS ---------------------------------------------------
usage = '''
{0}Usage: python mfdPlot [-h]
{1} [-t/--test [all/<num of test>]
......@@ -63,7 +63,7 @@ usage = '''
try:
opts, args = getopt.getopt(
sys.argv[1:], "htp:", ["test=", "plot=", "args=", "debug", "server"])
except getopt.GetoptError:
print(usage)
sys.exit(1)
......@@ -73,56 +73,68 @@ for opt, arg in opts:
if(opt == '-h'):
print(usage)
sys.exit(0)
elif opt in ("-t"):
run4Test = True
elif opt in ("--test"):
run4Test = True
tests = arg.split(', ')
testList = []
for test in tests:
if test in availTests.keys():
testList.append(availTests[test])
if test in avail_tests.keys():
testList.append(avail_tests[test])
if len(testList) == 0:
print(" > sevr-: you need to give valid tests to be tested.")
exit(1)
elif opt in ("-p", "--plot"):
run4Plot = True
arg4Plot = str(arg)
elif opt in ("--debug"):
debug = True
elif opt in ("--server"):
run4server = True
run4server = True
# SECTION: TESTS ------------------------------------------------------
if run4Test:
if debug:
print(DBUG + '{title:{c}^{n}}'.format(title=' Run for Test ', c='=', n=72))
print(
DBUG +
'{title:{c}^{n}}'.format(
title=' Run for Test ',
c='=',
n=72))
else:
print(INFO + '{title:{c}^{n}}'.format(title=' Run for Test ', c='=', n=72))
print(
INFO +
'{title:{c}^{n}}'.format(
title=' Run for Test ',
c='=',
n=72))
fail = []
status = True
print(INFO + "TESTS: ")
for test in testList:
print('\n')
print(INFO + '{title:{c}^{n}}'.format(title=' ' + str(test.__name__) + ' ', c='=', n=72))
testStatus = myTest(test, True, fail, debug) # function, expected, fail, debug
print(INFO + '{title:{c}^{n}}'.format(title=' ' + \
str(test.__name__) + ' ', c='=', n=72))
# function, expected, fail, debug
testStatus = myTest(test, True, fail, debug)
if testStatus:
print(INFO + 72 * '-' + " [PASSED]")
else:
print(INFO + 72 * '-' + " [FAILED] !")
status = status and testStatus
# Print final status
print('\n')
print(INFO + 'Status of test series: ' + str(status))
......@@ -134,9 +146,9 @@ if run4Test:
# SECTION: PLOTS ------------------------------------------------------
elif run4Plot:
print(INFO + '{title:{c}^{n}}'.format(title=' Run for Plot ', c='=', n=72))
# try:
# data = arg4Plot
# somePlottingRoutine(data)
......@@ -150,7 +162,7 @@ elif run4server:
from . import Server
from . import readStupidData
server = Server()
server.init()
server.run()
......@@ -158,5 +170,3 @@ elif run4server:
else:
print(usage)
from .myData import MyData
from .mpl_Data import MplData
from matplotlib import rcParams
# FORM -----------------------------------------------------------------
......@@ -10,22 +10,22 @@ SPCE = " > -----: "
# CONFIGURATION --------------------------------------------------------
# myFig
D_FIGNUM = 0 # default figure number
D_FIGSIZE = (8., 6.) # default figure size
D_REFORMAT = True # default reformat value
D_FORMATTED = False # default formatted value
D_RAWDATA = MyData() # default raw data
D_INPUTARG = 'current' # default Input argument
D_FIGNUM = 0 # default figure number
D_FIGSIZE = (8., 6.) # default figure size
D_REFORMAT = True # default reformat value
D_FORMATTED = False # default formatted value
D_RAWDATA = MplData() # default raw data
D_INPUTARG = 'current' # default Input argument
# myIOs
D_IPATH = '../' # default path to project
D_IPATH = '../' # default path to project
# print2file
D_OPATH = 'myplotlib/img/' # default path to ouput
D_OFORMAT = 'png' # default format for ouput
D_OPATH = 'myplotlib/img/' # default path to ouput
D_OFORMAT = 'png' # default format for ouput
# Debug
D_DEBUG = True # default debug value
D_DEBUG = True # default debug value
# PLOTTING CONFIGURATION -----------------------------------------------
# BACKEND: u'TKAgg', u'GTKAgg', u'WXAgg', u'Qt4Agg', u'MacOSX'
......@@ -36,7 +36,7 @@ rcParams['font.family'] = 'serif'
rcParams['font.size'] = '22'
try:
rcParams['text.usetex'] = True # need dvipng, ghostscript, and Agg
except:
except Exception:
print(WARN + "I could not set the LaTeX font sorry...")
# LINES
......@@ -61,7 +61,7 @@ try:
rcParams['ytick.minor.width'] = 1.5
rcParams['xtick.minor.visible'] = False
rcParams['ytick.minor.visible'] = False
except:
except Exception:
pass
# DPI
......
from .myData import MyData
from .mpl_Data import MplData
# TECHNICAL ------------------------------------------------------------
D_VERSION='v5'
D_HIERARCHY='SERVER'
D_HOST='localhost'
D_PORT=50803
D_VERSION = 'v5'
D_HIERARCHY = 'SERVER'
D_HOST = 'localhost'
D_PORT = 50803
# FORM -----------------------------------------------------------------
INFO = " > info-: "
......@@ -15,19 +15,19 @@ SPCE = " > -----: "
# CONFIGURATION --------------------------------------------------------
# myFig
D_FIGNUM = 0 # default figure number
D_FIGSIZE = (8., 6.) # default figure size
D_REFORMAT = True # default reformat value
D_FORMATTED = False # default formatted value
D_RAWDATA = MyData() # default raw data
D_INPUTARG = 'current' # default Input argument
D_FIGNUM = 0 # default figure number
D_FIGSIZE = (8., 6.) # default figure size
D_REFORMAT = True # default reformat value
D_FORMATTED = False # default formatted value
D_RAWDATA = MplData() # default raw data
D_INPUTARG = 'current' # default Input argument
# myIOs
D_IPATH = '../' # default path to project
D_IPATH = '../' # default path to project
# print2file
D_OPATH = 'myplotlib/img/' # default path to ouput
D_OFORMAT = 'png' # default format for ouput
D_OPATH = 'myplotlib/img/' # default path to ouput
D_OFORMAT = 'png' # default format for ouput
# Debug
D_DEBUG = True # default debug value
D_DEBUG = True # default debug value
from myplotlib import MyAxes
from myplotlib import MplAxes
class EmptyAxes(MyAxes):
class EmptyAxes(MplAxes):
def plotting(self):
return(True)
def formatRawData(self, rawdata):
def format_rawdata(self, rawdata):
self.data = rawdata.data
return(True)
from myplotlib import MyFig
from myplotlib import MplFig
class EmptyFig(MyFig):
class EmptyFig(MplFig):
def __init__(self, **kwargs):
MyFig.__init__(self, (), **kwargs)
MplFig.__init__(self, (), **kwargs)
def addAxes(self):
pass
from . import socket, AF_INET, SOCK_STREAM
from . import INFO, DBUG, WARN, SEVR, SPCE
SIZE_STATUS_MAX = 1024
from . import ProgressBar
from . import D_DEBUG
DEBUG = D_DEBUG
# CLASS CLIENT ---------------------------------------------------------
class MplClient(object):
# CONSTRUCTOR ------------------------------------------------------
def __init__(self, ip, port):
'''This is a myplotlib client.
It sends instructions to a MplSever at host:port.
'''
self.ip = ip
self.port = port
# just a list of names
#~ self.currentRemoteData = []
# PACK SIGNAL ------------------------------------------------------
def packSignal(self, unpackedSignal):
'''Pack the signal.'''
packedSignal = ''
header, instrucSize = unpackedSignal
header = str(header)
instrucSize = str(instrucSize)
packedSignal = "("+"\""+header+"\""+", "+instrucSize+")"
return(packedSignal)
# PACK INSTRUCTION -------------------------------------------------
def packInstructions(self, instructions):
'''Pack the instructions, a tuple of strings: (header, content).'''
header, packedContent = instructions
packedInstructions = "(\""+header+"\", "+str(packedContent)+")"
return(packedInstructions)
# PACK READDATA CONTENT --------------------------------------------
def packReadDataContent(self, ioFunction, dataName, *args, **kwargs):
'''Pack the content of the instructions for readData.'''
packedContent = "['"+str(dataName)+"', '"+ioFunction.__name__+"', "+str(args)+", "+str(kwargs)+"]"
return(packedContent)
# READ DATA --------------------------------------------------------
def readData(self, ioFunction, dataName, *args, **kwargs):
'''Start the readData procedure.
1. Send ReadData Signal with length of packedInstructions
2. Wait for receipt
3. Send Instructions
4. Wait for status