def time_tz_convert_from_utc(self, size, tz): # effectively: # dti = DatetimeIndex(self.i8data, tz=tz) # dti.tz_localize(None) if old_sig: tz_convert_from_utc(self.i8data, UTC, tz) else: tz_convert_from_utc(self.i8data, tz)
def test_tz_localize_to_utc_copies(): # GH#46460 arr = np.arange(5, dtype="i8") result = tzconversion.tz_convert_from_utc(arr, tz=UTC) tm.assert_numpy_array_equal(result, arr) assert not np.shares_memory(arr, result) result = tzconversion.tz_convert_from_utc(arr, tz=None) tm.assert_numpy_array_equal(result, arr) assert not np.shares_memory(arr, result)
def time_tz_convert_from_utc(self, size, tz): # effectively: # dti = DatetimeIndex(self.i8data, tz=tz) # dti.tz_localize(None) if size >= 10**6 and str(tz) == "tzlocal()": # asv fill will because each call takes 8+seconds return if old_sig: tz_convert_from_utc(self.i8data, UTC, tz) else: tz_convert_from_utc(self.i8data, tz)
def __init__(self, index, warn: bool = True): self.index = index self.i8values = index.asi8 # This moves the values, which are implicitly in UTC, to the # the timezone so they are in local time if hasattr(index, "tz"): if index.tz is not None: self.i8values = tzconversion.tz_convert_from_utc( self.i8values, index.tz ) if warn is not True: warnings.warn( "warn is deprecated (and never implemented) and " "will be removed in a future version.", FutureWarning, stacklevel=3, ) self.warn = warn if len(index) < 3: raise ValueError("Need at least 3 dates to infer frequency") self.is_monotonic = ( self.index._is_monotonic_increasing or self.index._is_monotonic_decreasing )
def _compare_utc_to_local(tz_didx): def f(x): return tzconversion.tz_convert_from_utc_single(x, tz_didx.tz) result = tzconversion.tz_convert_from_utc(tz_didx.asi8, tz_didx.tz) expected = np.vectorize(f)(tz_didx.asi8) tm.assert_numpy_array_equal(result, expected)
def __init__(self, index, warn: bool = True): self.index = index self.i8values = index.asi8 # This moves the values, which are implicitly in UTC, to the # the timezone so they are in local time if hasattr(index, "tz"): if index.tz is not None: self.i8values = tzconversion.tz_convert_from_utc( self.i8values, index.tz) self.warn = warn if len(index) < 3: raise ValueError("Need at least 3 dates to infer frequency") self.is_monotonic = (self.index._is_monotonic_increasing or self.index._is_monotonic_decreasing)
def test_tz_convert_readonly(): # GH#35530 arr = np.array([0], dtype=np.int64) arr.setflags(write=False) result = tzconversion.tz_convert_from_utc(arr, UTC) tm.assert_numpy_array_equal(result, arr)
def test_tz_convert_corner(arr): result = tzconversion.tz_convert_from_utc( arr, timezones.maybe_get_tz("Asia/Tokyo")) tm.assert_numpy_array_equal(result, arr)