diff --git a/trappy/plotter/AbstractDataPlotter.py b/trappy/plotter/AbstractDataPlotter.py index e4891d82..0bbc4430 100644 --- a/trappy/plotter/AbstractDataPlotter.py +++ b/trappy/plotter/AbstractDataPlotter.py @@ -55,13 +55,13 @@ def _check_data(self): data = listify(self.traces) if len(data): - mask = map(lambda x: isinstance(x, DataFrame), data) - data_frame = reduce(lambda x, y: x and y, mask) + data_frame = all(isinstance(x, DataFrame) for x in data) sig_or_template = self.templates or "signals" in self._attr if not data_frame and not sig_or_template: raise ValueError( - "Cannot understand data. Accepted DataFormats are pandas.DataFrame or trappy.FTrace/BareTrace/SysTrace (with templates)") + "Cannot understand data. Accepted types are pandas.DataFrame" + " or trappy.FTrace/BareTrace/SysTrace (with templates)") elif data_frame and "column" not in self._attr: raise ValueError("Column not specified for DataFrame input") else: diff --git a/trappy/plotter/Constraint.py b/trappy/plotter/Constraint.py index 1a5adc97..9dce3f3b 100644 --- a/trappy/plotter/Constraint.py +++ b/trappy/plotter/Constraint.py @@ -212,8 +212,8 @@ class ConstraintManager(object): :param traces: Input Trace data - :type traces: :mod:`trappy.trace.BareTrace`, list(:mod:`trappy.trace.BareTrace`) - (or a class derived from :mod:`trappy.trace.BareTrace`) + :type traces: a list of :mod:`trappy.trace.BareTrace` (or derived class), + or :mod:`pandas.DataFrame` or a single instance of them. :param columns: The column values from the corresponding :mod:`pandas.DataFrame` :type columns: str, list(str) @@ -276,12 +276,17 @@ def _expand(self): Len[columns] != 1 Len[templates] != 1 ) + + TODO is the following correct? + Permute( + Len[traces] != 1 + Len[columns] = 1 + Len[templates] != 1 + ) """ min_len = min(self._lens) max_pos_comp = [ - i for i, - j in enumerate( - self._lens) if j != self._max_len] + i for i, j in enumerate(self._lens) if j != self._max_len] if self._max_len == 1 and min_len != 1: raise RuntimeError("Essential Arg Missing") diff --git a/trappy/plotter/ILinePlot.py b/trappy/plotter/ILinePlot.py index 2bcd6aa4..fb26d106 100644 --- a/trappy/plotter/ILinePlot.py +++ b/trappy/plotter/ILinePlot.py @@ -36,6 +36,11 @@ class ILinePlot(AbstractDataPlotter): """ + Interactive Line Plotter + + Creates line plots for use in IPython notebooks that can be zoomed and + scrolled interactively + This class uses :mod:`trappy.plotter.Constraint.Constraint` to represent different permutations of input parameters. These constraints are generated by creating an instance of @@ -46,10 +51,30 @@ class ILinePlot(AbstractDataPlotter): :mod:`trappy.trace.SysTrace`, :mod:`trappy.trace.BareTrace` or :mod:`pandas.DataFrame` or a single instance of them. - :param column: specifies the name of the column to - be plotted. + :param column: When plotting DataFrames, specifies the name of the column to + be plotted. If plotting a single DataFrame, may be a list of columns + to use. If plotting multiple DataFrames, must be a single column name + or a list of respective column names such that ``columns[i]`` is + plotted from ``traces[i]`` for each ``i``. :type column: (str, list(str)) + :param signals: When plotting traces (i.e. using ``Ftrace``, ``SysTrace`` et + al. for ``traces``), a string of the type event_name:column to indicate + the value that needs to be plotted. You can add an additional parameter + to specify the color of the line in rgb: "event_name:column:color". The + color is specified as a comma separated list of rgb values, from 0 to + 255 or from 0x0 to 0xff. E.g. 0xff,0x0,0x0 is red and 100,40,32 is + brown. + + .. note:: + + - Only one of `signals` or both `templates` and + `columns` should be specified + - Signals format won't work for :mod:`pandas.DataFrame` + input + + :type signals: str + :param templates: TRAPpy events .. note:: @@ -113,22 +138,6 @@ class ILinePlot(AbstractDataPlotter): you zoom on any plot in a group all plots will zoom at the same time. :type group: string - - :param signals: A string of the type event_name:column to indicate - the value that needs to be plotted. You can add an additional - parameter to specify the color of the lin in rgb: - "event_name:column:color". The color is specified as a comma - separated list of rgb values, from 0 to 255 or from 0x0 to - 0xff. E.g. 0xff,0x0,0x0 is red and 100,40,32 is brown. - - .. note:: - - - Only one of `signals` or both `templates` and - `columns` should be specified - - Signals format won't work for :mod:`pandas.DataFrame` - input - - :type signals: str """ def __init__(self, traces, templates=None, **kwargs): diff --git a/trappy/plotter/Utils.py b/trappy/plotter/Utils.py index 2a475802..344c981a 100644 --- a/trappy/plotter/Utils.py +++ b/trappy/plotter/Utils.py @@ -21,13 +21,17 @@ from trappy.utils import listify -def normalize_list(val, lst): - """Normalize a unitary list""" +def normalize_list(count, lst): + """Normalize a unitary list + :param lst: list with single item + :param count: Length of returned list + :returns: List containing ``count`` instances of the item in ``list`` + """ if len(lst) != 1: raise RuntimeError("Cannot Normalize a non-unitary list") - return lst * val + return lst * count def decolonize(val):