|
2 | 2 | import pytest
|
3 | 3 |
|
4 | 4 | import pytz
|
5 |
| -import dateutil |
6 |
| -import numpy as np |
7 | 5 |
|
8 | 6 | from datetime import datetime
|
9 | 7 |
|
10 |
| -import pandas.util.testing as tm |
11 |
| -from pandas.core.indexes.datetimes import date_range |
12 |
| -from pandas._libs import tslib |
13 |
| -from pandas._libs.tslibs import timezones, conversion |
| 8 | +from pandas._libs.tslibs import timezones |
14 | 9 | from pandas import Timestamp
|
15 | 10 |
|
16 | 11 |
|
@@ -111,82 +106,3 @@ def localize(self, tz, x):
|
111 | 106 | def normalize(self, ts):
|
112 | 107 | # no-op for dateutil
|
113 | 108 | return ts
|
114 |
| - |
115 |
| - def test_tzlocal(self): |
116 |
| - # GH 13583 |
117 |
| - ts = Timestamp('2011-01-01', tz=dateutil.tz.tzlocal()) |
118 |
| - assert ts.tz == dateutil.tz.tzlocal() |
119 |
| - assert "tz='tzlocal()')" in repr(ts) |
120 |
| - |
121 |
| - tz = timezones.maybe_get_tz('tzlocal()') |
122 |
| - assert tz == dateutil.tz.tzlocal() |
123 |
| - |
124 |
| - # get offset using normal datetime for test |
125 |
| - offset = dateutil.tz.tzlocal().utcoffset(datetime(2011, 1, 1)) |
126 |
| - offset = offset.total_seconds() * 1000000000 |
127 |
| - assert ts.value + offset == Timestamp('2011-01-01').value |
128 |
| - |
129 |
| - |
130 |
| -class TestTimeZoneCacheKey(object): |
131 |
| - |
132 |
| - @pytest.mark.parametrize('tz_name', list(pytz.common_timezones)) |
133 |
| - def test_cache_keys_are_distinct_for_pytz_vs_dateutil(self, tz_name): |
134 |
| - if tz_name == 'UTC': |
135 |
| - # skip utc as it's a special case in dateutil |
136 |
| - return |
137 |
| - tz_p = timezones.maybe_get_tz(tz_name) |
138 |
| - tz_d = timezones.maybe_get_tz('dateutil/' + tz_name) |
139 |
| - if tz_d is None: |
140 |
| - # skip timezones that dateutil doesn't know about. |
141 |
| - return |
142 |
| - assert (timezones._p_tz_cache_key(tz_p) != |
143 |
| - timezones._p_tz_cache_key(tz_d)) |
144 |
| - |
145 |
| - |
146 |
| -class TestTslib(object): |
147 |
| - |
148 |
| - def test_tslib_tz_convert(self): |
149 |
| - def compare_utc_to_local(tz_didx, utc_didx): |
150 |
| - f = lambda x: conversion.tz_convert_single(x, 'UTC', tz_didx.tz) |
151 |
| - result = conversion.tz_convert(tz_didx.asi8, 'UTC', tz_didx.tz) |
152 |
| - result_single = np.vectorize(f)(tz_didx.asi8) |
153 |
| - tm.assert_numpy_array_equal(result, result_single) |
154 |
| - |
155 |
| - def compare_local_to_utc(tz_didx, utc_didx): |
156 |
| - f = lambda x: conversion.tz_convert_single(x, tz_didx.tz, 'UTC') |
157 |
| - result = conversion.tz_convert(utc_didx.asi8, tz_didx.tz, 'UTC') |
158 |
| - result_single = np.vectorize(f)(utc_didx.asi8) |
159 |
| - tm.assert_numpy_array_equal(result, result_single) |
160 |
| - |
161 |
| - for tz in ['UTC', 'Asia/Tokyo', 'US/Eastern', 'Europe/Moscow']: |
162 |
| - # US: 2014-03-09 - 2014-11-11 |
163 |
| - # MOSCOW: 2014-10-26 / 2014-12-31 |
164 |
| - tz_didx = date_range('2014-03-01', '2015-01-10', freq='H', tz=tz) |
165 |
| - utc_didx = date_range('2014-03-01', '2015-01-10', freq='H') |
166 |
| - compare_utc_to_local(tz_didx, utc_didx) |
167 |
| - # local tz to UTC can be differ in hourly (or higher) freqs because |
168 |
| - # of DST |
169 |
| - compare_local_to_utc(tz_didx, utc_didx) |
170 |
| - |
171 |
| - tz_didx = date_range('2000-01-01', '2020-01-01', freq='D', tz=tz) |
172 |
| - utc_didx = date_range('2000-01-01', '2020-01-01', freq='D') |
173 |
| - compare_utc_to_local(tz_didx, utc_didx) |
174 |
| - compare_local_to_utc(tz_didx, utc_didx) |
175 |
| - |
176 |
| - tz_didx = date_range('2000-01-01', '2100-01-01', freq='A', tz=tz) |
177 |
| - utc_didx = date_range('2000-01-01', '2100-01-01', freq='A') |
178 |
| - compare_utc_to_local(tz_didx, utc_didx) |
179 |
| - compare_local_to_utc(tz_didx, utc_didx) |
180 |
| - |
181 |
| - # Check empty array |
182 |
| - result = conversion.tz_convert(np.array([], dtype=np.int64), |
183 |
| - timezones.maybe_get_tz('US/Eastern'), |
184 |
| - timezones.maybe_get_tz('Asia/Tokyo')) |
185 |
| - tm.assert_numpy_array_equal(result, np.array([], dtype=np.int64)) |
186 |
| - |
187 |
| - # Check all-NaT array |
188 |
| - result = conversion.tz_convert(np.array([tslib.iNaT], dtype=np.int64), |
189 |
| - timezones.maybe_get_tz('US/Eastern'), |
190 |
| - timezones.maybe_get_tz('Asia/Tokyo')) |
191 |
| - tm.assert_numpy_array_equal(result, np.array( |
192 |
| - [tslib.iNaT], dtype=np.int64)) |
0 commit comments