From 4e1d1ddff528d53d232dec93bc29b953f57bbc86 Mon Sep 17 00:00:00 2001 From: Brock Mendel Date: Sat, 30 Jun 2018 22:48:51 -0700 Subject: [PATCH 1/2] remove unused cimport, parametrize test --- pandas/_libs/internals.pyx | 2 +- pandas/_libs/writers.pyx | 2 -- pandas/tests/sparse/test_libsparse.py | 22 +++++----------------- 3 files changed, 6 insertions(+), 20 deletions(-) diff --git a/pandas/_libs/internals.pyx b/pandas/_libs/internals.pyx index b46a05a0842c3..2179999859dbb 100644 --- a/pandas/_libs/internals.pyx +++ b/pandas/_libs/internals.pyx @@ -435,4 +435,4 @@ def get_blkno_indexers(int64_t[:] blknos, bint group=True): res_view[i] = diff i += 1 - yield blkno, result \ No newline at end of file + yield blkno, result diff --git a/pandas/_libs/writers.pyx b/pandas/_libs/writers.pyx index 6f07d04b3fad3..77d8ca81258a0 100644 --- a/pandas/_libs/writers.pyx +++ b/pandas/_libs/writers.pyx @@ -16,8 +16,6 @@ cimport numpy as cnp from numpy cimport ndarray, uint8_t cnp.import_array() -cimport util - ctypedef fused pandas_string: str diff --git a/pandas/tests/sparse/test_libsparse.py b/pandas/tests/sparse/test_libsparse.py index 7719ea46503fd..b9c417b561dbd 100644 --- a/pandas/tests/sparse/test_libsparse.py +++ b/pandas/tests/sparse/test_libsparse.py @@ -596,22 +596,10 @@ def _check_case(xloc, xlen, yloc, ylen, eloc, elen): check_cases(_check_case) - -# too cute? oh but how I abhor code duplication -check_ops = ['add', 'sub', 'mul', 'truediv', 'floordiv'] - - -def make_optestf(op): - def f(self): - sparse_op = getattr(splib, 'sparse_%s_float64' % op) - python_op = getattr(operator, op) + @pytest.mark.parametrize('opname', + ['add', 'sub', 'mul', 'truediv', 'floordiv']) + def test_op(self, opname): + sparse_op = getattr(splib, 'sparse_%s_float64' % opname) + python_op = getattr(operator, opname) self._op_tests(sparse_op, python_op) - f.__name__ = 'test_%s' % op - return f - - -for op in check_ops: - g = make_optestf(op) - setattr(TestSparseOperators, g.__name__, g) - del g From 17ca09c6ea79b638a10c13e685651acd8ce21da3 Mon Sep 17 00:00:00 2001 From: Brock Mendel Date: Mon, 2 Jul 2018 20:03:48 -0700 Subject: [PATCH 2/2] Fixup whitespace --- pandas/tests/sparse/test_libsparse.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pandas/tests/sparse/test_libsparse.py b/pandas/tests/sparse/test_libsparse.py index b9c417b561dbd..3b90d93cee7a4 100644 --- a/pandas/tests/sparse/test_libsparse.py +++ b/pandas/tests/sparse/test_libsparse.py @@ -602,4 +602,3 @@ def test_op(self, opname): sparse_op = getattr(splib, 'sparse_%s_float64' % opname) python_op = getattr(operator, opname) self._op_tests(sparse_op, python_op) -