Commit 7c1797c6 authored by Philipp Gast's avatar Philipp Gast
Browse files

Merge branch 'move-keywords' of gitlab:yfournier/myplotlib into move-keywords

Conflicts:
	myFig.py
parents e9eed9b9 6808891d
......@@ -103,3 +103,11 @@ class MyAxes(Axes):
# TESTING THE RAWDATA ------------------------------------------------
def testRawData(self, rawdata):
return(True)
# UPDATE -------------------------------------------------------------
def update(self, **kwargs):
for key in kwargs.keys():
if key in self.keywords.keys():
self.keywords[key] = kwargs[key]
......@@ -124,50 +124,37 @@ class MyFig(Figure):
# UPDATE ----------------------------------------------------------
def update(self, **kwargs):
rest = kwargs.copy()
# check attributes in keywords
for keyword in kwargs.keys():
# if it is the rawdata use the function
if keyword == 'rawdata':
self.set_rawdata(kwargs['rawdata'])
del rest['rawdata']
# if it is an attribute
elif keyword in self._attributesToUpdateKeys:
# update value
setattr(self, keyword, kwargs[keyword])
del rest[keyword]
# For each axes update the keywords
for ax in self.get_axes():
# if aliases is defined with that name
elif keyword in self.aliases.keys():
# update
ax, key = self.aliases[keyword]
ax.keywords[key] = kwargs[keyword]
del rest[keyword]
axkwargs = kwargs.copy() # make a copy of kwargs for this axes
# either a keywords or crap
else:
delete = False
# if it is an axes keyword
for ax in self.get_axes() :
# Check if a key of kwargs has an alias for this axes
for axk in axkwargs.keys():
if axk in self.aliases.keys():
alax, alkey = self.aliases[axk]
if keyword in ax.keywords.keys():
ax.keywords.update({keyword: kwargs[keyword]})
delete = True
if delete:
del rest[keyword]
# if there were some crap
if (self.debug and rest != {}) :
print(DBUG + "These keywords have not been updated: " + str(rest))
# If an alias is found then update axkwargs
if ax == alax:
axkwargs.update({alkey: kwargs[axk]})
# When eventual alias are added then update
ax.update(**axkwargs)
return(True)
# DECLARE ALIASES -------------------------------------------------
def declareAliases(self):
self.aliases = {}
......
Supports Markdown
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