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

Merge branch 'bugfix-figure-complain' into 'dev'

corrected the BUG Figure.__init__ was complaining from user arguments

See merge request !10
parents 56c9038f 3dfebf0e
......@@ -88,7 +88,7 @@ class MyFig_base(Figure):
'debug': D_DEBUG,
'formatted': D_FORMATTED}
# check attributes in keywords
# check attributes
for attribute in attributes.keys():
# if in kwargs
if attribute in kwargs.keys():
......@@ -98,8 +98,20 @@ class MyFig_base(Figure):
del kwargs[attribute]
else:
setattr(self, attribute, attributes[attribute])
# If some user keywords are defined
if hasattr(self, 'keywords'):
# check keywords
for keyword in self.keywords.keys():
# if in kwargs
if keyword in kwargs.keys():
# overwrite the default value
self.keywords[keyword] = kwargs[keyword]
# suppress keyword from kwargs for Figure.__init__
del kwargs[keyword]
else:
self.keywords = {}
self.keywords = {}
self.rawdata = rawdata
# add figsize in the kwargs for Figure.__init__
......@@ -231,21 +243,25 @@ class MyFig(MyFig_base):
# CONSTRUCTOR ------------------------------------------------------
def __init__(self, rawdata, *args, **kwargs):
# define user keywords before
# __init__ to erase them from kwargs
self.defineKeywords()
MyFig_base.__init__(self, rawdata, *args, **kwargs)
self.initialize(*args, **kwargs)
self._initialize(*args, **kwargs)
# INITIALIZE -------------------------------------------------------
def initialize(self, *args, **kwargs):
def _initialize(self, *args, **kwargs):
# sefine user keywords
self.defineKeywords()
# update the attributes and keywords
self.update(**kwargs)
# add the axes
self.addAxes(*args, **kwargs)
self.addAxes()
# set the rawdata through the function
# need to be done for the first init
self.set_rawdata(self.rawdata) # This function can be overwriten
# DEFINE KEYWORDS --------------------------------------------------
......@@ -311,7 +327,8 @@ class MyFig(MyFig_base):
return(status)
# RESET ------------------------------------------------------------
def reset(self):
def reset(self, *args, **kwargs):
self.clf()
self.initialize()
self.defineKeywords()
self._initialize(*args, **kwargs)
self.plot()
......@@ -111,9 +111,9 @@ class FigTest2(MyFig):
return(True)
def addAxes(self, *args, **kwargs):
def addAxes(self):
ratio = 6. / 8. # height/width of the axes (in inch)
frame = [0.0, 0.0, 1.0, 1.0] # part of the fig that is available
self.add_axes(AxTest1(self, ratio, frame, *args, **kwargs))
self.add_axes(AxTest1(self, ratio, frame))
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