Skip to content

Commit

Permalink
CLN: Move period.pyx to tslibs/period.pyx (#18555)
Browse files Browse the repository at this point in the history
  • Loading branch information
AaronCritchley authored and jreback committed Dec 3, 2017
1 parent 8172565 commit dc5403f
Show file tree
Hide file tree
Showing 14 changed files with 40 additions and 37 deletions.
3 changes: 2 additions & 1 deletion pandas/_libs/index.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ from tslibs.conversion cimport maybe_datetimelike_to_i8

from hashtable cimport HashTable

from pandas._libs import algos, period as periodlib, hashtable as _hash
from pandas._libs import algos, hashtable as _hash
from pandas._libs.tslibs import period as periodlib
from pandas._libs.tslib import Timestamp, Timedelta
from datetime import datetime, timedelta, date

Expand Down
29 changes: 13 additions & 16 deletions pandas/_libs/period.pyx → pandas/_libs/tslibs/period.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,23 @@ from cpython.datetime cimport PyDateTime_Check, PyDateTime_IMPORT
# import datetime C API
PyDateTime_IMPORT

from tslibs.np_datetime cimport (pandas_datetimestruct,
dtstruct_to_dt64, dt64_to_dtstruct,
is_leapyear)

from np_datetime cimport (pandas_datetimestruct, dtstruct_to_dt64,
dt64_to_dtstruct, is_leapyear)

cimport util
from util cimport is_period_object, is_string_object, INT32_MIN

from missing cimport is_null_datetimelike
from pandas._libs.tslib import Timestamp
from tslibs.timezones cimport (
is_utc, is_tzlocal, get_utcoffset, get_dst_info)
from tslibs.timedeltas cimport delta_to_nanoseconds

from tslibs.parsing import (parse_time_string, NAT_SENTINEL,
_get_rule_month, _MONTH_NUMBERS)
from tslibs.frequencies cimport get_freq_code
from tslibs.resolution import resolution, Resolution
from tslibs.nattype import nat_strings, NaT, iNaT
from tslibs.nattype cimport _nat_scalar_rules, NPY_NAT
from pandas._libs.missing cimport is_null_datetimelike
from timestamps import Timestamp
from timezones cimport is_utc, is_tzlocal, get_utcoffset, get_dst_info
from timedeltas cimport delta_to_nanoseconds

from parsing import (parse_time_string, NAT_SENTINEL,
_get_rule_month, _MONTH_NUMBERS)
from frequencies cimport get_freq_code
from resolution import resolution, Resolution
from nattype import nat_strings, NaT, iNaT
from nattype cimport _nat_scalar_rules, NPY_NAT

from pandas.tseries import offsets
from pandas.tseries import frequencies
Expand Down
6 changes: 5 additions & 1 deletion pandas/compat/pickle_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,11 @@ def load_reduce(self):
('pandas._libs.sparse', 'BlockIndex'),
('pandas.tslib', 'Timestamp'):
('pandas._libs.tslib', 'Timestamp'),
('pandas._period', 'Period'): ('pandas._libs.period', 'Period'),

# 18543 moving period
('pandas._period', 'Period'): ('pandas._libs.tslibs.period', 'Period'),
('pandas._libs.period', 'Period'):
('pandas._libs.tslibs.period', 'Period'),

# 18014 moved __nat_unpickle from _libs.tslib-->_libs.tslibs.nattype
('pandas.tslib', '__nat_unpickle'):
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/indexes/accessors.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from pandas.core.accessor import PandasDelegate
from pandas.core.base import NoNewAttributesMixin, PandasObject
from pandas.core.indexes.datetimes import DatetimeIndex
from pandas._libs.period import IncompatibleFrequency # noqa
from pandas._libs.tslibs.period import IncompatibleFrequency # noqa
from pandas.core.indexes.period import PeriodIndex
from pandas.core.indexes.timedeltas import TimedeltaIndex
from pandas.core.algorithms import take_1d
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/indexes/datetimelike.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

import pandas.io.formats.printing as printing
from pandas._libs import lib, iNaT, NaT
from pandas._libs.period import Period
from pandas._libs.tslibs.period import Period
from pandas._libs.tslibs.timedeltas import delta_to_nanoseconds

from pandas.core.indexes.base import Index, _index_shared_docs
Expand Down
5 changes: 3 additions & 2 deletions pandas/core/indexes/datetimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,9 @@

from pandas._libs import (lib, index as libindex, tslib as libts,
algos as libalgos, join as libjoin,
Timestamp, period as libperiod)
from pandas._libs.tslibs import timezones, conversion, fields
Timestamp)
from pandas._libs.tslibs import (timezones, conversion, fields,
period as libperiod)

# -------- some conversion wrapper functions

Expand Down
10 changes: 5 additions & 5 deletions pandas/core/indexes/period.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@
import pandas.tseries.offsets as offsets

from pandas._libs.lib import infer_dtype
from pandas._libs import tslib, period, index as libindex
from pandas._libs.period import (Period, IncompatibleFrequency,
get_period_field_arr, _validate_end_alias,
_quarter_to_myear)
from pandas._libs import tslib, index as libindex
from pandas._libs.tslibs.period import (Period, IncompatibleFrequency,
get_period_field_arr,
_validate_end_alias, _quarter_to_myear)
from pandas._libs.tslibs.fields import isleapyear_arr
from pandas._libs.tslibs import resolution
from pandas._libs.tslibs import resolution, period
from pandas._libs.tslibs.timedeltas import delta_to_nanoseconds

from pandas.core.base import _shared_docs
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/resample.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

from pandas._libs import lib, tslib
from pandas._libs.lib import Timestamp
from pandas._libs.period import IncompatibleFrequency
from pandas._libs.tslibs.period import IncompatibleFrequency

from pandas.util._decorators import Appender
from pandas.core.generic import _shared_docs
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/indexes/period/test_indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from pandas._libs import tslib, tslibs
from pandas import (PeriodIndex, Series, DatetimeIndex,
period_range, Period)
from pandas._libs import period as libperiod
from pandas._libs.tslibs import period as libperiod


class TestGetItem(object):
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/indexes/period/test_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import pandas.core.indexes.period as period
from pandas.compat import lrange
from pandas.tseries.frequencies import get_freq, MONTHS
from pandas._libs.period import period_ordinal, period_asfreq
from pandas._libs.tslibs.period import period_ordinal, period_asfreq
from pandas import (PeriodIndex, Period, DatetimeIndex, Timestamp, Series,
date_range, to_datetime, period_range)

Expand Down
3 changes: 2 additions & 1 deletion pandas/tests/scalar/test_period.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
from pandas.compat import text_type, iteritems
from pandas.compat.numpy import np_datetime64_compat

from pandas._libs import tslib, period as libperiod
from pandas._libs import tslib
from pandas._libs.tslibs import period as libperiod
from pandas._libs.tslibs.parsing import DateParseError
from pandas import Period, Timestamp, offsets
from pandas._libs.tslibs.resolution import DAYS, _MONTHS as MONTHS
Expand Down
3 changes: 1 addition & 2 deletions pandas/tests/scalar/test_timestamp.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@

import pandas.util.testing as tm
from pandas.tseries import offsets, frequencies
from pandas._libs import period
from pandas._libs.tslibs.timezones import get_timezone
from pandas._libs.tslibs import conversion
from pandas._libs.tslibs import conversion, period

from pandas.compat import long, PY3
from pandas.util.testing import assert_series_equal
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/test_resample.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
from pandas.core.indexes.timedeltas import timedelta_range, TimedeltaIndex
from pandas.util.testing import (assert_series_equal, assert_almost_equal,
assert_frame_equal, assert_index_equal)
from pandas._libs.period import IncompatibleFrequency
from pandas._libs.tslibs.period import IncompatibleFrequency

bday = BDay()

Expand Down
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,6 @@ class CheckSDist(sdist_class):
_pyxfiles = ['pandas/_libs/lib.pyx',
'pandas/_libs/hashtable.pyx',
'pandas/_libs/tslib.pyx',
'pandas/_libs/period.pyx',
'pandas/_libs/index.pyx',
'pandas/_libs/algos.pyx',
'pandas/_libs/join.pyx',
Expand All @@ -344,6 +343,7 @@ class CheckSDist(sdist_class):
'pandas/_libs/skiplist.pyx',
'pandas/_libs/sparse.pyx',
'pandas/_libs/parsers.pyx',
'pandas/_libs/tslibs/period.pyx',
'pandas/_libs/tslibs/strptime.pyx',
'pandas/_libs/tslibs/np_datetime.pyx',
'pandas/_libs/tslibs/timedeltas.pyx',
Expand Down Expand Up @@ -530,8 +530,8 @@ def pxd(name):
'pandas/_libs/src/numpy_helper.h'],
'sources': ['pandas/_libs/src/parser/tokenizer.c',
'pandas/_libs/src/parser/io.c']},
'_libs.period': {
'pyxfile': '_libs/period',
'_libs.tslibs.period': {
'pyxfile': '_libs/tslibs/period',
'pxdfiles': ['_libs/src/util',
'_libs/lib',
'_libs/tslibs/timedeltas',
Expand Down

0 comments on commit dc5403f

Please sign in to comment.