Commit 0acfa465 authored by Yori Fournier's avatar Yori Fournier
Browse files

revoked the MplData structure from myplotlib, and forces to give a list as an argument for rawdata.

This is done to prevent confusion when using the server/client interface.
parent 8b15762b
......@@ -87,11 +87,12 @@ else:
raise ImportError
# myplotlib
from .mpl_data import MplData
# from .mpl_data import MplData
# CONFIGURATION --------------------------------------------------------
from .config import D_FIGNUM, D_FIGSIZE, D_REFORMAT, D_FORMATTED
from .config import D_RAWDATA, D_INPUTARG
# from .config import D_RAWDATA, D_INPUTARG
from .config import D_INPUTARG
from .config import D_IPATH
from .config import D_OPATH, D_OFORMAT
from .config import D_DEBUG
......
......@@ -7,5 +7,5 @@ class EmptyAxes(MplAxes):
return(True)
def format_rawdata(self, rawdata):
self.data = rawdata.data
self.data = rawdata
return(True)
......@@ -73,7 +73,7 @@ from . import D_OFORMAT, D_OPATH
from . import DBUG, SEVR, INFO, SPCE, WARN
from . import CONTEXT
from . import MplData
# from . import MplData
from . import MplAxes
from . import HorizontalGrid
......@@ -578,14 +578,11 @@ class MplFig(metaclass=FigureClassFactory, context=CONTEXT.lower()):
After the rawdata is successfully set, it will be formatted.
"""
from collections import Iterable
from itertools import repeat
self.formatted = False
status = False
# DEFAULT: one item per axes in figure
if isinstance(rawdata, Iterable):
if isinstance(rawdata, list):
if len(rawdata) == len(self.get_axes()):
if(self.debug):
......@@ -604,16 +601,6 @@ class MplFig(metaclass=FigureClassFactory, context=CONTEXT.lower()):
len_rawdata=len(rawdata)))
return(False)
# CONVINIENT: one object for all axes
elif isinstance(rawdata, MplData):
if(self.debug):
print("{dbug} set_rawdata: one item for all axes\
".format(dbug=DBUG))
# This is the trick rawdata becomes a generator (so smart)
self.rawdata = repeat(rawdata)
status = self.format_rawdata()
else:
print("{sevr} set_rawdata: I could not set the rawdata...\
".format(sevr=SEVR))
......@@ -645,11 +632,10 @@ class MplFig(metaclass=FigureClassFactory, context=CONTEXT.lower()):
if(self.debug):
print("{info} Axes: {axes_class_name} \
with index {index} formats {rawdata_name}\
with index {index} formats rawdata\
".format(info=INFO,
axes_class_name=ax.__class__.__name__,
index=self.get_axes().index(ax),
rawdata_name=rawdata.name))
index=self.get_axes().index(ax)))
status = ax.test_rawdata(rawdata)
if status:
status = ax.format_rawdata(rawdata)
......@@ -1001,14 +987,11 @@ class MplFig(metaclass=FigureClassFactory, context=CONTEXT.lower()):
After the rawdata is successfully set, it will be formatted.
"""
from collections import Iterable
from itertools import repeat
self.formatted = False
status = False
# DEFAULT: one item per axes in figure
if isinstance(rawdata, Iterable):
if isinstance(rawdata, list):
if len(rawdata) == len(self.get_axes()):
if(self.debug):
......@@ -1027,16 +1010,6 @@ class MplFig(metaclass=FigureClassFactory, context=CONTEXT.lower()):
len_rawdata=len(rawdata)))
return(False)
# CONVINIENT: one object for all axes
elif isinstance(rawdata, str):
if(self.debug):
print("{dbug} set_rawdata: one item for all axes\
".format(dbug=DBUG))
# This is the trick rawdata becomes a generator (so smart)
self.rawdata = repeat(self.server._rawdata[rawdata])
status = self.format_rawdata()
else:
print("{sevr} set_rawdata: I could not set the rawdata...\
".format(sevr=SEVR))
......
......@@ -11,7 +11,7 @@ from . import SERVER_FIGURES
from . import MplFig
from . import DBUG, WARN, SPCE, SEVR, INFO
from . import MplUnpickler, MplData
from . import MplUnpickler
from . import D_DEBUG
......@@ -78,12 +78,12 @@ class MplHandler(socketserver.StreamRequestHandler):
try:
for data_name in data_names:
if self.server._rawdata.get(data_name, None) is not None:
merged_data.append(self.server._rawdata[data_name].data)
merged_data.append(self.server._rawdata[data_name])
else:
return Status(False, 'Could not create '
+ str(merged_name) + ', ' + str(data_name) + ' does not exist...')
self.server._rawdata[merged_name] = MplData(data=merged_data, name=merged_name)
self.server._rawdata[merged_name] = merged_data
return Status(True, 'data '
+ str(merged_name) + ' was successfully created from ' + str(data_names))
......
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