diff --git a/pandas/_libs/skiplist.pxd b/pandas/_libs/skiplist.pxd index 82a0862112199..78f206962bcfc 100644 --- a/pandas/_libs/skiplist.pxd +++ b/pandas/_libs/skiplist.pxd @@ -3,8 +3,6 @@ from cython cimport Py_ssize_t -from numpy cimport double_t - cdef extern from "src/skiplist.h": ctypedef struct node_t: @@ -33,7 +31,7 @@ cdef extern from "src/skiplist.h": # Node itself not intended to be exposed. cdef class Node: cdef public: - double_t value + double value list next list width diff --git a/pandas/_libs/skiplist.pyx b/pandas/_libs/skiplist.pyx index 5ede31b24118d..23836ef7f4de9 100644 --- a/pandas/_libs/skiplist.pyx +++ b/pandas/_libs/skiplist.pyx @@ -9,9 +9,6 @@ from libc.math cimport log import numpy as np -cimport numpy as cnp -from numpy cimport double_t -cnp.import_array() # MSVC does not have log2! @@ -26,11 +23,11 @@ from random import random cdef class Node: # cdef public: - # double_t value + # double value # list next # list width - def __init__(self, double_t value, list next, list width): + def __init__(self, double value, list next, list width): self.value = value self.next = next self.width = width diff --git a/pandas/_libs/src/compat_helper.h b/pandas/_libs/src/compat_helper.h index bdff61d7d4150..116cd91070a60 100644 --- a/pandas/_libs/src/compat_helper.h +++ b/pandas/_libs/src/compat_helper.h @@ -11,7 +11,7 @@ The full license is in the LICENSE file, distributed with this software. #define PANDAS__LIBS_SRC_COMPAT_HELPER_H_ #include "Python.h" -#include "numpy_helper.h" +#include "helper.h" /* PySlice_GetIndicesEx changes signature in PY3 diff --git a/pandas/core/tools/timedeltas.py b/pandas/core/tools/timedeltas.py index 63ab120833ba1..4dc4fcb00d84d 100644 --- a/pandas/core/tools/timedeltas.py +++ b/pandas/core/tools/timedeltas.py @@ -131,7 +131,7 @@ def _validate_timedelta_unit(arg): """ provide validation / translation for timedelta short units """ try: return _unit_map[arg] - except: + except (KeyError, TypeError): if arg is None: return 'ns' raise ValueError("invalid timedelta unit {arg} provided" diff --git a/pandas/io/s3.py b/pandas/io/s3.py index bd2286c5c8569..7d1360934fd53 100644 --- a/pandas/io/s3.py +++ b/pandas/io/s3.py @@ -3,7 +3,7 @@ try: import s3fs from botocore.exceptions import NoCredentialsError -except: +except ImportError: raise ImportError("The s3fs library is required to handle s3 files") if compat.PY3: diff --git a/pandas/tests/frame/test_missing.py b/pandas/tests/frame/test_missing.py index 9567c08781856..136299a4b81be 100644 --- a/pandas/tests/frame/test_missing.py +++ b/pandas/tests/frame/test_missing.py @@ -27,7 +27,7 @@ import scipy _is_scipy_ge_0190 = (LooseVersion(scipy.__version__) >= LooseVersion('0.19.0')) -except: +except ImportError: _is_scipy_ge_0190 = False diff --git a/pandas/tests/io/generate_legacy_storage_files.py b/pandas/tests/io/generate_legacy_storage_files.py index eb40e5521f7f1..aa020ba4c0623 100755 --- a/pandas/tests/io/generate_legacy_storage_files.py +++ b/pandas/tests/io/generate_legacy_storage_files.py @@ -303,7 +303,7 @@ def write_legacy_pickles(output_dir): # make sure we are < 0.13 compat (in py3) try: from pandas.compat import zip, cPickle as pickle # noqa - except: + except ImportError: import pickle version = pandas.__version__ diff --git a/pandas/tests/io/test_pickle.py b/pandas/tests/io/test_pickle.py index 45cbbd43cd6a8..c71e26ae56e8e 100644 --- a/pandas/tests/io/test_pickle.py +++ b/pandas/tests/io/test_pickle.py @@ -218,7 +218,7 @@ def c_unpickler(path): with open(path, 'rb') as fh: fh.seek(0) return c_pickle.load(fh) - except: + except ImportError: c_pickler = None c_unpickler = None diff --git a/pandas/tests/io/test_sql.py b/pandas/tests/io/test_sql.py index f8f742c5980ac..4b0edfce89174 100644 --- a/pandas/tests/io/test_sql.py +++ b/pandas/tests/io/test_sql.py @@ -468,7 +468,7 @@ def _transaction_test(self): with self.pandasSQL.run_transaction() as trans: trans.execute(ins_sql) raise Exception('error') - except: + except Exception: # ignore raised exception pass res = self.pandasSQL.read_query('SELECT * FROM test_trans') diff --git a/pandas/tests/series/test_missing.py b/pandas/tests/series/test_missing.py index 2bc44cb1c683f..ab3fdd8cbf84f 100644 --- a/pandas/tests/series/test_missing.py +++ b/pandas/tests/series/test_missing.py @@ -27,7 +27,7 @@ import scipy _is_scipy_ge_0190 = (LooseVersion(scipy.__version__) >= LooseVersion('0.19.0')) -except: +except ImportError: _is_scipy_ge_0190 = False diff --git a/pandas/util/_decorators.py b/pandas/util/_decorators.py index 7d5753d03f4fc..82cd44113cb25 100644 --- a/pandas/util/_decorators.py +++ b/pandas/util/_decorators.py @@ -1,7 +1,6 @@ from pandas.compat import callable, signature, PY2 from pandas._libs.properties import cache_readonly # noqa import inspect -import types import warnings from textwrap import dedent, wrap from functools import wraps, update_wrapper, WRAPPER_ASSIGNMENTS @@ -339,48 +338,3 @@ def make_signature(func): if spec.keywords: args.append('**' + spec.keywords) return args, spec.args - - -class docstring_wrapper(object): - """ - Decorator to wrap a function and provide - a dynamically evaluated doc-string. - - Parameters - ---------- - func : callable - creator : callable - return the doc-string - default : str, optional - return this doc-string on error - """ - _attrs = ['__module__', '__name__', - '__qualname__', '__annotations__'] - - def __init__(self, func, creator, default=None): - self.func = func - self.creator = creator - self.default = default - update_wrapper( - self, func, [attr for attr in self._attrs - if hasattr(func, attr)]) - - def __get__(self, instance, cls=None): - - # we are called with a class - if instance is None: - return self - - # we want to return the actual passed instance - return types.MethodType(self, instance) - - def __call__(self, *args, **kwargs): - return self.func(*args, **kwargs) - - @property - def __doc__(self): - try: - return self.creator() - except Exception as exc: - msg = self.default or str(exc) - return msg diff --git a/pandas/util/_print_versions.py b/pandas/util/_print_versions.py index 01198fc541e0c..5600834f3b615 100644 --- a/pandas/util/_print_versions.py +++ b/pandas/util/_print_versions.py @@ -114,7 +114,7 @@ def show_versions(as_json=False): if (as_json): try: import json - except: + except ImportError: import simplejson as json j = dict(system=dict(sys_info), dependencies=dict(deps_blob)) diff --git a/setup.py b/setup.py index d265733738425..f058c8a6e3c99 100755 --- a/setup.py +++ b/setup.py @@ -438,9 +438,12 @@ def get_tag(self): # enable coverage by building cython files by setting the environment variable -# "PANDAS_CYTHON_COVERAGE" (with a Truthy value) +# "PANDAS_CYTHON_COVERAGE" (with a Truthy value) or by running build_ext +# with `--with-cython-coverage`enabled linetrace = os.environ.get('PANDAS_CYTHON_COVERAGE', False) -CYTHON_TRACE = str(int(bool(linetrace))) +if '--with-cython-coverage' in sys.argv: + linetrace = True + sys.argv.remove('--with-cython-coverage') # Note: if not using `cythonize`, coverage can be enabled by # pinning `ext.cython_directives = directives` to each ext in extensions.