From d4d3b3379fb787a700ec9a6936ebec91e5ef7f18 Mon Sep 17 00:00:00 2001 From: jbrockmendel Date: Tue, 30 Jan 2018 15:55:19 -0800 Subject: [PATCH] remove unused (#19466) --- pandas/_libs/src/period_helper.c | 32 ------------------------------ pandas/_libs/src/period_helper.h | 10 ---------- pandas/_libs/tslibs/period.pyx | 9 --------- pandas/tests/scalar/test_period.py | 3 --- 4 files changed, 54 deletions(-) diff --git a/pandas/_libs/src/period_helper.c b/pandas/_libs/src/period_helper.c index 01fc46481d5b4..f1367978bd6c9 100644 --- a/pandas/_libs/src/period_helper.c +++ b/pandas/_libs/src/period_helper.c @@ -1275,38 +1275,6 @@ npy_int64 get_python_ordinal(npy_int64 period_ordinal, int freq) { return toDaily(period_ordinal, 'E', &af_info) + ORD_OFFSET; } -char *str_replace(const char *s, const char *old, const char *new) { - char *ret; - int i, count = 0; - size_t newlen = strlen(new); - size_t oldlen = strlen(old); - - for (i = 0; s[i] != '\0'; i++) { - if (strstr(&s[i], old) == &s[i]) { - count++; - i += oldlen - 1; - } - } - - ret = PyArray_malloc(i + 1 + count * (newlen - oldlen)); - if (ret == NULL) { - return (char *)PyErr_NoMemory(); - } - - i = 0; - while (*s) { - if (strstr(s, old) == s) { - strncpy(&ret[i], new, sizeof(char) * newlen); - i += newlen; - s += oldlen; - } else { - ret[i++] = *s++; - } - } - ret[i] = '\0'; - - return ret; -} // function to generate a nice string representation of the period // object, originally from DateObject_strftime diff --git a/pandas/_libs/src/period_helper.h b/pandas/_libs/src/period_helper.h index 45afc074cab72..35dd20848a2ec 100644 --- a/pandas/_libs/src/period_helper.h +++ b/pandas/_libs/src/period_helper.h @@ -112,15 +112,6 @@ frequency conversion routines. #define INT_ERR_CODE INT32_MIN -#define MEM_CHECK(item) \ - if (item == NULL) { \ - return PyErr_NoMemory(); \ - } -#define ERR_CHECK(item) \ - if (item == NULL) { \ - return NULL; \ - } - typedef struct asfreq_info { int from_week_end; // day the week ends on in the "from" frequency int to_week_end; // day the week ends on in the "to" frequency @@ -182,7 +173,6 @@ int pminute(npy_int64 ordinal, int freq); int psecond(npy_int64 ordinal, int freq); int pdays_in_month(npy_int64 ordinal, int freq); -double getAbsTime(int freq, npy_int64 dailyDate, npy_int64 originalDate); char *c_strftime(struct date_info *dinfo, char *fmt); int get_yq(npy_int64 ordinal, int freq, int *quarter, int *year); diff --git a/pandas/_libs/tslibs/period.pyx b/pandas/_libs/tslibs/period.pyx index 46365035a0b9a..e2caebe4c4afc 100644 --- a/pandas/_libs/tslibs/period.pyx +++ b/pandas/_libs/tslibs/period.pyx @@ -372,15 +372,6 @@ cdef object _period_strftime(int64_t value, int freq, object fmt): ctypedef int (*accessor)(int64_t ordinal, int freq) except INT32_MIN -def get_period_field(int code, int64_t value, int freq): - cdef accessor f = _get_accessor_func(code) - if f is NULL: - raise ValueError('Unrecognized period code: %d' % code) - if value == iNaT: - return np.nan - return f(value, freq) - - def get_period_field_arr(int code, ndarray[int64_t] arr, int freq): cdef: Py_ssize_t i, sz diff --git a/pandas/tests/scalar/test_period.py b/pandas/tests/scalar/test_period.py index ce733829c2315..41b3bb55bfff1 100644 --- a/pandas/tests/scalar/test_period.py +++ b/pandas/tests/scalar/test_period.py @@ -914,9 +914,6 @@ def test_round_trip(self): class TestPeriodField(object): - def test_get_period_field_raises_on_out_of_range(self): - pytest.raises(ValueError, libperiod.get_period_field, -1, 0, 0) - def test_get_period_field_array_raises_on_out_of_range(self): pytest.raises(ValueError, libperiod.get_period_field_arr, -1, np.empty(1), 0)