Skip to content

Commit 60e133d

Browse files
jbrockmendelvictor
authored and
victor
committed
1 parent d8fc11e commit 60e133d

File tree

4 files changed

+45
-4
lines changed

4 files changed

+45
-4
lines changed

pandas/_libs/tslibs/conversion.pyx

+5-1
Original file line numberDiff line numberDiff line change
@@ -1045,6 +1045,10 @@ def normalize_date(object dt):
10451045
Returns
10461046
-------
10471047
normalized : datetime.datetime or Timestamp
1048+
1049+
Raises
1050+
------
1051+
TypeError : if input is not datetime.date, datetime.datetime, or Timestamp
10481052
"""
10491053
if PyDateTime_Check(dt):
10501054
if not PyDateTime_CheckExact(dt):
@@ -1063,7 +1067,7 @@ def normalize_date(object dt):
10631067

10641068
@cython.wraparound(False)
10651069
@cython.boundscheck(False)
1066-
def date_normalize(ndarray[int64_t] stamps, tz=None):
1070+
def normalize_i8_timestamps(ndarray[int64_t] stamps, tz=None):
10671071
"""
10681072
Normalize each of the (nanosecond) timestamps in the given array by
10691073
rounding down to the beginning of the day (i.e. midnight). If `tz`

pandas/_libs/tslibs/timestamps.pyx

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ from util cimport (is_datetime64_object, is_timedelta64_object,
2121
INT64_MAX)
2222

2323
cimport ccalendar
24-
from conversion import tz_localize_to_utc, date_normalize
24+
from conversion import tz_localize_to_utc, normalize_i8_timestamps
2525
from conversion cimport (tz_convert_single, _TSObject,
2626
convert_to_tsobject, convert_datetime_to_tsobject)
2727
from fields import get_start_end_field, get_date_name_field
@@ -1083,7 +1083,7 @@ class Timestamp(_Timestamp):
10831083
Normalize Timestamp to midnight, preserving
10841084
tz information.
10851085
"""
1086-
normalized_value = date_normalize(
1086+
normalized_value = normalize_i8_timestamps(
10871087
np.array([self.value], dtype='i8'), tz=self.tz)[0]
10881088
return Timestamp(normalized_value).tz_localize(self.tz)
10891089

pandas/core/indexes/datetimes.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2002,7 +2002,7 @@ def normalize(self):
20022002
'2014-08-01 00:00:00+05:30'],
20032003
dtype='datetime64[ns, Asia/Calcutta]', freq=None)
20042004
"""
2005-
new_values = conversion.date_normalize(self.asi8, self.tz)
2005+
new_values = conversion.normalize_i8_timestamps(self.asi8, self.tz)
20062006
return DatetimeIndex(new_values,
20072007
freq='infer',
20082008
name=self.name).tz_localize(self.tz)

pandas/tests/tslibs/test_api.py

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# -*- coding: utf-8 -*-
2+
"""Tests that the tslibs API is locked down"""
3+
4+
from pandas._libs import tslibs
5+
6+
7+
def test_namespace():
8+
9+
submodules = ['ccalendar',
10+
'conversion',
11+
'fields',
12+
'frequencies',
13+
'nattype',
14+
'np_datetime',
15+
'offsets',
16+
'parsing',
17+
'period',
18+
'resolution',
19+
'strptime',
20+
'timedeltas',
21+
'timestamps',
22+
'timezones']
23+
24+
api = ['NaT',
25+
'iNaT',
26+
'OutOfBoundsDatetime',
27+
'Timedelta',
28+
'Timestamp',
29+
'delta_to_nanoseconds',
30+
'ints_to_pytimedelta',
31+
'localize_pydatetime',
32+
'normalize_date',
33+
'tz_convert_single']
34+
35+
expected = set(submodules + api)
36+
names = [x for x in dir(tslibs) if not x.startswith('__')]
37+
assert set(names) == expected

0 commit comments

Comments
 (0)