From c879ad8a39f2b74edcdaa05a2f2f854fb235537d Mon Sep 17 00:00:00 2001 From: Charles Harris Date: Sat, 13 Apr 2013 12:21:42 -0600 Subject: 2to3: Apply types fixer. Python 3 removes the builtin types from the types module. The types fixer replaces such references with the builtin types where possible and also takes care of some special cases: types.TypeNone <- type(None) types.NotImplementedType <- type(NotImplemented) types.EllipsisType <- type(Ellipsis) The only two tricky substitutions are types.StringType <- bytes types.LongType <- int These are fixed up to support both Python 3 and Python 2 code by importing the long and bytes types from numpy.compat. Closes #3240. --- numpy/testing/utils.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'numpy/testing/utils.py') diff --git a/numpy/testing/utils.py b/numpy/testing/utils.py index 1b69d0ed2..40c569c0f 100644 --- a/numpy/testing/utils.py +++ b/numpy/testing/utils.py @@ -8,7 +8,6 @@ import os import sys import re import operator -import types import warnings from .nosetester import import_nose @@ -54,7 +53,7 @@ def gisnan(x): This should be removed once this problem is solved at the Ufunc level.""" from numpy.core import isnan st = isnan(x) - if isinstance(st, types.NotImplementedType): + if isinstance(st, type(NotImplemented)): raise TypeError("isnan not supported for this type") return st @@ -73,7 +72,7 @@ def gisfinite(x): err = seterr(invalid='ignore') try: st = isfinite(x) - if isinstance(st, types.NotImplementedType): + if isinstance(st, type(NotImplemented)): raise TypeError("isfinite not supported for this type") finally: seterr(**err) @@ -94,7 +93,7 @@ def gisinf(x): err = seterr(invalid='ignore') try: st = isinf(x) - if isinstance(st, types.NotImplementedType): + if isinstance(st, type(NotImplemented)): raise TypeError("isinf not supported for this type") finally: seterr(**err) -- cgit v1.2.1