Commit 1042f173 authored by Philipp Gast's avatar Philipp Gast
Browse files

minimal version of the behavior of issue 18 working:

give either iterable or single instance to set_rawdata of figure
parent 4921bfe6
......@@ -73,7 +73,7 @@ class MyAxes(Axes):
hypoHeight = maxWidth * ratio
# if the hypothetical width is larger that the
# maximum allowed width (in inches) then chose
# maximum allowed width (in inches) then choose
# the hypothetical Height
if (hypoWidth > maxWidth):
height = hypoHeight / figHeight # height in percent
......
......@@ -70,6 +70,7 @@ from . import D_FIGSIZE, D_INPUTARG, D_DEBUG, D_REFORMAT, D_FORMATTED
from . import D_OFORMAT, D_OPATH
from . import DBUG, SEVR, INFO, SPCE, WARN
from . import G_RAWDATAS
from . import MyData
from . import Figure
......@@ -271,21 +272,26 @@ class MyFig(MyFig_base):
# ADD AXES ---------------------------------------------------------
def addAxes(self, *arg, **kwargs):
pass
# SET RAW DATA -----------------------------------------------------
def set_rawdata(self, rawdata):
if(type(rawdata) != tuple):
print(SEVR + "rawdata should be a tuple. i.e. (data1,)")
return(False)
from collections import Iterable
from itertools import repeat
if(len(self.get_axes()) == len(rawdata)):
if isinstance(rawdata, Iterable): # default case. one item per axis in figure
if(self.debug): print(DBUG + "using 'default case' in set_rawdata")
self.rawdata = rawdata
self.formatted = False
self.formatRawData()
else:
elif isinstance(rawdata, MyData) : # conveniece case : if just one object is given use it for all axis
if(self.debug): print(DBUG + "using 'conveniece case' in set_rawdata")
self.rawdata = repeat(rawdata) # this is nessesary because we don't know jet how many axis are in the figure
self.formatted = False
self.formatRawData()
else :
if(self.debug): print(DBUG + "using 'ERROR CASE' in set_rawdata")
self.rawdata = ()
print(SEVR + "rawdata should have the dimention of the number of axes: #axes = " + str(len(self.get_axes())) + "; dim of rawdata = " + str(len(rawdata)))
return(False)
return(True)
......@@ -296,6 +302,7 @@ class MyFig(MyFig_base):
for ax, rawdata in zip(self.get_axes(), self.rawdata):
if(self.debug):
print(DBUG+" combining ", rawdata ," with ", ax)
ax.formatRawData(rawdata)
else:
try:
......
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