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 from matplotlib import rcParams
# FORM ----------------------------------------------------------------- # FORM -----------------------------------------------------------------
...@@ -14,7 +14,7 @@ D_FIGNUM = 0 # default figure number ...@@ -14,7 +14,7 @@ D_FIGNUM = 0 # default figure number
D_FIGSIZE = (8., 6.) # default figure size D_FIGSIZE = (8., 6.) # default figure size
D_REFORMAT = True # default reformat value D_REFORMAT = True # default reformat value
D_FORMATTED = False # default formatted 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 D_INPUTARG = 'current' # default Input argument
# myIOs # myIOs
......
from .myData import MyData from .mpl_data import MplData
from matplotlib import rcParams from matplotlib import rcParams
# FORM ----------------------------------------------------------------- # FORM -----------------------------------------------------------------
...@@ -14,7 +14,7 @@ D_FIGNUM = 0 # default figure number ...@@ -14,7 +14,7 @@ D_FIGNUM = 0 # default figure number
D_FIGSIZE = (8., 6.) # default figure size D_FIGSIZE = (8., 6.) # default figure size
D_REFORMAT = True # default reformat value D_REFORMAT = True # default reformat value
D_FORMATTED = False # default formatted 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 D_INPUTARG = 'current' # default Input argument
# myIOs # myIOs
......
from .myData import MyData from .mpl_data import MplData
from matplotlib import rcParams from matplotlib import rcParams
# FORM ----------------------------------------------------------------- # FORM -----------------------------------------------------------------
...@@ -14,7 +14,7 @@ D_FIGNUM = 0 # default figure number ...@@ -14,7 +14,7 @@ D_FIGNUM = 0 # default figure number
D_FIGSIZE = (8., 6.) # default figure size D_FIGSIZE = (8., 6.) # default figure size
D_REFORMAT = True # default reformat value D_REFORMAT = True # default reformat value
D_FORMATTED = False # default formatted 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 D_INPUTARG = 'current' # default Input argument
# myIOs # myIOs
......
from .myData import MyData from .mpl_data import MplData
# TECHNICAL ------------------------------------------------------------ # TECHNICAL ------------------------------------------------------------
D_VERSION='v5' D_VERSION='v5'
...@@ -19,7 +19,7 @@ D_FIGNUM = 0 # default figure number ...@@ -19,7 +19,7 @@ D_FIGNUM = 0 # default figure number
D_FIGSIZE = (8., 6.) # default figure size D_FIGSIZE = (8., 6.) # default figure size
D_REFORMAT = True # default reformat value D_REFORMAT = True # default reformat value
D_FORMATTED = False # default formatted 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 D_INPUTARG = 'current' # default Input argument
# myIOs # myIOs
......
...@@ -6,6 +6,7 @@ before_script: ...@@ -6,6 +6,7 @@ before_script:
- python -m pip --version - python -m pip --version
- python -m pip install --upgrade pip - python -m pip install --upgrade pip
- python -m pip install -U matplotlib - python -m pip install -U matplotlib
- python -m pip install pep8
myplotlib_import_local_latex_tkagg: myplotlib_import_local_latex_tkagg:
script: script:
...@@ -15,13 +16,14 @@ myplotlib_import_local_latex_tkagg: ...@@ -15,13 +16,14 @@ myplotlib_import_local_latex_tkagg:
- ./setup_test_folder.sh -r latex-tkagg - ./setup_test_folder.sh -r latex-tkagg
- python import_test.py - python import_test.py
- python -m tests - python -m tests
- python -m tutorials
- ./clean_test_folder.sh - ./clean_test_folder.sh
myplotlib_test_mytool: myplotlib_test_mytool:
script: script:
- git name-rev --name-only HEAD - git name-rev --name-only HEAD
- ls -l - ls -l
- cd mytool - cd mpl_toolbox/
- cp ../.configs/tests/config-local.py ../config.py - cp ../.configs/tests/config-local.py ../config.py
- python -m tests - python -m tests
- python -m tutorials - python -m tutorials
...@@ -35,3 +37,11 @@ myplotlib_import_network_latex_tkagg: ...@@ -35,3 +37,11 @@ myplotlib_import_network_latex_tkagg:
- python test_com_nogl.py - python test_com_nogl.py
- python -m tests - python -m tests
- ./clean_test_folder.sh - ./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 ...@@ -38,24 +38,40 @@ from .config import D_HIERARCHY
import os as os import os as os
import numpy as np import numpy as np
np.set_printoptions(threshold='nan')
from signal import Signal, Query, Status, Answer from signal import Signal, Query, Status, Answer
from mpl_unpickler import MplUnpickler from mpl_unpickler import MplUnpickler
np.set_printoptions(threshold='nan')
# matplotlib import for client/local ----------------------------------- # matplotlib import for client/local -----------------------------------
if D_HIERARCHY in ('CLIENT', 'client', 'LOCAL', 'local'): if D_HIERARCHY in ('CLIENT', 'client', 'LOCAL', 'local'):
if D_HIERARCHY in ('CLIENT', 'client'): if D_HIERARCHY in ('CLIENT', 'client'):
print(INFO+'Import '+__package__+' as a client.') print(INFO + 'Import ' + __package__ + ' as a client.')
else: else:
print(INFO+'Import '+__package__+' for local use.') print(INFO + 'Import ' + __package__ + ' for local use.')
# Test mpl version: # Test mpl version:
from matplotlib import __version__ as mplvers from matplotlib import __version__ as mplvers
if int(mplvers.replace('.','')[:3]) < 143 : 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') 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 # matplotlib
from matplotlib.pyplot import figure from matplotlib.pyplot import figure
...@@ -70,18 +86,19 @@ if D_HIERARCHY in ('CLIENT', 'client', 'LOCAL', 'local'): ...@@ -70,18 +86,19 @@ if D_HIERARCHY in ('CLIENT', 'client', 'LOCAL', 'local'):
from .config import D_HOST, D_PORT from .config import D_HOST, D_PORT
from socket import socket, AF_INET, SOCK_STREAM from socket import socket, AF_INET, SOCK_STREAM
elif D_HIERARCHY in ('SERVER', 'server'): 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 .config import D_HOST, D_PORT
from socket import socket, AF_INET, SOCK_STREAM, SOL_SOCKET, SO_REUSEADDR from socket import socket, AF_INET, SOCK_STREAM, SOL_SOCKET, SO_REUSEADDR
else: else:
print(SEVR+'the value of D_HIERARCHY has to be SERVER or CLIENT') print(SEVR + 'the value of D_HIERARCHY has to be SERVER or CLIENT')
raise ImportError raise ImportError
# myplotlib # myplotlib
from .myData import MyData from .mpl_data import MplData
# CONFIGURATION -------------------------------------------------------- # CONFIGURATION --------------------------------------------------------
from .config import D_FIGNUM, D_FIGSIZE, D_REFORMAT, D_FORMATTED from .config import D_FIGNUM, D_FIGSIZE, D_REFORMAT, D_FORMATTED
...@@ -91,70 +108,64 @@ from .config import D_OPATH, D_OFORMAT ...@@ -91,70 +108,64 @@ from .config import D_OPATH, D_OFORMAT
from .config import D_DEBUG from .config import D_DEBUG
if D_HIERARCHY in ('CLIENT', 'client', 'LOCAL', 'local'): if D_HIERARCHY in ('CLIENT', 'client', 'LOCAL', 'local'):
from .rconfig import rcParams from .rconfig import rcParams
if D_HIERARCHY in ('CLIENT', 'client'): 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 # MplAxes: Overlay on matplotlib.Axes class
from .myFig_client import MyFig_client as MyFig from .mpl_axes_client import MplAxesClient as MplAxes
from .progressbar import ProgressBar from .mpl_grid import Grid, VerticalGrid, HorizontalGrid
from .mplClient import MplClient # MplFig: Overlay on matplotlib.Figure class
from .mplClient2 import MplClient2 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 .mpl_client import MplClient
from .myAxes_server import MyAxes_server as MyAxes
# MyFig: Overlay on matplotlib.Figure class elif(D_HIERARCHY in ('SERVER', 'server')):
from .myFig_server import MyFig_server as MyFig
# from .test import FigTestServer # MplAxes: Overlay on matplotlib.Axes class
# from .test import FigTest from .mpl_axes_server import MplAxesServer as MplAxes
# for testing purpose from .mpl_grid import Grid, VerticalGrid, HorizontalGrid
# from .test import readStupidData, readStupidData2
# MplFig: Overlay on matplotlib.Figure class
from .mpl_fig_server import MplFigServer as MplFig
SERVER_IOFUNCTIONS = { SERVER_IOFUNCTIONS = {
# 'readStupidData': readStupidData, # 'readStupidData': readStupidData,
# 'readStupidData2': readStupidData2 # 'readStupidData2': readStupidData2
} }
SERVER_FIGURES = { SERVER_FIGURES = {
#'FigTest': FigTest #'FigTest': FigTest
} }
from .mplServer import MplServer from .mpl_server import MplServer, MplHandler
from .mplServer2 import MplServer2, MplHandler
elif D_HIERARCHY in ('LOCAL', 'local'): elif D_HIERARCHY in ('LOCAL', 'local'):
# MyAxes: Overlay on matplotlib.Axes class
from .myAxes import MyAxes
# MyFig: Overlay on matplotlib.Figure class # MplAxes: Overlay on matplotlib.Axes class
from .myFig import MyFig 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_fig import EmptyFig
from .empty_axes import EmptyAxes from .empty_axes import EmptyAxes
else: else:
print(SEVR+'the value of D_HIERARCHY has to be SERVER, CLIENT or LOCAL') print(SEVR + 'the value of D_HIERARCHY has to be SERVER, CLIENT or LOCAL')
raise ImportError raise ImportError
if D_HIERARCHY in ('CLIENT', 'client', 'LOCAL', 'local'): if D_HIERARCHY in ('CLIENT', 'client', 'LOCAL', 'local'):
_G_WINDOWS = [] _G_WINDOWS = []
# MyWin: Overlay on matplotlib.FigureManager class # MyWin: Overlay on matplotlib.FigureManager class
if rcParams['backend'] == u'TkAgg': if rcParams['backend'] == u'TkAgg':
from .myWin_TkAgg import MyWin_TkAgg as MyWin from .myWin_TkAgg import MyWin_TkAgg as MyWin
...@@ -167,24 +178,5 @@ if D_HIERARCHY in ('CLIENT', 'client', 'LOCAL', 'local'): ...@@ -167,24 +178,5 @@ if D_HIERARCHY in ('CLIENT', 'client', 'LOCAL', 'local'):
elif rcParams['backend'] == u'MacOSX': elif rcParams['backend'] == u'MacOSX':
from .myWin_MacOSx import MyWin_MacOSx as MyWin from .myWin_MacOSx import MyWin_MacOSx as MyWin
else: else:
print(SEVR + "The backend you choosed is not supported interactive mode not available") 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
...@@ -35,8 +35,8 @@ from . import D_HIERARCHY ...@@ -35,8 +35,8 @@ from . import D_HIERARCHY
from . import INFO, SPCE, DBUG from . import INFO, SPCE, DBUG
if D_HIERARCHY in ('CLIENT', 'client', 'local', 'LOCAL'): if D_HIERARCHY in ('CLIENT', 'client', 'local', 'LOCAL'):
from . import myTest, testList from . import myTest
from .test import __dict__ as availTests from .test import __dict__ as avail_tests
else: else:
from socket import socket, AF_INET, SOCK_STREAM from socket import socket, AF_INET, SOCK_STREAM
from . import D_HOST, D_PORT from . import D_HOST, D_PORT
...@@ -48,9 +48,9 @@ import getopt ...@@ -48,9 +48,9 @@ import getopt
run4Plot = False run4Plot = False
arg4Plot = '' arg4Plot = ''
run4Test = False run4Test = False
debug = False debug = False
# GET PASSED OPTIONS --------------------------------------------------- # GET PASSED OPTIONS ---------------------------------------------------
usage = ''' usage = '''
{0}Usage: python mfdPlot [-h] {0}Usage: python mfdPlot [-h]
{1} [-t/--test [all/<num of test>] {1} [-t/--test [all/<num of test>]
...@@ -63,7 +63,7 @@ usage = ''' ...@@ -63,7 +63,7 @@ usage = '''
try: try:
opts, args = getopt.getopt( opts, args = getopt.getopt(
sys.argv[1:], "htp:", ["test=", "plot=", "args=", "debug", "server"]) sys.argv[1:], "htp:", ["test=", "plot=", "args=", "debug", "server"])
except getopt.GetoptError: except getopt.GetoptError:
print(usage) print(usage)
sys.exit(1) sys.exit(1)
...@@ -73,56 +73,68 @@ for opt, arg in opts: ...@@ -73,56 +73,68 @@ for opt, arg in opts:
if(opt == '-h'): if(opt == '-h'):
print(usage) print(usage)
sys.exit(0) sys.exit(0)
elif opt in ("-t"): elif opt in ("-t"):
run4Test = True run4Test = True
elif opt in ("--test"): elif opt in ("--test"):
run4Test = True run4Test = True
tests = arg.split(', ') tests = arg.split(', ')
testList = [] testList = []
for test in tests: for test in tests:
if test in availTests.keys(): if test in avail_tests.keys():
testList.append(availTests[test]) testList.append(avail_tests[test])
if len(testList) == 0: if len(testList) == 0:
print(" > sevr-: you need to give valid tests to be tested.") print(" > sevr-: you need to give valid tests to be tested.")
exit(1) exit(1)
elif opt in ("-p", "--plot"): elif opt in ("-p", "--plot"):
run4Plot = True run4Plot = True
arg4Plot = str(arg) arg4Plot = str(arg)
elif opt in ("--debug"): elif opt in ("--debug"):
debug = True debug = True
elif opt in ("--server"): elif opt in ("--server"):
run4server = True run4server = True
# SECTION: TESTS ------------------------------------------------------ # SECTION: TESTS ------------------------------------------------------
if run4Test: if run4Test:
if debug: 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: 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 = [] fail = []
status = True status = True
print(INFO + "TESTS: ") print(INFO + "TESTS: ")
for test in testList: for test in testList:
print('\n') print('\n')
print(INFO + '{title:{c}^{n}}'.format(title=' ' + str(test.__name__) + ' ', c='=', n=72)) print(INFO + '{title:{c}^{n}}'.format(title=' ' + \
testStatus = myTest(test, True, fail, debug) # function, expected, fail, debug str(test.__name__) + ' ', c='=', n=72))
# function, expected, fail, debug
testStatus = myTest(test, True, fail, debug)
if testStatus: if testStatus:
print(INFO + 72 * '-' + " [PASSED]") print(INFO + 72 * '-' + " [PASSED]")
else: else:
print(INFO + 72 * '-' + " [FAILED] !") print(INFO + 72 * '-' + " [FAILED] !")
status = status and testStatus status = status and testStatus
# Print final status # Print final status
print('\n') print('\n')
print(INFO + 'Status of test series: ' + str(status)) print(INFO + 'Status of test series: ' + str(status))
...@@ -134,9 +146,9 @@ if run4Test: ...@@ -134,9 +146,9 @@ if run4Test:
# SECTION: PLOTS ------------------------------------------------------ # SECTION: PLOTS ------------------------------------------------------
elif run4Plot: elif run4Plot:
print(INFO + '{title:{c}^{n}}'.format(title=' Run for Plot ', c='=', n=72)) print(INFO + '{title:{c}^{n}}'.format(title=' Run for Plot ', c='=', n=72))
# try: # try:
# data = arg4Plot # data = arg4Plot
# somePlottingRoutine(data) # somePlottingRoutine(data)
...@@ -150,7 +162,7 @@ elif run4server: ...@@ -150,7 +162,7 @@ elif run4server:
from . import Server from . import Server
from . import readStupidData from . import readStupidData
server = Server() server = Server()
server.init() server.init()
server.run() server.run()
...@@ -158,5 +170,3 @@ elif run4server: ...@@ -158,5 +170,3 @@ elif run4server:
else: else:
print(usage) print(usage)
from .myData import MyData from .mpl_Data import MplData
from matplotlib import rcParams from matplotlib import rcParams
# FORM ----------------------------------------------------------------- # FORM -----------------------------------------------------------------
...@@ -10,22 +10,22 @@ SPCE = " > -----: " ...@@ -10,22 +10,22 @@ SPCE = " > -----: "
# CONFIGURATION -------------------------------------------------------- # CONFIGURATION --------------------------------------------------------
# myFig # myFig
D_FIGNUM = 0 # default figure number D_FIGNUM = 0 # default figure number
D_FIGSIZE = (8., 6.) # default figure size D_FIGSIZE = (8., 6.) # default figure size
D_REFORMAT = True # default reformat value D_REFORMAT = True # default reformat value
D_FORMATTED = False # default formatted 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 D_INPUTARG = 'current' # default Input argument
# myIOs # myIOs
D_IPATH = '../' # default path to project D_IPATH = '../' # default path to project
# print2file # print2file
D_OPATH = 'myplotlib/img/' # default path to ouput D_OPATH = 'myplotlib/img/' # default path to ouput
D_OFORMAT = 'png' # default format for ouput D_OFORMAT = 'png' # default format for ouput
# Debug # Debug
D_DEBUG = True # default debug value D_DEBUG = True # default debug value