Beispiel #1
0
    def test_constraint_with_window(self):
        """Test that the constraint manager can constraint to a window of time"""
        c_mgr = ConstraintManager(self.dfrs[0],
                                  "freq",
                                  None,
                                  AttrConf.PIVOT, {},
                                  window=(1, 3))

        constraint = iter(c_mgr).next()
        series = constraint.result[AttrConf.PIVOT_VAL]
        self.assertEquals(len(series), 3)

        # For the graph to plot a value at 0.75, the resulting series
        # must contain the value before 0.75.  Same for the upper limit.
        c_mgr = ConstraintManager(self.dfrs[0],
                                  "freq",
                                  None,
                                  AttrConf.PIVOT, {},
                                  window=(0.75, 1.5))

        constraint = iter(c_mgr).next()
        series = constraint.result[AttrConf.PIVOT_VAL]
        self.assertEquals(series.index.tolist(), [0, 1, 2])

        c_mgr = ConstraintManager(self.dfrs[0],
                                  "freq",
                                  None,
                                  AttrConf.PIVOT, {},
                                  window=(0, 2))

        constraint = iter(c_mgr).next()
        series = constraint.result[AttrConf.PIVOT_VAL]
        self.assertEquals(len(series), 3)
Beispiel #2
0
    def __init__(self, traces, templates, **kwargs):
        self._fig = None
        self._layout = None
        super(StaticPlot, self).__init__(traces=traces, templates=templates)

        self.set_defaults()

        for key in kwargs:
            if key in AttrConf.ARGS_TO_FORWARD:
                self._attr["args_to_forward"][key] = kwargs[key]
            else:
                self._attr[key] = kwargs[key]

        if "signals" in self._attr:
            self._describe_signals()

        self._check_data()

        if "column" not in self._attr:
            raise RuntimeError("Value Column not specified")

        zip_constraints = not self._attr["permute"]
        self.c_mgr = ConstraintManager(traces,
                                       self._attr["column"],
                                       self.templates,
                                       self._attr["pivot"],
                                       self._attr["filters"],
                                       zip_constraints=zip_constraints)
Beispiel #3
0
    def __init__(self, traces, templates=None, **kwargs):
        # Default keys, each can be overridden in kwargs
        self._layout = None
        super(ILinePlot, self).__init__(traces=traces, templates=templates)

        self.set_defaults()

        for key in kwargs:
            self._attr[key] = kwargs[key]

        if "signals" in self._attr:
            self._describe_signals()

        self._check_data()

        if "column" not in self._attr:
            raise RuntimeError("Value Column not specified")

        if self._attr["drawstyle"] and self._attr["drawstyle"].startswith(
                "steps"):
            self._attr["step_plot"] = True

        zip_constraints = not self._attr["permute"]

        window = self._attr["xlim"] if "xlim" in self._attr else None

        self.c_mgr = ConstraintManager(traces,
                                       self._attr["column"],
                                       self.templates,
                                       self._attr["pivot"],
                                       self._attr["filters"],
                                       window=window,
                                       zip_constraints=zip_constraints)
Beispiel #4
0
    def __init__(self, runs, templates=None, **kwargs):
        # Default keys, each can be overridden in kwargs
        self._attr = {}
        self.runs = runs
        self.templates = templates
        self.set_defaults()
        self._fig = None
        self._layout = None

        self._check_data()

        for key in kwargs:
            if key in AttrConf.ARGS_TO_FORWARD:
                self._attr["args_to_forward"][key] = kwargs[key]
            else:
                self._attr[key] = kwargs[key]

        if "column" not in self._attr:
            raise RuntimeError("Value Column not specified")

        zip_constraints = not self._attr["permute"]
        self.c_mgr = ConstraintManager(runs, self._attr["column"], templates,
                                       self._attr["pivot"],
                                       self._attr["filters"], zip_constraints)
        self._check_add_scatter()
        super(LinePlot, self).__init__()
Beispiel #5
0
    def __init__(self, runs, templates=None, **kwargs):
        # Default keys, each can be overridden in kwargs
        self._attr = {}
        self.runs = runs
        self.templates = templates
        self.set_defaults()
        self._layout = None

        self._check_data()
        for key in kwargs:
            self._attr[key] = kwargs[key]

        if "column" not in self._attr:
            raise RuntimeError("Value Column not specified")

        if self._attr["drawstyle"] and self._attr["drawstyle"].startswith(
                "steps"):
            self._attr["step_plot"] = True

        zip_constraints = not self._attr["permute"]

        self.c_mgr = ConstraintManager(runs, self._attr["column"], templates,
                                       self._attr["pivot"],
                                       self._attr["filters"], zip_constraints)

        super(ILinePlot, self).__init__()
Beispiel #6
0
    def test_no_pivot_multiple_traces(self):
        """Test that the constraint manager works with multiple traces and no pivots"""

        c_mgr = ConstraintManager(self.dfrs, "load", None, AttrConf.PIVOT, {})

        self.assertEquals(len(c_mgr), 2)

        for constraint, orig_dfr in zip(c_mgr, self.dfrs):
            series = constraint.result[AttrConf.PIVOT_VAL]
            self.assertEquals(series.to_dict().values(),
                              orig_dfr["load"].to_dict().values())
Beispiel #7
0
    def test_no_pivot_zipped_columns_and_traces(self):
        """Test the constraint manager with multiple columns and traces zipped"""

        c_mgr = ConstraintManager(self.dfrs, self.cols, None, AttrConf.PIVOT, {})

        self.assertEquals(len(c_mgr), 2)

        for constraint, orig_dfr, col in zip(c_mgr, self.dfrs, self.cols):
            series = constraint.result[AttrConf.PIVOT_VAL]
            self.assertEquals(series.to_dict().values(),
                              orig_dfr[col].to_dict().values())
Beispiel #8
0
    def test_pivoted_multitraces_multicolumns(self):
        """Test the constraint manager with multiple traces and columns"""

        c_mgr = ConstraintManager(self.dfrs, ["load", "freq"], None, "cpu", {})
        self.assertEquals(len(c_mgr), 2)

        constraint_iter = iter(c_mgr)
        constraint = constraint_iter.next()
        self.assertEquals(constraint.result[1].to_dict().values(), [2, 3])

        constraint = constraint_iter.next()
        self.assertEquals(constraint.result[0].to_dict().values(), [2, 1])
Beispiel #9
0
    def test_no_pivot_multicolumns_multitraces(self):
        """Test the constraint manager with multiple traces that can have each multiple columns"""

        c_mgr = ConstraintManager(self.dfrs, self.cols, None, AttrConf.PIVOT,
                                  {}, zip_constraints=False)

        self.assertEquals(len(c_mgr), 4)

        expected_series = [dfr[col] for dfr in self.dfrs for col in self.cols]
        for constraint, orig_series in zip(c_mgr, expected_series):
            series = constraint.result[AttrConf.PIVOT_VAL]
            self.assertEquals(series.to_dict(), orig_series.to_dict())
Beispiel #10
0
    def test_pivoted_data(self):
        """Test the constraint manager with a pivot and one trace"""

        c_mgr = ConstraintManager(self.dfrs[0], "load", None, "cpu", {})

        self.assertEquals(len(c_mgr), 1)

        constraint = iter(c_mgr).next()
        results = dict([(k, v.to_dict().values()) for k, v in constraint.result.items()])
        expected_results = {0: [1, 2], 1: [2, 3]}

        self.assertEquals(results, expected_results)
Beispiel #11
0
    def test_one_constraint(self):
        """Test that the constraint manager works with one constraint"""

        dfr = self.dfrs[0]

        c_mgr = ConstraintManager(dfr, "load", None, AttrConf.PIVOT, {})

        self.assertEquals(len(c_mgr), 1)

        constraint = iter(c_mgr).next()
        series = constraint.result[AttrConf.PIVOT_VAL]
        self.assertEquals(series.to_dict().values(),
                          dfr["load"].to_dict().values())
Beispiel #12
0
    def test_pivoted_multitrace(self):
        """Test the constraint manager with a pivot and multiple traces"""

        c_mgr = ConstraintManager(self.dfrs, "load", None, "cpu", {})

        self.assertEquals(len(c_mgr), 2)

        constraint_iter = iter(c_mgr)
        constraint = constraint_iter.next()
        self.assertEquals(constraint.result[0].to_dict().values(), [1, 2])

        constraint = constraint_iter.next()
        self.assertEquals(constraint.result[1].to_dict().values(), [2, 2])
Beispiel #13
0
    def test_pivoted_with_filters(self):
        """Test the constraint manager with pivoted data and filters"""

        simple_filter = {"load": [2]}
        c_mgr = ConstraintManager(self.dfrs[0], "freq", None, "cpu",
                                  simple_filter)

        self.assertEquals(len(c_mgr), 1)

        constraint = iter(c_mgr).next()
        result = constraint.result

        self.assertEquals(result[0].iloc[0], 3)
        self.assertEquals(result[1].iloc[0], 3)
Beispiel #14
0
    def test_no_pivot_filters(self):
        """Test the constraint manager with filters"""

        simple_filter = {"freq": [2]}

        c_mgr = ConstraintManager(self.dfrs, "load", None, AttrConf.PIVOT,
                                  simple_filter)

        num_constraints = len(c_mgr)
        self.assertEquals(num_constraints, 2)

        constraint_iter = iter(c_mgr)
        constraint = constraint_iter.next()
        self.assertEquals(len(constraint.result), 1)

        constraint = constraint_iter.next()
        series_second_frame = constraint.result[AttrConf.PIVOT_VAL]
        self.assertEquals(series_second_frame.to_dict().values(), [3, 2])