ktongue commited on
Commit
44527cf
·
verified ·
1 Parent(s): ffc2623

Upload hf_env/lib/python3.14/site-packages/pandas/tests/tslibs/test_npy_units.py with huggingface_hub

Browse files
hf_env/lib/python3.14/site-packages/pandas/tests/tslibs/test_npy_units.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import numpy as np
2
+
3
+ from pandas._libs.tslibs.dtypes import abbrev_to_npy_unit
4
+ from pandas._libs.tslibs.vectorized import is_date_array_normalized
5
+
6
+ # a datetime64 ndarray which *is* normalized
7
+ day_arr = np.arange(10, dtype="i8").view("M8[D]")
8
+
9
+
10
+ class TestIsDateArrayNormalized:
11
+ def test_is_date_array_normalized_day(self):
12
+ arr = day_arr
13
+ abbrev = "D"
14
+ unit = abbrev_to_npy_unit(abbrev)
15
+ result = is_date_array_normalized(arr.view("i8"), None, unit)
16
+ assert result is True
17
+
18
+ def test_is_date_array_normalized_seconds(self):
19
+ abbrev = "s"
20
+ arr = day_arr.astype(f"M8[{abbrev}]")
21
+ unit = abbrev_to_npy_unit(abbrev)
22
+ result = is_date_array_normalized(arr.view("i8"), None, unit)
23
+ assert result is True
24
+
25
+ arr[0] += np.timedelta64(1, abbrev)
26
+ result2 = is_date_array_normalized(arr.view("i8"), None, unit)
27
+ assert result2 is False