Skip to content

Remove unused cimports, fix #22067 #22087

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Jul 30, 2018
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pandas/_libs/hashing.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# at https://github.com/veorq/SipHash

import cython
cimport numpy as cnp

import numpy as np
from numpy cimport ndarray, uint8_t, uint32_t, uint64_t

Expand Down
2 changes: 0 additions & 2 deletions pandas/_libs/tslibs/frequencies.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
# cython: profile=False
import re

cimport cython

cimport numpy as cnp
cnp.import_array()

Expand Down
4 changes: 1 addition & 3 deletions pandas/_libs/tslibs/parsing.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ from cpython.datetime cimport datetime
import time

import numpy as np
cimport numpy as cnp
from numpy cimport int64_t, ndarray
cnp.import_array()
from numpy cimport ndarray

# Avoid import from outside _libs
if sys.version_info.major == 2:
Expand Down
4 changes: 2 additions & 2 deletions pandas/_libs/tslibs/period.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1920,8 +1920,8 @@ class Period(_Period):
return cls._from_ordinal(ordinal, freq)


cdef int64_t _ordinal_from_fields(year, month, quarter, day,
hour, minute, second, freq):
cdef int64_t _ordinal_from_fields(int year, int month, quarter, int day,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does quarter not need a type?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It can be None.

int hour, int minute, int second, freq):
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is what fixed 22067. year and month were getting an Int64Index.

base, mult = get_freq_code(freq)
if quarter is not None:
year, month = quarter_to_myear(year, quarter, freq)
Expand Down
2 changes: 0 additions & 2 deletions pandas/_libs/tslibs/resolution.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ cimport cython
from cython cimport Py_ssize_t

import numpy as np
cimport numpy as cnp
from numpy cimport ndarray, int64_t, int32_t
cnp.import_array()

from util cimport is_string_object, get_nat

Expand Down
2 changes: 0 additions & 2 deletions pandas/_libs/tslibs/strptime.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ import pytz
from cython cimport Py_ssize_t
from cpython cimport PyFloat_Check

cimport cython

import numpy as np
from numpy cimport ndarray, int64_t

Expand Down
10 changes: 5 additions & 5 deletions pandas/_libs/window.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ from libc.stdlib cimport malloc, free

import numpy as np
cimport numpy as cnp
from numpy cimport ndarray, double_t, int64_t, float64_t
from numpy cimport ndarray, double_t, int64_t, float64_t, float32_t
cnp.import_array()


Expand All @@ -25,11 +25,11 @@ from skiplist cimport (skiplist_t,
skiplist_init, skiplist_destroy,
skiplist_get, skiplist_insert, skiplist_remove)

cdef cnp.float32_t MINfloat32 = np.NINF
cdef cnp.float64_t MINfloat64 = np.NINF
cdef float32_t MINfloat32 = np.NINF
cdef float64_t MINfloat64 = np.NINF

cdef cnp.float32_t MAXfloat32 = np.inf
cdef cnp.float64_t MAXfloat64 = np.inf
cdef float32_t MAXfloat32 = np.inf
cdef float64_t MAXfloat64 = np.inf

cdef double NaN = <double> np.NaN

Expand Down
2 changes: 0 additions & 2 deletions pandas/_libs/writers.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ except ImportError:
from cpython cimport PyUnicode_GET_SIZE as PyString_GET_SIZE

import numpy as np
cimport numpy as cnp
from numpy cimport ndarray, uint8_t
cnp.import_array()


ctypedef fused pandas_string:
Expand Down
16 changes: 11 additions & 5 deletions pandas/io/msgpack/_packer.pyx
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
# coding: utf-8
# cython: embedsignature=True

from cpython cimport *
from libc.stdlib cimport *
from libc.string cimport *
from libc.limits cimport *
from cpython cimport (
PyFloat_Check, PyLong_Check, PyInt_Check,
PyDict_CheckExact, PyDict_Check,
PyTuple_Check, PyList_Check,
PyCallable_Check,
PyUnicode_Check, PyBytes_Check,
PyBytes_AsString,
PyBytes_FromStringAndSize,
PyUnicode_AsEncodedString)
from libc.stdlib cimport free, malloc

from pandas.io.msgpack.exceptions import PackValueError
from pandas.io.msgpack import ExtType
Expand Down Expand Up @@ -74,7 +80,7 @@ cdef class Packer(object):
cdef object _berrors
cdef char *encoding
cdef char *unicode_errors
cdef bool use_float
cdef bint use_float
cdef bint autoreset

def __cinit__(self):
Expand Down
16 changes: 12 additions & 4 deletions pandas/io/msgpack/_unpacker.pyx
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
# coding: utf-8
# cython: embedsignature=True

from cpython cimport *
from cython cimport Py_ssize_t

from cpython cimport (
PyCallable_Check,
PyBUF_SIMPLE, PyObject_GetBuffer, PyBuffer_Release,
PyBytes_Size,
PyBytes_FromStringAndSize,
PyBytes_AsString)

cdef extern from "Python.h":
ctypedef struct PyObject
cdef int PyObject_AsReadBuffer(object o, const void** buff,
Py_ssize_t* buf_len) except -1

from libc.stdlib cimport *
from libc.string cimport *
from libc.limits cimport *
from libc.stdlib cimport free, malloc
from libc.string cimport memcpy, memmove
from libc.limits cimport INT_MAX

from pandas.io.msgpack.exceptions import (BufferFull, OutOfData,
UnpackValueError, ExtraData)
Expand Down
3 changes: 1 addition & 2 deletions pandas/io/sas/sas.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
# cython: boundscheck=False, initializedcheck=False

import numpy as np
cimport numpy as cnp
from numpy cimport uint8_t, uint16_t, int8_t, int64_t, ndarray
from numpy cimport uint8_t, uint16_t, int64_t, ndarray
import sas_constants as const

# rle_decompress decompresses data using a Run Length Encoding
Expand Down