Ejemplo n.º 1
0
    def testBreakingCases(self):
        """
        Testing some cases observed to fail previously
        """

        tab1, tab2, tab3 = None, None, None
        with self.subTest(msg="charCol with list"):
            tab1 = TableTools.newTable(
                TableTools.charCol('tab1', ['A', 'B', 'C', 'D']))
            print("tab1 = \n{}".format(TableTools.html(tab1)))

        with self.subTest(msg="charCol with string"):
            tab2 = TableTools.newTable(TableTools.charCol('tab2', 'EFGH'))
            print("tab2 = \n{}".format(TableTools.html(tab2)))

        with self.subTest(msg="col with single string"):
            tab3 = TableTools.newTable(TableTools.col('tab3', 'EFGH'))
            print("tab3 = \n{}".format(TableTools.html(tab3)))
        del tab1, tab2, tab3
Ejemplo n.º 2
0
chp = plt.catHistPlot("S1", t, "X").show()

hp = plt.histPlot("S1", t, "X", 5).show()
hp = plt.histPlot("S1", t, "X", 0, 10, 5).show()

ep = plt.errorBarXY("S1", t, "X", "XLow", "XHigh", "Y", "YLow", "YHigh").show()
epBy = plt.errorBarXYBy("S1", t, "X", "XLow", "XHigh", "Y", "YLow", "YHigh",
                        "USym").show()
ep2 = plt.errorBarX("S1", t, "X", "XLow", "XHigh", "Y").show()
epBy2 = plt.errorBarXBy("S1", t, "X", "XLow", "XHigh", "Y", "USym").show()
ep3 = plt.errorBarY("S1", t, "X", "Y", "YLow", "YHigh").show()
epBy3 = plt.errorBarYBy("S1", t, "X", "Y", "YLow", "YHigh", "USym").show()

doubles = [3, 4, 3, 5, 4, 5]
time = 1491946585000000000
t = tt.newTable(tt.col("USym", ["A", "B", "A", "B", "A", "B"]),
                tt.doubleCol("Open", doubles), tt.doubleCol("High", doubles),
                tt.doubleCol("Low", doubles), tt.doubleCol("Close", doubles))

t = t.updateView("Time = new DateTime(time + (MINUTE * i))")

ohlc = plt.ohlcPlot("Test1", t, "Time", "Open", "High", "Low", "Close")

ohlcPlotBy = plt.figure().newChart(0)\
    .chartTitle("Chart Title")\
    .newAxes()\
    .xLabel("X")\
    .yLabel("Y")\
    .ohlcPlotBy("Test1", t, "Time", "Open", "High", "Low", "Close", "USym")

categories = ["Samsung", "Others", "Nokia", "Apple", "MSFT"]
Ejemplo n.º 3
0
    def testPrimitiveColCases(self):
        """
        Testing column construction from primitive cases
        """

        with self.subTest(msg="col with bool"):
            col1 = TableTools.col('bool1', numpy.array([True],
                                                       dtype=numpy.bool))
            self.assertEqual(col1.dataType.toString(),
                             'class java.lang.Boolean')
            # print("table from bool = \n{}".format(TableTools.html(TableTools.newTable(col1))))

            col2 = TableTools.col('bool2', True, False, None)
            self.assertEqual(col2.dataType.toString(),
                             'class java.lang.Boolean')
            # print("table from bool varargs = \n{}".format(TableTools.html(TableTools.newTable(col2))))

        with self.subTest(msg="col with int"):
            col1 = TableTools.col('int1', 1)
            self.assertEqual(col1.dataType.toString(), 'long')
            # print("table from int = \n{}".format(TableTools.html(TableTools.newTable(col1))))

            col2 = TableTools.col('int2', 1, 2, None)
            self.assertEqual(col2.dataType.toString(), 'long')
            # print("table from int varargs = \n{}".format(TableTools.html(TableTools.newTable(col2))))

        with self.subTest(msg="col with float"):
            col1 = TableTools.col('float1', 1.0)
            self.assertEqual(col1.dataType.toString(), 'double')
            # print("table from float = \n{}".format(TableTools.html(TableTools.newTable(col1))))

            col2 = TableTools.col('float2', 1.0, 2.0, None)
            self.assertEqual(col2.dataType.toString(), 'double')
            # print("table from float varargs = \n{}".format(TableTools.html(TableTools.newTable(col2))))

        with self.subTest(msg="col with string"):
            col1 = TableTools.col('string1', 'one')
            self.assertEqual(col1.dataType.toString(),
                             'class java.lang.String')
            # print("table from string = \n{}".format(TableTools.html(TableTools.newTable(col1))))

            col2 = TableTools.col('string2', 'one', 'two', None)
            self.assertEqual(col2.dataType.toString(),
                             'class java.lang.String')
            # print("table from string varargs = \n{}".format(TableTools.html(TableTools.newTable(col2))))

        with self.subTest(msg="col with datetime"):
            col1 = TableTools.col('datetime1', datetime.utcnow())
            self.assertEqual(col1.dataType.toString(),
                             'class io.deephaven.db.tables.utils.DBDateTime')
            # print("table from string = \n{}".format(TableTools.html(TableTools.newTable(col1))))

            col2 = TableTools.col('datetime2', datetime.utcnow(),
                                  datetime.utcnow(), None)
            self.assertEqual(col2.dataType.toString(),
                             'class io.deephaven.db.tables.utils.DBDateTime')
            # print("table from datetime varargs = \n{}".format(TableTools.html(TableTools.newTable(col2))))

        with self.subTest(msg="col with date"):
            col1 = TableTools.col('date1', date.today())
            self.assertEqual(col1.dataType.toString(),
                             'class io.deephaven.db.tables.utils.DBDateTime')
            # print("table from string = \n{}".format(TableTools.html(TableTools.newTable(col1))))

            col2 = TableTools.col('date2', date.today(), date.today(), None)
            self.assertEqual(col2.dataType.toString(),
                             'class io.deephaven.db.tables.utils.DBDateTime')
            # print("table from date varargs = \n{}".format(TableTools.html(TableTools.newTable(col2))))

        with self.subTest(msg="col with no argument"):
            col1 = TableTools.col('empty', [])
            self.assertEqual(col1.dataType.toString(),
                             'class java.lang.Object')
Ejemplo n.º 4
0
    def testColumnHolder(self):
        """
        Test cases for <primitive>Col() methods & associated newTable() method
        """

        holders = []
        junk, tab = None, None
        with self.subTest(msg="byteCol"):
            holders.append(TableTools.byteCol("byteCol", self.nByteArray))
        with self.subTest(msg="shortCol"):
            holders.append(TableTools.shortCol("shortCol", self.nShortArray))
        with self.subTest(msg="intCol"):
            holders.append(TableTools.intCol("intCol", self.nIntArray))
        with self.subTest(msg="longCol"):
            holders.append(TableTools.longCol("longCol", self.nLongArray))
        with self.subTest(msg="floatCol"):
            holders.append(TableTools.floatCol("floatCol", self.floatList))
        with self.subTest(msg="doubleCol"):
            holders.append(TableTools.doubleCol("doubleCol",
                                                self.nDoubleArray))
        with self.subTest(msg="charCol"):
            holders.append(TableTools.charCol("charCol", self.nCharArray))

        with self.subTest(msg="newTable with column holders"):
            self.assertGreater(len(holders),
                               0)  # make sure that we even do something useful
            tab = TableTools.newTable(*holders)
            print("tab =\n{}".format(TableTools.html(tab)))
        del holders, tab

        holders = []
        with self.subTest(msg="byteCol with list"):
            holders.append(TableTools.byteCol("byteList", self.intList))
        with self.subTest(msg="shortCol with list"):
            holders.append(TableTools.shortCol("shortList", self.intList))
        with self.subTest(msg="intCol with list"):
            holders.append(TableTools.intCol("intList", self.intList))
        with self.subTest(msg="longCol with list"):
            holders.append(TableTools.longCol("longList", self.intList))
        with self.subTest(msg="floatCol with list"):
            holders.append(TableTools.doubleCol("floatList", self.floatList))
        with self.subTest(msg="doubleCol with list"):
            holders.append(TableTools.doubleCol("doubleList", self.floatList))
        with self.subTest(msg="charCol with list"):
            holders.append(TableTools.charCol("charList", self.charList))
        print('prim col from list = \n{}'.format(
            TableTools.html(TableTools.newTable(*holders))))
        del holders

        holders = []
        with self.subTest(msg="col with string array"):
            holders.append(TableTools.col("stringCol", self.nStringArray))
        with self.subTest(msg="col with boolean array"):
            holders.append(TableTools.col("booleanCol", self.nBooleanArray))
        with self.subTest(msg="col with time array"):
            holders.append(TableTools.col("timeCol", self.nTimeArray))
        print('obj col = \n{}'.format(
            TableTools.html(TableTools.newTable(*holders))))
        del holders

        holders = []
        with self.subTest(msg="col with int list"):
            holders.append(TableTools.col("intList2", self.intList))
        with self.subTest(msg="col with double list"):
            holders.append(TableTools.col("doubleList2", self.floatList))
        with self.subTest(msg="col with char list"):
            holders.append(TableTools.col("stringList", self.stringList))
        with self.subTest(msg="col with char list"):
            holders.append(TableTools.col("charList2", self.charList))
        with self.subTest(msg="col with boolean list"):
            holders.append(TableTools.col("booleanList", self.booleanList))
        with self.subTest(msg="col with time list"):
            holders.append(TableTools.col("timeList", self.timeList))
        print('col from list = \n{}'.format(
            TableTools.html(TableTools.newTable(*holders))))
        del holders

        holders = []
        with self.subTest(msg="col with byte"):
            holders.append(TableTools.col("byteCol", self.nByteArray))
        with self.subTest(msg="col with short"):
            holders.append(TableTools.col("shortCol", self.nShortArray))
        with self.subTest(msg="col with int"):
            holders.append(TableTools.col("intCol", self.nIntArray))
        with self.subTest(msg="col with long"):
            holders.append(TableTools.col("longCol", self.nLongArray))
        with self.subTest(msg="col with float"):
            holders.append(TableTools.col("floatCol", self.nFloatArray))
        with self.subTest(msg="col with double"):
            holders.append(TableTools.col("doubleCol", self.nDoubleArray))
        with self.subTest(msg="col with char"):
            holders.append(TableTools.col("charCol", self.nCharArray))
        print("primitive from col =\n{}".format(
            TableTools.html(TableTools.newTable(*holders))))
        del holders