forked from pandas-dev/pandas
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7e68183
commit 70a5b34
Showing
8 changed files
with
59 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import numpy as np | ||
|
||
from pandas._libs.tslibs.dtypes import abbrev_to_npy_unit | ||
from pandas._libs.tslibs.vectorized import is_date_array_normalized | ||
|
||
# a datetime64 ndarray which *is* normalized | ||
day_arr = np.arange(10, dtype="i8").view("M8[D]") | ||
|
||
|
||
class TestIsDateArrayNormalized: | ||
def test_is_date_array_normalized_day(self): | ||
arr = day_arr | ||
abbrev = "D" | ||
unit = abbrev_to_npy_unit(abbrev) | ||
result = is_date_array_normalized(arr.view("i8"), None, unit) | ||
assert result is True | ||
|
||
def test_is_date_array_normalized_seconds(self): | ||
abbrev = "s" | ||
arr = day_arr.astype(f"M8[{abbrev}]") | ||
unit = abbrev_to_npy_unit(abbrev) | ||
result = is_date_array_normalized(arr.view("i8"), None, unit) | ||
assert result is True | ||
|
||
arr[0] += np.timedelta64(1, abbrev) | ||
result2 = is_date_array_normalized(arr.view("i8"), None, unit) | ||
assert result2 is False |