diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2018-03-23 06:50:00 -0600 |
---|---|---|
committer | Charles Harris <charlesr.harris@gmail.com> | 2018-03-24 09:55:09 -0600 |
commit | fbb29df68bd7f330d5a5ced2c20e9244f12f9648 (patch) | |
tree | 43b8d9dab23035628ca116be269b507655ecaf53 | |
parent | e8389cb15f8d8fd902ea9f7aad0da64bce0f2583 (diff) | |
download | python-numpy-fbb29df68bd7f330d5a5ced2c20e9244f12f9648.tar.gz python-numpy-fbb29df68bd7f330d5a5ced2c20e9244f12f9648.tar.bz2 python-numpy-fbb29df68bd7f330d5a5ced2c20e9244f12f9648.zip |
TST: Rename some compiled c test modules
The renamed C modules provide low level functions for testing. The
rename marks them as private functions and makes them invisible to
pytest by default.
18 files changed, 64 insertions, 64 deletions
diff --git a/numpy/conftest.py b/numpy/conftest.py index 15985a75b..ce985d079 100644 --- a/numpy/conftest.py +++ b/numpy/conftest.py @@ -8,7 +8,7 @@ import pytest import numpy import importlib -from numpy.core.multiarray_tests import get_fpu_mode +from numpy.core._multiarray_tests import get_fpu_mode _old_fpu_mode = None @@ -21,7 +21,7 @@ def pytest_itemcollected(item): Check FPU precision mode was not changed during test collection. The clumsy way we do it here is mainly necessary because numpy - still uses yield tests, which can execute code at test collection + still uses yield tests, which can execute code at test collection time. """ global _old_fpu_mode diff --git a/numpy/core/setup.py b/numpy/core/setup.py index 11b1acb07..d519e0eb8 100644 --- a/numpy/core/setup.py +++ b/numpy/core/setup.py @@ -924,29 +924,29 @@ def configuration(parent_package='',top_path=None): # umath_tests module # ####################################################################### - config.add_extension('umath_tests', - sources=[join('src', 'umath', 'umath_tests.c.src')]) + config.add_extension('_umath_tests', + sources=[join('src', 'umath', '_umath_tests.c.src')]) ####################################################################### # custom rational dtype module # ####################################################################### - config.add_extension('test_rational', - sources=[join('src', 'umath', 'test_rational.c.src')]) + config.add_extension('_rational_tests', + sources=[join('src', 'umath', '_rational_tests.c.src')]) ####################################################################### # struct_ufunc_test module # ####################################################################### - config.add_extension('struct_ufunc_test', - sources=[join('src', 'umath', 'struct_ufunc_test.c.src')]) + config.add_extension('_struct_ufunc_tests', + sources=[join('src', 'umath', '_struct_ufunc_tests.c.src')]) ####################################################################### # multiarray_tests module # ####################################################################### - config.add_extension('multiarray_tests', - sources=[join('src', 'multiarray', 'multiarray_tests.c.src'), + config.add_extension('_multiarray_tests', + sources=[join('src', 'multiarray', '_multiarray_tests.c.src'), join('src', 'private', 'mem_overlap.c')], depends=[join('src', 'private', 'mem_overlap.h'), join('src', 'private', 'npy_extint128.h')], @@ -956,8 +956,8 @@ def configuration(parent_package='',top_path=None): # operand_flag_tests module # ####################################################################### - config.add_extension('operand_flag_tests', - sources=[join('src', 'umath', 'operand_flag_tests.c.src')]) + config.add_extension('_operand_flag_tests', + sources=[join('src', 'umath', '_operand_flag_tests.c.src')]) config.add_data_dir('tests') config.add_data_dir('tests/data') diff --git a/numpy/core/src/multiarray/multiarray_tests.c.src b/numpy/core/src/multiarray/_multiarray_tests.c.src index d63349560..afc6db1aa 100644 --- a/numpy/core/src/multiarray/multiarray_tests.c.src +++ b/numpy/core/src/multiarray/_multiarray_tests.c.src @@ -1867,7 +1867,7 @@ static PyMethodDef Multiarray_TestsMethods[] = { #if defined(NPY_PY3K) static struct PyModuleDef moduledef = { PyModuleDef_HEAD_INIT, - "multiarray_tests", + "_multiarray_tests", NULL, -1, Multiarray_TestsMethods, @@ -1880,11 +1880,11 @@ static struct PyModuleDef moduledef = { #if defined(NPY_PY3K) #define RETVAL m -PyMODINIT_FUNC PyInit_multiarray_tests(void) +PyMODINIT_FUNC PyInit__multiarray_tests(void) #else #define RETVAL PyMODINIT_FUNC -initmultiarray_tests(void) +init_multiarray_tests(void) #endif { PyObject *m; @@ -1892,7 +1892,7 @@ initmultiarray_tests(void) #if defined(NPY_PY3K) m = PyModule_Create(&moduledef); #else - m = Py_InitModule("multiarray_tests", Multiarray_TestsMethods); + m = Py_InitModule("_multiarray_tests", Multiarray_TestsMethods); #endif if (m == NULL) { return RETVAL; @@ -1900,7 +1900,7 @@ initmultiarray_tests(void) import_array(); if (PyErr_Occurred()) { PyErr_SetString(PyExc_RuntimeError, - "cannot load umath_tests module."); + "cannot load _multiarray_tests module."); } return RETVAL; } diff --git a/numpy/core/src/umath/operand_flag_tests.c.src b/numpy/core/src/umath/_operand_flag_tests.c.src index 046c37595..551a9c632 100644 --- a/numpy/core/src/umath/operand_flag_tests.c.src +++ b/numpy/core/src/umath/_operand_flag_tests.c.src @@ -42,7 +42,7 @@ static void *data[1] = {NULL}; #if defined(NPY_PY3K) static struct PyModuleDef moduledef = { PyModuleDef_HEAD_INIT, - "operand_flag_tests", + "_operand_flag_tests", NULL, -1, TestMethods, @@ -53,11 +53,11 @@ static struct PyModuleDef moduledef = { }; #define RETVAL m -PyMODINIT_FUNC PyInit_operand_flag_tests(void) +PyMODINIT_FUNC PyInit__operand_flag_tests(void) { #else #define RETVAL -PyMODINIT_FUNC initoperand_flag_tests(void) +PyMODINIT_FUNC init_operand_flag_tests(void) { #endif PyObject *m = NULL; @@ -66,7 +66,7 @@ PyMODINIT_FUNC initoperand_flag_tests(void) #if defined(NPY_PY3K) m = PyModule_Create(&moduledef); #else - m = Py_InitModule("operand_flag_tests", TestMethods); + m = Py_InitModule("_operand_flag_tests", TestMethods); #endif if (m == NULL) { goto fail; @@ -92,7 +92,7 @@ PyMODINIT_FUNC initoperand_flag_tests(void) fail: if (!PyErr_Occurred()) { PyErr_SetString(PyExc_RuntimeError, - "cannot load operand_flag_tests module."); + "cannot load _operand_flag_tests module."); } #if defined(NPY_PY3K) if (m) { diff --git a/numpy/core/src/umath/test_rational.c.src b/numpy/core/src/umath/_rational_tests.c.src index ffc92b732..9e74845df 100644 --- a/numpy/core/src/umath/test_rational.c.src +++ b/numpy/core/src/umath/_rational_tests.c.src @@ -1129,7 +1129,7 @@ PyMethodDef module_methods[] = { #if defined(NPY_PY3K) static struct PyModuleDef moduledef = { PyModuleDef_HEAD_INIT, - "test_rational", + "_rational_tests", NULL, -1, module_methods, @@ -1142,10 +1142,10 @@ static struct PyModuleDef moduledef = { #if defined(NPY_PY3K) #define RETVAL m -PyMODINIT_FUNC PyInit_test_rational(void) { +PyMODINIT_FUNC PyInit__rational_tests(void) { #else #define RETVAL -PyMODINIT_FUNC inittest_rational(void) { +PyMODINIT_FUNC init_rational_tests(void) { #endif PyObject *m = NULL; @@ -1295,7 +1295,7 @@ PyMODINIT_FUNC inittest_rational(void) { #if defined(NPY_PY3K) m = PyModule_Create(&moduledef); #else - m = Py_InitModule("test_rational", module_methods); + m = Py_InitModule("_rational_tests", module_methods); #endif if (!m) { @@ -1397,7 +1397,7 @@ PyMODINIT_FUNC inittest_rational(void) { fail: if (!PyErr_Occurred()) { PyErr_SetString(PyExc_RuntimeError, - "cannot load test_rational module."); + "cannot load _rational_tests module."); } #if defined(NPY_PY3K) if (m) { diff --git a/numpy/core/src/umath/struct_ufunc_test.c.src b/numpy/core/src/umath/_struct_ufunc_tests.c.src index 9a6318f47..b831d5c2a 100644 --- a/numpy/core/src/umath/struct_ufunc_test.c.src +++ b/numpy/core/src/umath/_struct_ufunc_tests.c.src @@ -56,7 +56,7 @@ static void add_uint64_triplet(char **args, npy_intp *dimensions, #if defined(NPY_PY3K) static struct PyModuleDef moduledef = { PyModuleDef_HEAD_INIT, - "struct_ufunc_test", + "_struct_ufunc_tests", NULL, -1, StructUfuncTestMethods, @@ -68,9 +68,9 @@ static struct PyModuleDef moduledef = { #endif #if defined(NPY_PY3K) -PyMODINIT_FUNC PyInit_struct_ufunc_test(void) +PyMODINIT_FUNC PyInit__struct_ufunc_tests(void) #else -PyMODINIT_FUNC initstruct_ufunc_test(void) +PyMODINIT_FUNC init_struct_ufunc_tests(void) #endif { PyObject *m, *add_triplet, *d; @@ -81,7 +81,7 @@ PyMODINIT_FUNC initstruct_ufunc_test(void) #if defined(NPY_PY3K) m = PyModule_Create(&moduledef); #else - m = Py_InitModule("struct_ufunc_test", StructUfuncTestMethods); + m = Py_InitModule("_struct_ufunc_tests", StructUfuncTestMethods); #endif if (m == NULL) { diff --git a/numpy/core/src/umath/umath_tests.c.src b/numpy/core/src/umath/_umath_tests.c.src index 8d9009a1a..120ce0332 100644 --- a/numpy/core/src/umath/umath_tests.c.src +++ b/numpy/core/src/umath/_umath_tests.c.src @@ -360,7 +360,7 @@ static PyMethodDef UMath_TestsMethods[] = { #if defined(NPY_PY3K) static struct PyModuleDef moduledef = { PyModuleDef_HEAD_INIT, - "umath_tests", + "_umath_tests", NULL, -1, UMath_TestsMethods, @@ -373,11 +373,11 @@ static struct PyModuleDef moduledef = { #if defined(NPY_PY3K) #define RETVAL m -PyMODINIT_FUNC PyInit_umath_tests(void) +PyMODINIT_FUNC PyInit__umath_tests(void) #else #define RETVAL PyMODINIT_FUNC -initumath_tests(void) +init_umath_tests(void) #endif { PyObject *m; @@ -387,7 +387,7 @@ initumath_tests(void) #if defined(NPY_PY3K) m = PyModule_Create(&moduledef); #else - m = Py_InitModule("umath_tests", UMath_TestsMethods); + m = Py_InitModule("_umath_tests", UMath_TestsMethods); #endif if (m == NULL) return RETVAL; @@ -406,7 +406,7 @@ initumath_tests(void) if (PyErr_Occurred()) { PyErr_SetString(PyExc_RuntimeError, - "cannot load umath_tests module."); + "cannot load _umath_tests module."); } return RETVAL; diff --git a/numpy/core/tests/test_deprecations.py b/numpy/core/tests/test_deprecations.py index fe0c7cc5f..2c2900e6c 100644 --- a/numpy/core/tests/test_deprecations.py +++ b/numpy/core/tests/test_deprecations.py @@ -429,7 +429,7 @@ class TestNonNumericConjugate(_DeprecationTestCase): class TestNPY_CHAR(_DeprecationTestCase): # 2017-05-03, 1.13.0 def test_npy_char_deprecation(self): - from numpy.core.multiarray_tests import npy_char_deprecation + from numpy.core._multiarray_tests import npy_char_deprecation self.assert_deprecated(npy_char_deprecation) assert_(npy_char_deprecation() == 'S1') @@ -440,11 +440,11 @@ class Test_UPDATEIFCOPY(_DeprecationTestCase): WRITEBACKIFCOPY instead """ def test_npy_updateifcopy_deprecation(self): - from numpy.core.multiarray_tests import npy_updateifcopy_deprecation + from numpy.core._multiarray_tests import npy_updateifcopy_deprecation arr = np.arange(9).reshape(3, 3) v = arr.T self.assert_deprecated(npy_updateifcopy_deprecation, args=(v,)) - + class TestDatetimeEvent(_DeprecationTestCase): # 2017-08-11, 1.14.0 diff --git a/numpy/core/tests/test_dtype.py b/numpy/core/tests/test_dtype.py index 2f997b4f7..c924e6f43 100644 --- a/numpy/core/tests/test_dtype.py +++ b/numpy/core/tests/test_dtype.py @@ -5,7 +5,7 @@ import sys import operator import numpy as np -from numpy.core.test_rational import rational +from numpy.core._rational_tests import rational from numpy.testing import ( run_module_suite, assert_, assert_equal, assert_raises, dec diff --git a/numpy/core/tests/test_extint128.py b/numpy/core/tests/test_extint128.py index d87585dcf..31786124d 100644 --- a/numpy/core/tests/test_extint128.py +++ b/numpy/core/tests/test_extint128.py @@ -6,7 +6,7 @@ import contextlib import operator import numpy as np -import numpy.core.multiarray_tests as mt +import numpy.core._multiarray_tests as mt from numpy.compat import long from numpy.testing import assert_raises, assert_equal, dec diff --git a/numpy/core/tests/test_indexing.py b/numpy/core/tests/test_indexing.py index 3a02c9fce..082ecb496 100644 --- a/numpy/core/tests/test_indexing.py +++ b/numpy/core/tests/test_indexing.py @@ -6,7 +6,7 @@ import functools import operator import numpy as np -from numpy.core.multiarray_tests import array_indexing +from numpy.core._multiarray_tests import array_indexing from itertools import product from numpy.testing import ( run_module_suite, assert_, assert_equal, assert_raises, diff --git a/numpy/core/tests/test_mem_overlap.py b/numpy/core/tests/test_mem_overlap.py index 9c17ed210..92baa0896 100644 --- a/numpy/core/tests/test_mem_overlap.py +++ b/numpy/core/tests/test_mem_overlap.py @@ -7,8 +7,8 @@ import numpy as np from numpy.testing import (run_module_suite, assert_, assert_raises, assert_equal, assert_array_equal, assert_allclose, dec) -from numpy.core.multiarray_tests import solve_diophantine, internal_overlap -from numpy.core import umath_tests +from numpy.core._multiarray_tests import solve_diophantine, internal_overlap +from numpy.core import _umath_tests from numpy.lib.stride_tricks import as_strided from numpy.compat import long @@ -749,7 +749,7 @@ class TestUFunc(object): def test_unary_gufunc_fuzz(self): shapes = [7, 13, 8, 21, 29, 32] - gufunc = umath_tests.euclidean_pdist + gufunc = _umath_tests.euclidean_pdist rng = np.random.RandomState(1234) diff --git a/numpy/core/tests/test_multiarray.py b/numpy/core/tests/test_multiarray.py index da0ccf9eb..44e934585 100644 --- a/numpy/core/tests/test_multiarray.py +++ b/numpy/core/tests/test_multiarray.py @@ -26,7 +26,7 @@ from decimal import Decimal import numpy as np from numpy.compat import strchar, unicode -from numpy.core.multiarray_tests import ( +from numpy.core._multiarray_tests import ( test_neighborhood_iterator, test_neighborhood_iterator_oob, test_pydatamem_seteventhook_start, test_pydatamem_seteventhook_end, test_inplace_increment, get_buffer_info, test_as_c_array, @@ -193,7 +193,7 @@ class TestAttributes(object): assert_equal(isinstance(numpy_int, int), True) # ... and fast-path checks on C-API level should also work - from numpy.core.multiarray_tests import test_int_subclass + from numpy.core._multiarray_tests import test_int_subclass assert_equal(test_int_subclass(numpy_int), True) def test_stridesattr(self): @@ -3344,7 +3344,7 @@ class TestTemporaryElide(object): # def incref_elide(a): # d = input.copy() # refcount 1 # return d, d + d # PyNumber_Add without increasing refcount - from numpy.core.multiarray_tests import incref_elide + from numpy.core._multiarray_tests import incref_elide d = np.ones(100000) orig, res = incref_elide(d) d + d @@ -3359,7 +3359,7 @@ class TestTemporaryElide(object): # # def incref_elide_l(d): # return l[4] + l[4] # PyNumber_Add without increasing refcount - from numpy.core.multiarray_tests import incref_elide_l + from numpy.core._multiarray_tests import incref_elide_l # padding with 1 makes sure the object on the stack is not overwritten l = [1, 1, 1, 1, np.ones(100000)] res = incref_elide_l(l) @@ -3438,7 +3438,7 @@ class TestTemporaryElide(object): class TestCAPI(object): def test_IsPythonScalar(self): - from numpy.core.multiarray_tests import IsPythonScalar + from numpy.core._multiarray_tests import IsPythonScalar assert_(IsPythonScalar(b'foobar')) assert_(IsPythonScalar(1)) assert_(IsPythonScalar(2**80)) @@ -6633,7 +6633,7 @@ def test_scalar_element_deletion(): class TestMemEventHook(object): def test_mem_seteventhook(self): # The actual tests are within the C code in - # multiarray/multiarray_tests.c.src + # multiarray/_multiarray_tests.c.src test_pydatamem_seteventhook_start() # force an allocation and free of a numpy array # needs to be larger then limit of small memory cacher in ctors.c @@ -6645,7 +6645,7 @@ class TestMemEventHook(object): class TestMapIter(object): def test_mapiter(self): # The actual tests are within the C code in - # multiarray/multiarray_tests.c.src + # multiarray/_multiarray_tests.c.src a = np.arange(12).reshape((3, 4)).astype(float) index = ([1, 1, 2, 0], @@ -7237,7 +7237,7 @@ class TestWritebackIfCopy(object): assert_equal(b, np.array([[15, 18, 21], [42, 54, 66], [69, 90, 111]])) def test_view_assign(self): - from numpy.core.multiarray_tests import npy_create_writebackifcopy, npy_resolve + from numpy.core._multiarray_tests import npy_create_writebackifcopy, npy_resolve arr = np.arange(9).reshape(3, 3).T arr_wb = npy_create_writebackifcopy(arr) assert_(arr_wb.flags.writebackifcopy) @@ -7307,7 +7307,7 @@ def test_equal_override(): def test_npymath_complex(): # Smoketest npymath functions - from numpy.core.multiarray_tests import ( + from numpy.core._multiarray_tests import ( npy_cabs, npy_carg) funcs = {npy_cabs: np.absolute, @@ -7326,7 +7326,7 @@ def test_npymath_complex(): def test_npymath_real(): # Smoketest npymath functions - from numpy.core.multiarray_tests import ( + from numpy.core._multiarray_tests import ( npy_log10, npy_cosh, npy_sinh, npy_tan, npy_tanh) funcs = {npy_log10: np.log10, diff --git a/numpy/core/tests/test_nditer.py b/numpy/core/tests/test_nditer.py index 1b2485a87..6b1152e09 100644 --- a/numpy/core/tests/test_nditer.py +++ b/numpy/core/tests/test_nditer.py @@ -5,7 +5,7 @@ import warnings import numpy as np from numpy import array, arange, nditer, all -from numpy.core.multiarray_tests import test_nditer_too_large +from numpy.core._multiarray_tests import test_nditer_too_large from numpy.testing import ( run_module_suite, assert_, assert_equal, assert_array_equal, assert_raises, assert_warns, dec, HAS_REFCOUNT, suppress_warnings diff --git a/numpy/core/tests/test_ufunc.py b/numpy/core/tests/test_ufunc.py index 7e1bfbdbe..0dc12b144 100644 --- a/numpy/core/tests/test_ufunc.py +++ b/numpy/core/tests/test_ufunc.py @@ -4,9 +4,9 @@ import warnings import itertools import numpy as np -import numpy.core.umath_tests as umt -import numpy.core.operand_flag_tests as opflag_tests -from numpy.core.test_rational import rational, test_add, test_add_rationals +import numpy.core._umath_tests as umt +import numpy.core._operand_flag_tests as opflag_tests +from numpy.core._rational_tests import rational, test_add, test_add_rationals from numpy.testing import ( run_module_suite, assert_, assert_equal, assert_raises, assert_array_equal, assert_almost_equal, assert_array_almost_equal, @@ -42,7 +42,7 @@ class TestUfunc(object): assert_(pickle.loads(pickle.dumps(np.sin)) is np.sin) # Check that ufunc not defined in the top level numpy namespace such as - # numpy.core.test_rational.test_add can also be pickled + # numpy.core._rational_tests.test_add can also be pickled assert_(pickle.loads(pickle.dumps(test_add)) is test_add) def test_pickle_withstring(self): @@ -1167,7 +1167,7 @@ class TestUfunc(object): assert_equal(a, 10) def test_struct_ufunc(self): - import numpy.core.struct_ufunc_test as struct_ufunc + import numpy.core._struct_ufunc_tests as struct_ufunc a = np.array([(1, 2, 3)], dtype='u8,u8,u8') b = np.array([(1, 2, 3)], dtype='u8,u8,u8') diff --git a/numpy/core/tests/test_umath.py b/numpy/core/tests/test_umath.py index 4b6b26cbf..fe7768e53 100644 --- a/numpy/core/tests/test_umath.py +++ b/numpy/core/tests/test_umath.py @@ -7,7 +7,7 @@ import fnmatch import itertools import numpy.core.umath as ncu -from numpy.core import umath_tests as ncu_tests +from numpy.core import _umath_tests as ncu_tests import numpy as np from numpy.testing import ( run_module_suite, assert_, assert_equal, assert_raises, diff --git a/numpy/lib/tests/test_stride_tricks.py b/numpy/lib/tests/test_stride_tricks.py index 0599324d7..475119481 100644 --- a/numpy/lib/tests/test_stride_tricks.py +++ b/numpy/lib/tests/test_stride_tricks.py @@ -1,7 +1,7 @@ from __future__ import division, absolute_import, print_function import numpy as np -from numpy.core.test_rational import rational +from numpy.core._rational_tests import rational from numpy.testing import ( run_module_suite, assert_equal, assert_array_equal, assert_raises, assert_ diff --git a/numpy/testing/nose_tools/noseclasses.py b/numpy/testing/nose_tools/noseclasses.py index 9756b9b45..08dec0ca9 100644 --- a/numpy/testing/nose_tools/noseclasses.py +++ b/numpy/testing/nose_tools/noseclasses.py @@ -325,7 +325,7 @@ class FPUModeCheckPlugin(Plugin): """ def prepareTestCase(self, test): - from numpy.core.multiarray_tests import get_fpu_mode + from numpy.core._multiarray_tests import get_fpu_mode def run(result): old_mode = get_fpu_mode() |