MCPcopy
hub / github.com/pydata/xarray / test_tz_datetime

Method test_tz_datetime

xarray/tests/test_variable.py:2811–2828  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2809 assert expected.dtype == actual.dtype
2810
2811 def test_tz_datetime(self) -> None:
2812 tz = pytz.timezone("America/New_York")
2813 times_ns = pd.date_range("2000", periods=1, tz=tz)
2814
2815 times_s = times_ns.astype(pd.DatetimeTZDtype("s", tz)) # type: ignore[arg-type]
2816 with warnings.catch_warnings():
2817 warnings.simplefilter("ignore")
2818 actual: T_DuckArray = as_compatible_data(times_s)
2819 assert actual.array == times_s
2820 assert actual.array.dtype == pd.DatetimeTZDtype("s", tz) # type: ignore[arg-type]
2821
2822 series = pd.Series(times_s)
2823 with warnings.catch_warnings():
2824 warnings.simplefilter("ignore")
2825 actual2: T_DuckArray = as_compatible_data(series)
2826
2827 np.testing.assert_array_equal(actual2, np.asarray(series.values))
2828 assert actual2.dtype == np.dtype("datetime64[s]")
2829
2830 def test_full_like(self) -> None:
2831 # For more thorough tests, see test_variable.py

Callers

nothing calls this directly

Calls 3

as_compatible_dataFunction · 0.90
astypeMethod · 0.45
dtypeMethod · 0.45

Tested by

no test coverage detected