diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2013-08-18 11:51:25 -0600 |
---|---|---|
committer | Charles Harris <charlesr.harris@gmail.com> | 2013-08-18 11:51:25 -0600 |
commit | fbd6510d58a47ea0d166c48a82793f05425406e4 (patch) | |
tree | 330ce703eb02d20f96099c3fe0fc36ae33d4905b /numpy/testing | |
parent | 8ddb0ce0acafe75d78df528b4d2540dfbf4b364d (diff) | |
download | numpy-fbd6510d58a47ea0d166c48a82793f05425406e4.tar.gz |
STY: Giant comma spacing fixup.
Run the 2to3 ws_comma fixer on *.py files. Some lines are now too long
and will need to be broken at some point. OTOH, some lines were already
too long and need to be broken at some point. Now seems as good a time
as any to do this with open PRs at a minimum.
Diffstat (limited to 'numpy/testing')
-rw-r--r-- | numpy/testing/decorators.py | 4 | ||||
-rw-r--r-- | numpy/testing/noseclasses.py | 12 | ||||
-rw-r--r-- | numpy/testing/nosetester.py | 6 | ||||
-rw-r--r-- | numpy/testing/numpytest.py | 4 | ||||
-rwxr-xr-x | numpy/testing/print_coercion_tables.py | 2 | ||||
-rwxr-xr-x | numpy/testing/setup.py | 2 | ||||
-rw-r--r-- | numpy/testing/tests/test_decorators.py | 2 | ||||
-rw-r--r-- | numpy/testing/tests/test_utils.py | 2 | ||||
-rw-r--r-- | numpy/testing/utils.py | 40 |
9 files changed, 37 insertions, 37 deletions
diff --git a/numpy/testing/decorators.py b/numpy/testing/decorators.py index 91659bb8d..8a4cfb480 100644 --- a/numpy/testing/decorators.py +++ b/numpy/testing/decorators.py @@ -141,14 +141,14 @@ def skipif(skip_condition, msg=None): def skipper_func(*args, **kwargs): """Skipper for normal test functions.""" if skip_val(): - raise nose.SkipTest(get_msg(f,msg)) + raise nose.SkipTest(get_msg(f, msg)) else: return f(*args, **kwargs) def skipper_gen(*args, **kwargs): """Skipper for test generators.""" if skip_val(): - raise nose.SkipTest(get_msg(f,msg)) + raise nose.SkipTest(get_msg(f, msg)) else: for x in f(*args, **kwargs): yield x diff --git a/numpy/testing/noseclasses.py b/numpy/testing/noseclasses.py index 3816a2194..cb757a13f 100644 --- a/numpy/testing/noseclasses.py +++ b/numpy/testing/noseclasses.py @@ -69,7 +69,7 @@ class NumpyDocTestFinder(doctest.DocTestFinder): add them to `tests`. """ - doctest.DocTestFinder._find(self,tests, obj, name, module, + doctest.DocTestFinder._find(self, tests, obj, name, module, source_lines, globs, seen) # Below we re-run pieces of the above method with manual modifications, @@ -127,13 +127,13 @@ class NumpyOutputChecker(doctest.OutputChecker): # bigendian machines don't fail all the tests (and there are # actually some bigendian examples in the doctests). Let's try # making them all little endian - got = got.replace("'>","'<") - want= want.replace("'>","'<") + got = got.replace("'>", "'<") + want= want.replace("'>", "'<") # try to normalize out 32 and 64 bit default int sizes - for sz in [4,8]: - got = got.replace("'<i%d'"%sz,"int") - want= want.replace("'<i%d'"%sz,"int") + for sz in [4, 8]: + got = got.replace("'<i%d'"%sz, "int") + want= want.replace("'<i%d'"%sz, "int") ret = doctest.OutputChecker.check_output(self, want, got, optionflags) diff --git a/numpy/testing/nosetester.py b/numpy/testing/nosetester.py index 481b6189d..77ac61074 100644 --- a/numpy/testing/nosetester.py +++ b/numpy/testing/nosetester.py @@ -57,7 +57,7 @@ def import_nose(): """ Import nose only when needed. """ fine_nose = True - minimum_nose_version = (0,10,0) + minimum_nose_version = (0, 10, 0) try: import nose except ImportError: @@ -82,7 +82,7 @@ def run_module_suite(file_to_run = None): if file_to_run is None: raise AssertionError - import_nose().run(argv=['',file_to_run]) + import_nose().run(argv=['', file_to_run]) class NoseTester(object): @@ -214,7 +214,7 @@ class NoseTester(object): spdir = os.path.dirname(scipy.__file__) print("SciPy is installed in %s" % spdir) - pyversion = sys.version.replace('\n','') + pyversion = sys.version.replace('\n', '') print("Python version %s" % pyversion) print("nose version %d.%d.%d" % nose.__versioninfo__) diff --git a/numpy/testing/numpytest.py b/numpy/testing/numpytest.py index 2120975df..d83a21d83 100644 --- a/numpy/testing/numpytest.py +++ b/numpy/testing/numpytest.py @@ -15,7 +15,7 @@ def importall(package): warnings.warn("`importall is deprecated, and will be remobed in numpy 1.9.0", DeprecationWarning) - if isinstance(package,str): + if isinstance(package, str): package = __import__(package) package_name = package.__name__ @@ -24,7 +24,7 @@ def importall(package): subdir = os.path.join(package_dir, subpackage_name) if not os.path.isdir(subdir): continue - if not os.path.isfile(os.path.join(subdir,'__init__.py')): + if not os.path.isfile(os.path.join(subdir, '__init__.py')): continue name = package_name+'.'+subpackage_name try: diff --git a/numpy/testing/print_coercion_tables.py b/numpy/testing/print_coercion_tables.py index 06c968cf4..bde82a666 100755 --- a/numpy/testing/print_coercion_tables.py +++ b/numpy/testing/print_coercion_tables.py @@ -54,7 +54,7 @@ def print_coercion_table(ntypes, inputfirstvalue, inputsecondvalue, firstarray, if use_promote_types: char = np.promote_types(rowvalue.dtype, colvalue.dtype).char else: - value = np.add(rowvalue,colvalue) + value = np.add(rowvalue, colvalue) if isinstance(value, np.ndarray): char = value.dtype.char else: diff --git a/numpy/testing/setup.py b/numpy/testing/setup.py index 0e3a9627e..595e48925 100755 --- a/numpy/testing/setup.py +++ b/numpy/testing/setup.py @@ -4,7 +4,7 @@ from __future__ import division, print_function def configuration(parent_package='',top_path=None): from numpy.distutils.misc_util import Configuration - config = Configuration('testing',parent_package,top_path) + config = Configuration('testing', parent_package, top_path) config.add_data_dir('tests') return config diff --git a/numpy/testing/tests/test_decorators.py b/numpy/testing/tests/test_decorators.py index f3e142d54..36c7cc7bb 100644 --- a/numpy/testing/tests/test_decorators.py +++ b/numpy/testing/tests/test_decorators.py @@ -7,7 +7,7 @@ import nose def test_slow(): @dec.slow - def slow_func(x,y,z): + def slow_func(x, y, z): pass assert_(slow_func.slow) diff --git a/numpy/testing/tests/test_utils.py b/numpy/testing/tests/test_utils.py index cbc8cd23e..94fc4d655 100644 --- a/numpy/testing/tests/test_utils.py +++ b/numpy/testing/tests/test_utils.py @@ -194,7 +194,7 @@ class TestArrayAlmostEqual(_GenericTest, unittest.TestCase): def test_inf(self): a = np.array([[1., 2.], [3., 4.]]) b = a.copy() - a[0,0] = np.inf + a[0, 0] = np.inf self.assertRaises(AssertionError, lambda : self._assert_func(a, b)) diff --git a/numpy/testing/utils.py b/numpy/testing/utils.py index ca09e3b7d..8e324a78d 100644 --- a/numpy/testing/utils.py +++ b/numpy/testing/utils.py @@ -17,7 +17,7 @@ if sys.version_info[0] >= 3: else: from StringIO import StringIO -__all__ = ['assert_equal', 'assert_almost_equal','assert_approx_equal', +__all__ = ['assert_equal', 'assert_almost_equal', 'assert_approx_equal', 'assert_array_equal', 'assert_array_less', 'assert_string_equal', 'assert_array_almost_equal', 'assert_raises', 'build_err_msg', 'decorate_methods', 'jiffies', 'memusage', 'print_assert_equal', @@ -118,7 +118,7 @@ if sys.platform[:5]=='linux': if not _load_time: _load_time.append(time.time()) try: - f=open(_proc_pid_stat,'r') + f=open(_proc_pid_stat, 'r') l = f.readline().split(' ') f.close() return int(l[13]) @@ -129,7 +129,7 @@ if sys.platform[:5]=='linux': """ Return virtual memory size in bytes of the running python. """ try: - f=open(_proc_pid_stat,'r') + f=open(_proc_pid_stat, 'r') l = f.readline().split(' ') f.close() return int(l[22]) @@ -164,7 +164,7 @@ if os.name=='nt' and sys.version[:3] > '2.3': # the CPU to 100%, but the above makes more sense :) import win32pdh if format is None: format = win32pdh.PDH_FMT_LONG - path = win32pdh.MakeCounterPath( (machine,object,instance, None, inum,counter) ) + path = win32pdh.MakeCounterPath( (machine, object, instance, None, inum, counter) ) hq = win32pdh.OpenQuery() try: hc = win32pdh.AddCounter(hq, path) @@ -243,16 +243,16 @@ def assert_equal(actual,desired,err_msg='',verbose=True): if isinstance(desired, dict): if not isinstance(actual, dict) : raise AssertionError(repr(type(actual))) - assert_equal(len(actual),len(desired),err_msg,verbose) - for k,i in desired.items(): + assert_equal(len(actual), len(desired), err_msg, verbose) + for k, i in desired.items(): if k not in actual : raise AssertionError(repr(k)) - assert_equal(actual[k], desired[k], 'key=%r\n%s' % (k,err_msg), verbose) + assert_equal(actual[k], desired[k], 'key=%r\n%s' % (k, err_msg), verbose) return - if isinstance(desired, (list,tuple)) and isinstance(actual, (list,tuple)): - assert_equal(len(actual),len(desired),err_msg,verbose) + if isinstance(desired, (list, tuple)) and isinstance(actual, (list, tuple)): + assert_equal(len(actual), len(desired), err_msg, verbose) for k in range(len(desired)): - assert_equal(actual[k], desired[k], 'item=%r\n%s' % (k,err_msg), verbose) + assert_equal(actual[k], desired[k], 'item=%r\n%s' % (k, err_msg), verbose) return from numpy.core import ndarray, isscalar, signbit from numpy.lib import iscomplexobj, real, imag @@ -316,7 +316,7 @@ def assert_equal(actual,desired,err_msg='',verbose=True): if desired != actual : raise AssertionError(msg) -def print_assert_equal(test_string,actual,desired): +def print_assert_equal(test_string, actual, desired): """ Test if two objects are equal, and print an error message if test fails. @@ -350,9 +350,9 @@ def print_assert_equal(test_string,actual,desired): msg = StringIO() msg.write(test_string) msg.write(' failed\nACTUAL: \n') - pprint.pprint(actual,msg) + pprint.pprint(actual, msg) msg.write('DESIRED: \n') - pprint.pprint(desired,msg) + pprint.pprint(desired, msg) raise AssertionError(msg.getvalue()) def assert_almost_equal(actual,desired,decimal=7,err_msg='',verbose=True): @@ -466,7 +466,7 @@ def assert_almost_equal(actual,desired,decimal=7,err_msg='',verbose=True): return except (NotImplementedError, TypeError): pass - if round(abs(desired - actual),decimal) != 0 : + if round(abs(desired - actual), decimal) != 0 : raise AssertionError(msg) @@ -535,7 +535,7 @@ def assert_approx_equal(actual,desired,significant=7,err_msg='',verbose=True): # scale = float(pow(10,math.floor(math.log10(0.5*(abs(desired)+abs(actual)))))) with np.errstate(invalid='ignore'): scale = 0.5*(np.abs(desired) + np.abs(actual)) - scale = np.power(10,np.floor(np.log10(scale))) + scale = np.power(10, np.floor(np.log10(scale))) try: sc_desired = desired/scale except ZeroDivisionError: @@ -562,7 +562,7 @@ def assert_approx_equal(actual,desired,significant=7,err_msg='',verbose=True): return except (TypeError, NotImplementedError): pass - if np.abs(sc_desired - sc_actual) >= np.power(10.,-(significant-1)) : + if np.abs(sc_desired - sc_actual) >= np.power(10., -(significant-1)) : raise AssertionError(msg) def assert_array_compare(comparison, x, y, err_msg='', verbose=True, @@ -624,7 +624,7 @@ def assert_array_compare(comparison, x, y, err_msg='', verbose=True, else: val = comparison(x, y) else: - val = comparison(x,y) + val = comparison(x, y) if isinstance(val, bool): cond = val @@ -1100,7 +1100,7 @@ def measure(code_str,times=1,label=None): """ frame = sys._getframe(1) - locs,globs = frame.f_locals,frame.f_globals + locs, globs = frame.f_locals, frame.f_globals code = compile(code_str, 'Test name: %s ' % label, @@ -1109,7 +1109,7 @@ def measure(code_str,times=1,label=None): elapsed = jiffies() while i < times: i += 1 - exec(code, globs,locs) + exec(code, globs, locs) elapsed = jiffies() - elapsed return 0.01*elapsed @@ -1127,7 +1127,7 @@ def _assert_valid_refcount(op): rc = sys.getrefcount(i) for j in range(15): - d = op(b,c) + d = op(b, c) assert_(sys.getrefcount(i) >= rc) |