From 9315407ba080de7b26e140f0414626756757c373 Mon Sep 17 00:00:00 2001 From: Yori 'AGy' Fournier Date: Wed, 8 Mar 2017 16:09:04 +0100 Subject: [PATCH 1/2] Changed the inline loops in myAxes In MyAxes.update we wrote some inline loops that are not compatible with python2.6 I just wrote them in not inline mode, it shoudl work --- myAxes.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/myAxes.py b/myAxes.py index 291dc1e..1a2a054 100644 --- a/myAxes.py +++ b/myAxes.py @@ -114,8 +114,19 @@ class MyAxes(Axes): # Because matplotlib.axes.update expect kwargs and not **kwargs ... (stupid!!) if args: # catch matplotlib kwargs kwargs = args[0] - kw_for_axes = {key: value for (key, value) in args[0].items() if key not in self.keywords} + # kw_for_axes = {key: value for (key, value) in args[0].items() if key not in self.keywords} # Not compatible with python2.6 + + kw_for_axes = {} + for (key, value) in args[0].items(): + if key not in self.keywords: + kw_for_axes.update({key: value}) + Axes.update(self, kw_for_axes) # update matplotlib.Axes # myplotlib update - self.keywords.update({key: value for (key, value) in kwargs.items() if key in self.keywords}) + # self.keywords.update({key: value for (key, value) in kwargs.items() if key in self.keywords}) # Not compatible with python2.6 + + for (key, value) in kwargs.items(): + if key in self.keywords: + self.keywords.update({key: value}) + -- GitLab From bf696c841c9dd4661a09106d4b4f4d62854f3e7c Mon Sep 17 00:00:00 2001 From: Yori Fournier Date: Wed, 8 Mar 2017 16:29:41 +0100 Subject: [PATCH 2/2] Test the compatibility Now compatible with python2.6 Also tested with matplotlib < 143 test203 fail because in that version the function set_xlim was not yet existing. All version of matplotlib < 143 are not considered as stable therefore not supported. I add a message in __init__ I also corrected a bug I added in a former commit: I prevent myplotlib.__init__ from importing tests but just testList. This prevented `python myplotlib --test ` to work because no tests were in myplotlib.__dict__ So I change the import from: from . import __dict__ to from .test import __dict__ Now `python myplotlib --test ` works --- __init__.py | 9 ++++++++- __main__.py | 6 +++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/__init__.py b/__init__.py index e71c84d..fbe457c 100644 --- a/__init__.py +++ b/__init__.py @@ -33,9 +33,17 @@ # # # IMPORT --------------------------------------------------------------- +from .config import INFO, WARN, SEVR, DBUG, SPCE + import os as os import numpy as np +# 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') + # matplotlib from matplotlib.pyplot import figure from matplotlib.pyplot import rc @@ -56,7 +64,6 @@ G_RAWDATAS = {'current': MyData()} # raw data Object _G_WINDOWS = [] # CONFIGURATION -------------------------------------------------------- -from .config import INFO, WARN, SEVR, DBUG, SPCE from .config import D_FIGNUM, D_FIGSIZE, D_REFORMAT, D_FORMATTED from .config import D_RAWDATA, D_INPUTARG from .config import D_IPATH diff --git a/__main__.py b/__main__.py index b3f2908..d2fd3ee 100644 --- a/__main__.py +++ b/__main__.py @@ -33,7 +33,7 @@ # IMPORT --------------------------------------------------------------- from . import INFO, SPCE, DBUG from . import myTest, testList -from . import __dict__ +from .test import __dict__ as availTests import sys import getopt @@ -76,8 +76,8 @@ for opt, arg in opts: tests = arg.split(', ') testList = [] for test in tests: - if test in __dict__.keys(): - testList.append(__dict__[test]) + if test in availTests.keys(): + testList.append(availTests[test]) if len(testList) == 0: print(" > sevr-: you need to give valid tests to be tested.") -- GitLab