Пример #1
0
 def _add_datelike(self, other):
     # adding a timedeltaindex to a datetimelike
     from pandas import Timestamp, DatetimeIndex
     if other is tslib.NaT:
         result = self._nat_new(box=False)
     else:
         other = Timestamp(other)
         i8 = self.asi8
         result = _checked_add_with_arr(i8, other.value)
         result = self._maybe_mask_results(result, fill_value=tslib.iNaT)
     return DatetimeIndex(result, name=self.name, copy=False)
Пример #2
0
Файл: tdi.py Проект: Tux1/pandas
 def _add_datelike(self, other):
     # adding a timedeltaindex to a datetimelike
     from pandas import Timestamp, DatetimeIndex
     if other is tslib.NaT:
         result = self._nat_new(box=False)
     else:
         other = Timestamp(other)
         i8 = self.asi8
         result = _checked_add_with_arr(i8, other.value)
         result = self._maybe_mask_results(result, fill_value=tslib.iNaT)
     return DatetimeIndex(result, name=self.name, copy=False)
Пример #3
0
def test_int64_add_overflow():
    # see gh-14068
    msg = "too (big|large) to convert"
    m = np.iinfo(np.int64).max

    with tm.assertRaisesRegexp(OverflowError, msg):
        nanops._checked_add_with_arr(np.array([m, m]), m)
    with tm.assertRaisesRegexp(OverflowError, msg):
        nanops._checked_add_with_arr(np.array([m, m]), np.array([m, m]))
    with tm.assertRaisesRegexp(OverflowError, msg):
        with tm.assert_produces_warning(RuntimeWarning):
            nanops._checked_add_with_arr(np.array([m, m]),
                                         np.array([np.nan, m]))
Пример #4
0
def test_int64_add_overflow():
    # see gh-14068
    msg = "too (big|large) to convert"
    m = np.iinfo(np.int64).max

    with tm.assertRaisesRegexp(OverflowError, msg):
        nanops._checked_add_with_arr(np.array([m, m]), m)
    with tm.assertRaisesRegexp(OverflowError, msg):
        nanops._checked_add_with_arr(np.array([m, m]), np.array([m, m]))
    with tm.assertRaisesRegexp(OverflowError, msg):
        with tm.assert_produces_warning(RuntimeWarning):
            nanops._checked_add_with_arr(np.array([m, m]),
                                         np.array([np.nan, m]))
Пример #5
0
def test_int64_add_overflow():
    # see gh-14068
    msg = "Overflow in int64 addition"
    m = np.iinfo(np.int64).max
    n = np.iinfo(np.int64).min

    with tm.assertRaisesRegexp(OverflowError, msg):
        nanops._checked_add_with_arr(np.array([m, m]), m)
    with tm.assertRaisesRegexp(OverflowError, msg):
        nanops._checked_add_with_arr(np.array([m, m]), np.array([m, m]))
    with tm.assertRaisesRegexp(OverflowError, msg):
        nanops._checked_add_with_arr(np.array([n, n]), n)
    with tm.assertRaisesRegexp(OverflowError, msg):
        nanops._checked_add_with_arr(np.array([n, n]), np.array([n, n]))
    with tm.assertRaisesRegexp(OverflowError, msg):
        nanops._checked_add_with_arr(np.array([m, n]), np.array([n, n]))
    with tm.assertRaisesRegexp(OverflowError, msg):
        with tm.assert_produces_warning(RuntimeWarning):
            nanops._checked_add_with_arr(np.array([m, m]),
                                         np.array([np.nan, m]))
Пример #6
0
def test_int64_add_overflow():
    # see gh-14068
    msg = "Overflow in int64 addition"
    m = np.iinfo(np.int64).max
    n = np.iinfo(np.int64).min

    with tm.assertRaisesRegexp(OverflowError, msg):
        nanops._checked_add_with_arr(np.array([m, m]), m)
    with tm.assertRaisesRegexp(OverflowError, msg):
        nanops._checked_add_with_arr(np.array([m, m]), np.array([m, m]))
    with tm.assertRaisesRegexp(OverflowError, msg):
        nanops._checked_add_with_arr(np.array([n, n]), n)
    with tm.assertRaisesRegexp(OverflowError, msg):
        nanops._checked_add_with_arr(np.array([n, n]), np.array([n, n]))
    with tm.assertRaisesRegexp(OverflowError, msg):
        nanops._checked_add_with_arr(np.array([m, n]), np.array([n, n]))
    with tm.assertRaisesRegexp(OverflowError, msg):
        with tm.assert_produces_warning(RuntimeWarning):
            nanops._checked_add_with_arr(np.array([m, m]),
                                         np.array([np.nan, m]))