Beispiel #1
0
    def test_convert_sql_column_bools(self):
        arr = np.array([True, False, True, False], dtype="O")
        result = lib.convert_sql_column(arr)
        expected = np.array([True, False, True, False], dtype=bool)
        self.assert_numpy_array_equal(result, expected)

        arr = np.array([True, False, None, False], dtype="O")
        result = lib.convert_sql_column(arr)
        expected = np.array([True, False, np.nan, False], dtype=object)
        self.assert_numpy_array_equal(result, expected)
Beispiel #2
0
    def test_convert_sql_column_bools(self):
        arr = np.array([True, False, True, False], dtype='O')
        result = lib.convert_sql_column(arr)
        expected = np.array([True, False, True, False], dtype=bool)
        self.assert_numpy_array_equal(result, expected)

        arr = np.array([True, False, None, False], dtype='O')
        result = lib.convert_sql_column(arr)
        expected = np.array([True, False, np.nan, False], dtype=object)
        self.assert_numpy_array_equal(result, expected)
Beispiel #3
0
    def test_convert_sql_column_longs(self):
        arr = np.array([long(1), long(2), long(3), long(4)], dtype="O")
        result = lib.convert_sql_column(arr)
        expected = np.array([1, 2, 3, 4], dtype="i8")
        self.assert_numpy_array_equal(result, expected)

        arr = np.array([long(1), long(2), long(3), None, long(4)], dtype="O")
        result = lib.convert_sql_column(arr)
        expected = np.array([1, 2, 3, np.nan, 4], dtype="f8")
        self.assert_numpy_array_equal(result, expected)
    def test_convert_sql_column_longs(self):
        arr = np.array([long(1), long(2), long(3), long(4)], dtype='O')
        result = lib.convert_sql_column(arr)
        expected = np.array([1, 2, 3, 4], dtype='i8')
        _assert_same_values_and_dtype(result, expected)

        arr = np.array([long(1), long(2), long(3), None, long(4)], dtype='O')
        result = lib.convert_sql_column(arr)
        expected = np.array([1, 2, 3, np.nan, 4], dtype='f8')
        _assert_same_values_and_dtype(result, expected)
Beispiel #5
0
    def test_convert_sql_column_bools(self):
        arr = np.array([True, False, True, False], dtype='O')
        result = lib.convert_sql_column(arr)
        expected = np.array([True, False, True, False], dtype=bool)
        assert_same_values_and_dtype(result, expected)

        arr = np.array([True, False, None, False], dtype='O')
        result = lib.convert_sql_column(arr)
        expected = np.array([True, False, np.nan, False], dtype=object)
        assert_same_values_and_dtype(result, expected)
Beispiel #6
0
    def test_convert_sql_column_longs(self):
        arr = np.array([1L, 2L, 3L, 4L], dtype='O')
        result = lib.convert_sql_column(arr)
        expected = np.array([1, 2, 3, 4], dtype='i8')
        assert_same_values_and_dtype(result, expected)

        arr = np.array([1L, 2L, 3L, None, 4L], dtype='O')
        result = lib.convert_sql_column(arr)
        expected = np.array([1, 2, 3, np.nan, 4], dtype='f8')
        assert_same_values_and_dtype(result, expected)
    def test_convert_sql_column_longs(self):
        arr = np.array([long(1), long(2), long(3), long(4)], dtype='O')
        result = lib.convert_sql_column(arr)
        expected = np.array([1, 2, 3, 4], dtype='i8')
        _assert_same_values_and_dtype(result, expected)

        arr = np.array([long(1), long(2), long(3), None, long(4)], dtype='O')
        result = lib.convert_sql_column(arr)
        expected = np.array([1, 2, 3, np.nan, 4], dtype='f8')
        _assert_same_values_and_dtype(result, expected)
    def test_convert_sql_column_bools(self):
        arr = np.array([True, False, True, False], dtype='O')
        result = lib.convert_sql_column(arr)
        expected = np.array([True, False, True, False], dtype=bool)
        _assert_same_values_and_dtype(result, expected)

        arr = np.array([True, False, None, False], dtype='O')
        result = lib.convert_sql_column(arr)
        expected = np.array([True, False, np.nan, False], dtype=object)
        _assert_same_values_and_dtype(result, expected)
Beispiel #9
0
    def test_convert_sql_column_longs(self):
        arr = np.array([1L, 2L, 3L, 4L], dtype='O')
        result = lib.convert_sql_column(arr)
        expected = np.array([1, 2, 3, 4], dtype='i8')
        assert_same_values_and_dtype(result, expected)

        arr = np.array([1L, 2L, 3L, None, 4L], dtype='O')
        result = lib.convert_sql_column(arr)
        expected = np.array([1, 2, 3, np.nan, 4], dtype='f8')
        assert_same_values_and_dtype(result, expected)
Beispiel #10
0
    def test_convert_sql_column_longs(self):
        arr = np.array([long(1), long(2), long(3), long(4)], dtype='O')
        result = lib.convert_sql_column(arr)
        expected = np.array([1, 2, 3, 4], dtype='i8')
        self.assert_numpy_array_equal(result, expected)

        arr = np.array([long(1), long(2), long(3), None, long(4)], dtype='O')
        result = lib.convert_sql_column(arr)
        expected = np.array([1, 2, 3, np.nan, 4], dtype='f8')
        self.assert_numpy_array_equal(result, expected)
    def test_convert_sql_column_ints(self):
        arr = np.array([1, 2, 3, 4], dtype='O')
        arr2 = np.array([1, 2, 3, 4], dtype='i4').astype('O')
        result = lib.convert_sql_column(arr)
        result2 = lib.convert_sql_column(arr2)
        expected = np.array([1, 2, 3, 4], dtype='i8')
        _assert_same_values_and_dtype(result, expected)
        _assert_same_values_and_dtype(result2, expected)

        arr = np.array([1, 2, 3, None, 4], dtype='O')
        result = lib.convert_sql_column(arr)
        expected = np.array([1, 2, 3, np.nan, 4], dtype='f8')
        _assert_same_values_and_dtype(result, expected)
Beispiel #12
0
    def test_convert_sql_column_ints(self):
        arr = np.array([1, 2, 3, 4], dtype='O')
        arr2 = np.array([1, 2, 3, 4], dtype='i4').astype('O')
        result = lib.convert_sql_column(arr)
        result2 = lib.convert_sql_column(arr2)
        expected = np.array([1, 2, 3, 4], dtype='i8')
        self.assert_numpy_array_equal(result, expected)
        self.assert_numpy_array_equal(result2, expected)

        arr = np.array([1, 2, 3, None, 4], dtype='O')
        result = lib.convert_sql_column(arr)
        expected = np.array([1, 2, 3, np.nan, 4], dtype='f8')
        self.assert_numpy_array_equal(result, expected)
Beispiel #13
0
    def test_convert_sql_column_ints(self):
        arr = np.array([1, 2, 3, 4], dtype="O")
        arr2 = np.array([1, 2, 3, 4], dtype="i4").astype("O")
        result = lib.convert_sql_column(arr)
        result2 = lib.convert_sql_column(arr2)
        expected = np.array([1, 2, 3, 4], dtype="i8")
        self.assert_numpy_array_equal(result, expected)
        self.assert_numpy_array_equal(result2, expected)

        arr = np.array([1, 2, 3, None, 4], dtype="O")
        result = lib.convert_sql_column(arr)
        expected = np.array([1, 2, 3, np.nan, 4], dtype="f8")
        self.assert_numpy_array_equal(result, expected)
Beispiel #14
0
    def test_convert_sql_column_ints(self):
        arr = np.array([1, 2, 3, 4], dtype='O')
        arr2 = np.array([1, 2, 3, 4], dtype='i4').astype('O')
        result = lib.convert_sql_column(arr)
        result2 = lib.convert_sql_column(arr2)
        expected = np.array([1, 2, 3, 4], dtype='i8')
        self.assert_numpy_array_equal(result, expected)
        self.assert_numpy_array_equal(result2, expected)

        arr = np.array([1, 2, 3, None, 4], dtype='O')
        result = lib.convert_sql_column(arr)
        expected = np.array([1, 2, 3, np.nan, 4], dtype='f8')
        self.assert_numpy_array_equal(result, expected)
Beispiel #15
0
    def test_convert_sql_column_ints(self):
        arr = np.array([1, 2, 3, 4], dtype='O')
        arr2 = np.array([1, 2, 3, 4], dtype='i4').astype('O')
        result = lib.convert_sql_column(arr)
        result2 = lib.convert_sql_column(arr2)
        expected = np.array([1, 2, 3, 4], dtype='i8')
        assert_same_values_and_dtype(result, expected)
        assert_same_values_and_dtype(result2, expected)

        arr = np.array([1, 2, 3, None, 4], dtype='O')
        result = lib.convert_sql_column(arr)
        expected = np.array([1, 2, 3, np.nan, 4], dtype='f8')
        assert_same_values_and_dtype(result, expected)
Beispiel #16
0
 def test_convert_sql_column_unicode(self):
     arr = np.array([u('1.5'), None, u('3'), u('4.2')],
                    dtype=object)
     result = lib.convert_sql_column(arr)
     expected = np.array([u('1.5'), np.nan, u('3'), u('4.2')],
                         dtype=object)
     self.assert_numpy_array_equal(result, expected)
Beispiel #17
0
    def test_convert_sql_column_decimals(self):
        from decimal import Decimal

        arr = np.array([Decimal("1.5"), None, Decimal("3"), Decimal("4.2")])
        result = lib.convert_sql_column(arr)
        expected = np.array([1.5, np.nan, 3, 4.2], dtype="f8")
        self.assert_numpy_array_equal(result, expected)
Beispiel #18
0
 def test_convert_sql_column_unicode(self):
     arr = np.array([u('1.5'), None, u('3'), u('4.2')],
                    dtype=object)
     result = lib.convert_sql_column(arr)
     expected = np.array([u('1.5'), np.nan, u('3'), u('4.2')],
                         dtype=object)
     self.assert_numpy_array_equal(result, expected)
Beispiel #19
0
 def test_convert_sql_column_unicode(self):
     arr = np.array([u('1.5'), None, u('3'), u('4.2')],
                    dtype=object)
     result = lib.convert_sql_column(arr)
     expected = np.array([u('1.5'), np.nan, u('3'), u('4.2')],
                         dtype=object)
     _assert_same_values_and_dtype(result, expected)
 def test_convert_sql_column_decimals(self):
     from decimal import Decimal
     arr = np.array([Decimal('1.5'), None, Decimal('3'), Decimal('4.2')])
     result = lib.convert_sql_column(arr)
     expected = np.array([1.5, np.nan, 3, 4.2], dtype='f8')
     _assert_same_values_and_dtype(result, expected)
Beispiel #21
0
 def test_convert_sql_column_decimals(self):
     from decimal import Decimal
     arr = np.array([Decimal('1.5'), None, Decimal('3'), Decimal('4.2')])
     result = lib.convert_sql_column(arr)
     expected = np.array([1.5, np.nan, 3, 4.2], dtype='f8')
     self.assert_numpy_array_equal(result, expected)
Beispiel #22
0
 def test_convert_sql_column_strings(self):
     arr = np.array(['1.5', None, '3', '4.2'], dtype=object)
     result = lib.convert_sql_column(arr)
     expected = np.array(['1.5', np.nan, '3', '4.2'], dtype=object)
     self.assert_numpy_array_equal(result, expected)
 def test_convert_sql_column_unicode(self):
     arr = np.array([u('1.5'), None, u('3'), u('4.2')], dtype=object)
     result = lib.convert_sql_column(arr)
     expected = np.array([u('1.5'), np.nan, u('3'), u('4.2')], dtype=object)
     _assert_same_values_and_dtype(result, expected)
Beispiel #24
0
 def test_convert_sql_column_floats(self):
     arr = np.array([1.5, None, 3, 4.2], dtype=object)
     result = lib.convert_sql_column(arr)
     expected = np.array([1.5, np.nan, 3, 4.2], dtype="f8")
     self.assert_numpy_array_equal(result, expected)
 def test_convert_sql_column_floats(self):
     arr = np.array([1.5, None, 3, 4.2], dtype=object)
     result = lib.convert_sql_column(arr)
     expected = np.array([1.5, np.nan, 3, 4.2], dtype='f8')
     _assert_same_values_and_dtype(result, expected)
 def test_convert_sql_column_strings(self):
     arr = np.array(['1.5', None, '3', '4.2'], dtype=object)
     result = lib.convert_sql_column(arr)
     expected = np.array(['1.5', np.nan, '3', '4.2'], dtype=object)
     _assert_same_values_and_dtype(result, expected)
Beispiel #27
0
 def test_convert_sql_column_strings(self):
     arr = np.array(["1.5", None, "3", "4.2"], dtype=object)
     result = lib.convert_sql_column(arr)
     expected = np.array(["1.5", np.nan, "3", "4.2"], dtype=object)
     self.assert_numpy_array_equal(result, expected)
Beispiel #28
0
 def test_convert_sql_column_decimals(self):
     from decimal import Decimal
     arr = np.array([Decimal('1.5'), None, Decimal('3'), Decimal('4.2')])
     result = lib.convert_sql_column(arr)
     expected = np.array([1.5, np.nan, 3, 4.2], dtype='f8')
     assert_same_values_and_dtype(result, expected)
Beispiel #29
0
 def test_convert_sql_column_floats(self):
     arr = np.array([1.5, None, 3, 4.2], dtype=object)
     result = lib.convert_sql_column(arr)
     expected = np.array([1.5, np.nan, 3, 4.2], dtype='f8')
     self.assert_numpy_array_equal(result, expected)
Beispiel #30
0
 def test_convert_sql_column_strings(self):
     arr = np.array(['1.5', None, '3', '4.2'], dtype=object)
     result = lib.convert_sql_column(arr)
     expected = np.array(['1.5', np.nan, '3', '4.2'], dtype=object)
     self.assert_numpy_array_equal(result, expected)
Beispiel #31
0
 def test_convert_sql_column_strings(self):
     arr = np.array(['1.5', None, '3', '4.2'], dtype=object)
     result = lib.convert_sql_column(arr)
     expected = np.array(['1.5', np.nan, '3', '4.2'], dtype=object)
     assert_same_values_and_dtype(result, expected)
Beispiel #32
0
 def test_convert_sql_column_floats(self):
     arr = np.array([1.5, None, 3, 4.2], dtype=object)
     result = lib.convert_sql_column(arr)
     expected = np.array([1.5, np.nan, 3, 4.2], dtype='f8')
     assert_same_values_and_dtype(result, expected)
Beispiel #33
0
 def test_convert_sql_column_decimals(self):
     from decimal import Decimal
     arr = np.array([Decimal('1.5'), None, Decimal('3'), Decimal('4.2')])
     result = lib.convert_sql_column(arr)
     expected = np.array([1.5, np.nan, 3, 4.2], dtype='f8')
     self.assert_numpy_array_equal(result, expected)