Example #1
0
    def test_singleAggregators(self):
        _, fd1 = OverwriteFunctions.from_xaxis_dict({
            "A": [(1, 1), (2, 2), (3, 3)],
            "B": [(3, 3), (4, 4), (5, 5)],
            "C": [(7, 7), (8, 8)],
            "D": [(14, 14)]
        }).alter_curves(None)
        _, fd2 = OverwriteFunctions.from_xaxis_dict({
            "A": [(10, 10), (20, 20), (30, 30)],
            "B": [(6, 6), (7, 7), (8, 8)],
            "C": [(10, 10), (11, 11)]
        }).alter_curves(None)

        aggregator = aggregators.SingleAggregator()
        fdtotal = aggregator.with_pandas([fd1, fd2])

        CheckFunctions.from_xaxis_dict({
            "A": [(1, 1), (2, 2), (3, 3), (10, 10), (20, 20), (30, 30)],
            "B": [(3, 3), (
                4,
                4,
            ), (5, 5), (6, 6), (7, 7), (8, 8)],
            "C": [(7, 7), (8, 8), (10, 10), (11, 11)],
            "D": [(14, 14)],
        }).alter_curves(fdtotal)
Example #2
0
    def test_QuantizeXAxis_03(self):
        """
        functions not defined everywhere
        :return:
        """
        _, fd = OverwriteFunctions.from_dict(
            xaxis=[1, 2, 3, 4, 5, 6],
            functions={
                "A": [10, np.nan, 15, 10, 15, 15],
                "B": [20, 30, np.nan, np.nan, 30, 30],
                "C": [40, 50, 50, 40, np.nan, 50]
            }).alter_curves(None)

        _, fd = QuantizeXAxis(
            quantization_levels=[0, 2, 4, 6],
            slot_value=UpperBoundSlotValueFetcher(),
            merge_method=MeanAggregator(),
        ).alter_curves(fd)

        CheckFunctions.from_dict(xaxis=[2, 4, 6],
                                 functions={
                                     "A": [10, 12.5, 15],
                                     "B": [25, np.nan, 30],
                                     "C": [45, 45, 50]
                                 })
Example #3
0
 def test_CheckNoInvalidNumbers_01(self):
     _, fd = OverwriteFunctions.from_dict(xaxis=[1, 2, 3],
                                          functions={
                                              "A": [3, 4, 5],
                                              "B": [6, 7, 8],
                                              "C": [9, 10, 11]
                                          }).alter_curves(None)
     CheckNoInvalidNumbers().alter_curves(fd)
Example #4
0
    def singleAggregatorsDuplicated(self):
        _, fd1 = OverwriteFunctions.from_xaxis_dict({
            "A": [(1, 1), (2, 2), (3, 3)],
            "B": [(3, 3), (4, 4), (5, 5)],
            "C": [(7, 7), (8, 8)],
            "D": [(14, 14)]
        }).alter_curves(None)
        _, fd2 = OverwriteFunctions.from_xaxis_dict({
            "A": [(10, 10), (20, 20), (30, 30)],
            "B": [(6, 6), (7, 7), (8, 8)],
            "C": [(10, 10), (7, 7)]  # dupliacted entry
        }).alter_curves(None)

        aggregator = aggregators.SingleAggregator()

        with self.assertRaises(ValueError) as context:
            fdtotal = aggregator.with_pandas([fd1, fd2])
Example #5
0
    def test_CheckNoInvalidNumbers_07(self):
        _, fd = OverwriteFunctions.from_dict(xaxis=[1, 2, 3, 4, 5],
                                             functions={
                                                 "A": [3, 4, 5, 6, 7],
                                                 "B": [6, 7, 8, 9, 10],
                                                 "C": [9, 10, 11, 12, np.nan]
                                             }).alter_curves(None)

        with self.assertRaises(ValueError) as context:
            CheckNoInvalidNumbers().alter_curves(fd)

        self.assertTrue(
            'a cell in curves is either NaN, +infinite or -infinite!' in
            context.exception.args)