[Scipy-svn] r3529 - in trunk/scipy: integrate lib/blas lib/lapack linalg linsolve linsolve/umfpack misc sandbox/ga sandbox/maskedarray sandbox/netcdf sandbox/newoptimize sandbox/timeseries stats/models weave weave/tests
scipy-svn@scip...
scipy-svn@scip...
Tue Nov 13 02:02:02 CST 2007
Author: jarrod.millman
Date: 2007-11-13 02:01:14 -0600 (Tue, 13 Nov 2007)
New Revision: 3529
Modified:
trunk/scipy/integrate/quadrature.py
trunk/scipy/integrate/setup.py
trunk/scipy/lib/blas/__init__.py
trunk/scipy/lib/lapack/__init__.py
trunk/scipy/linalg/blas.py
trunk/scipy/linalg/flinalg.py
trunk/scipy/linalg/lapack.py
trunk/scipy/linsolve/linsolve.py
trunk/scipy/linsolve/umfpack/umfpack.py
trunk/scipy/misc/ppimport.py
trunk/scipy/sandbox/ga/genome.py
trunk/scipy/sandbox/ga/language.py
trunk/scipy/sandbox/ga/tree.py
trunk/scipy/sandbox/maskedarray/testutils.py
trunk/scipy/sandbox/netcdf/netcdf.py
trunk/scipy/sandbox/newoptimize/log.py
trunk/scipy/sandbox/timeseries/parser.py
trunk/scipy/sandbox/timeseries/plotlib.py
trunk/scipy/stats/models/cox.py
trunk/scipy/stats/models/mixed.py
trunk/scipy/weave/build_tools.py
trunk/scipy/weave/bytecodecompiler.py
trunk/scipy/weave/catalog.py
trunk/scipy/weave/tests/test_catalog.py
trunk/scipy/weave/tests/test_scxx_dict.py
Log:
use the 'in' keyword instead of the 'has_key()' method for testing dictionary membership
Modified: trunk/scipy/integrate/quadrature.py
===================================================================
--- trunk/scipy/integrate/quadrature.py 2007-11-13 07:13:14 UTC (rev 3528)
+++ trunk/scipy/integrate/quadrature.py 2007-11-13 08:01:14 UTC (rev 3529)
@@ -1,7 +1,4 @@
-## Automatically adapted for scipy Oct 21, 2005 by
-# Author: Travis Oliphant
-
__all__ = ['fixed_quad','quadrature','romberg','trapz','simps','romb',
'cumtrapz','newton_cotes','composite']
@@ -562,7 +559,7 @@
rn = np.arange(N+1)
equal = 1
- if equal and _builtincoeffs.has_key(N):
+ if equal and N in _builtincoeffs:
na, da, vi, nb, db = _builtincoeffs[N]
return na*np.array(vi,float)/da, float(nb)/db
Modified: trunk/scipy/integrate/setup.py
===================================================================
--- trunk/scipy/integrate/setup.py 2007-11-13 07:13:14 UTC (rev 3528)
+++ trunk/scipy/integrate/setup.py 2007-11-13 08:01:14 UTC (rev 3529)
@@ -35,7 +35,7 @@
libs = ['odepack','linpack_lite','mach']
# Remove libraries key from blas_opt
- if blas_opt.has_key('libraries'): # key doesn't exist on OS X ...
+ if 'libraries' in blas_opt: # key doesn't exist on OS X ...
libs.extend(blas_opt['libraries'])
newblas = {}
for key in blas_opt.keys():
Modified: trunk/scipy/lib/blas/__init__.py
===================================================================
--- trunk/scipy/lib/blas/__init__.py 2007-11-13 07:13:14 UTC (rev 3528)
+++ trunk/scipy/lib/blas/__init__.py 2007-11-13 08:01:14 UTC (rev 3529)
@@ -26,7 +26,8 @@
ordering = []
for i in range(len(arrays)):
t = arrays[i].dtype.char
- if not _type_conv.has_key(t): t = 'd'
+ if t not in _type_conv:
+ t = 'd'
ordering.append((t,i))
if ordering:
ordering.sort()
Modified: trunk/scipy/lib/lapack/__init__.py
===================================================================
--- trunk/scipy/lib/lapack/__init__.py 2007-11-13 07:13:14 UTC (rev 3528)
+++ trunk/scipy/lib/lapack/__init__.py 2007-11-13 08:01:14 UTC (rev 3529)
@@ -40,7 +40,8 @@
ordering = []
for i in range(len(arrays)):
t = arrays[i].dtype.char
- if not _type_conv.has_key(t): t = 'd'
+ if t not in _type_conv:
+ t = 'd'
ordering.append((t,i))
if ordering:
ordering.sort()
@@ -83,7 +84,7 @@
_colmajor_func_template = '''\
def %(func_name)s(*args,**kws):
- if not kws.has_key("rowmajor"):
+ if "rowmajor" not in kws:
kws["rowmajor"] = 0
return clapack_func(*args,**kws)
func_code = %(func_name)s.func_code
Modified: trunk/scipy/linalg/blas.py
===================================================================
--- trunk/scipy/linalg/blas.py 2007-11-13 07:13:14 UTC (rev 3528)
+++ trunk/scipy/linalg/blas.py 2007-11-13 08:01:14 UTC (rev 3529)
@@ -31,7 +31,8 @@
ordering = []
for i in range(len(arrays)):
t = arrays[i].dtype.char
- if not _type_conv.has_key(t): t = 'd'
+ if t not in _type_conv:
+ t = 'd'
ordering.append((t,i))
if ordering:
ordering.sort()
Modified: trunk/scipy/linalg/flinalg.py
===================================================================
--- trunk/scipy/linalg/flinalg.py 2007-11-13 07:13:14 UTC (rev 3528)
+++ trunk/scipy/linalg/flinalg.py 2007-11-13 08:01:14 UTC (rev 3529)
@@ -29,7 +29,8 @@
ordering = []
for i in range(len(arrays)):
t = arrays[i].dtype.char
- if not _type_conv.has_key(t): t = 'd'
+ if t not in _type_conv:
+ t = 'd'
ordering.append((t,i))
if ordering:
ordering.sort()
Modified: trunk/scipy/linalg/lapack.py
===================================================================
--- trunk/scipy/linalg/lapack.py 2007-11-13 07:13:14 UTC (rev 3528)
+++ trunk/scipy/linalg/lapack.py 2007-11-13 08:01:14 UTC (rev 3529)
@@ -109,7 +109,7 @@
_colmajor_func_template = '''\
def %(func_name)s(*args,**kws):
- if not kws.has_key("rowmajor"):
+ if "rowmajor" not in kws:
kws["rowmajor"] = 0
return clapack_func(*args,**kws)
func_code = %(func_name)s.func_code
Modified: trunk/scipy/linsolve/linsolve.py
===================================================================
--- trunk/scipy/linsolve/linsolve.py 2007-11-13 07:13:14 UTC (rev 3528)
+++ trunk/scipy/linsolve/linsolve.py 2007-11-13 08:01:14 UTC (rev 3529)
@@ -28,7 +28,7 @@
sure that the matrix fulfills this, pass assumeSortedIndices=True
to gain some speed.
"""
- if kwargs.has_key( 'useUmfpack' ):
+ if 'useUmfpack' in kwargs:
globals()['useUmfpack'] = kwargs['useUmfpack']
if isUmfpack:
Modified: trunk/scipy/linsolve/umfpack/umfpack.py
===================================================================
--- trunk/scipy/linsolve/umfpack/umfpack.py 2007-11-13 07:13:14 UTC (rev 3528)
+++ trunk/scipy/linsolve/umfpack/umfpack.py 2007-11-13 08:01:14 UTC (rev 3529)
@@ -28,7 +28,7 @@
sure that the matrix fulfills this, pass assumeSortedIndices =
True to gain some speed.
"""
- if kwargs.has_key( 'assumeSortedIndices' ):
+ if 'assumeSortedIndices' in kwargs):
globals()['assumeSortedIndices'] = kwargs['assumeSortedIndices']
@@ -297,7 +297,7 @@
maxLen = max( [len( name ) for name in umfControls] )
format = '%%-%ds : %%d' % maxLen
aux = [format % (name, self.control[umfDefines[name]])
- for name in umfControls if umfDefines.has_key( name )]
+ for name in umfControls if name in umfDefines]
return '\n'.join( aux )
##
@@ -306,7 +306,7 @@
maxLen = max( [len( name ) for name in umfInfo] )
format = '%%-%ds : %%d' % maxLen
aux = [format % (name, self.info[umfDefines[name]])
- for name in umfInfo if umfDefines.has_key( name )]
+ for name in umfInfo if name in umfDefines]
return '\n'.join( aux )
##
@@ -508,7 +508,7 @@
# UMFPACK uses CSC internally...
if self.family in umfRealTypes: ii = 0
else: ii = 1
- if umfSys_transposeMap[ii].has_key( sys ):
+ if sys in umfSys_transposeMap[ii]:
sys = umfSys_transposeMap[ii][sys]
else:
raise RuntimeError, 'autoTranspose ambiguous, switch it off'
Modified: trunk/scipy/misc/ppimport.py
===================================================================
--- trunk/scipy/misc/ppimport.py 2007-11-13 07:13:14 UTC (rev 3528)
+++ trunk/scipy/misc/ppimport.py 2007-11-13 08:01:14 UTC (rev 3529)
@@ -101,7 +101,7 @@
return getattr(attr, name)
def __repr__(self):
- if self.__dict__.has_key('_ppimport_attr'):
+ if '_ppimport_attr' in self.__dict__:
return repr(self._ppimport_attr)
module = self.__dict__['_ppimport_attr_module']
name = self.__dict__['_ppimport_attr_name']
@@ -135,7 +135,7 @@
level = 1
parent_frame = p_frame = _get_frame(level)
- while not p_frame.f_locals.has_key('__name__'):
+ while '__name__' not in p_frame.f_locals:
level = level + 1
p_frame = _get_frame(level)
@@ -143,7 +143,7 @@
if p_name=='__main__':
p_dir = ''
fullname = name
- elif p_frame.f_locals.has_key('__path__'):
+ elif '__path__' in_frame.f_locals:
# python package
p_path = p_frame.f_locals['__path__']
p_dir = p_path[0]
@@ -310,9 +310,9 @@
except KeyError:
module = self._ppimport_importer()
return module.__repr__()
- if self.__dict__.has_key('_ppimport_module'):
+ if '_ppimport_module' in self.__dict__:
status = 'imported'
- elif self.__dict__.has_key('_ppimport_exc_info'):
+ elif '_ppimport_exc_info' in self.__dict__:
status = 'import error'
else:
status = 'import postponed'
@@ -356,7 +356,7 @@
if ignore_failure and not hasattr(a, b[-1]):
a = '.'.join(ns+b)
b = '.'.join(b)
- if sys.modules.has_key(b) and sys.modules[b] is None:
+ if b in sys.modules and sys.modules[b] is None:
del sys.modules[b]
return a
a = getattr(a,b[-1])
Modified: trunk/scipy/sandbox/ga/genome.py
===================================================================
--- trunk/scipy/sandbox/ga/genome.py 2007-11-13 07:13:14 UTC (rev 3528)
+++ trunk/scipy/sandbox/ga/genome.py 2007-11-13 08:01:14 UTC (rev 3529)
@@ -211,7 +211,7 @@
ga_list.ga_list.__init__(self,list)
def initialize(self,settings = None):
genome.initialize(self,settings)
- if settings and settings.has_key('p_mutate'):
+ if settings and 'p_mutate' in settings:
for g in self: g.set_mutation(settings['p_mutate'])
def clone(self):
"""This returns a new genome object. The new genome is a shallow copy
@@ -316,7 +316,7 @@
tried_sym = []
for i in range(tries):
sym,node_a = dict_choice(sis.symbol_table)
- if not self.bad_cross_point(sym) and bro.symbol_table.has_key(sym):
+ if not self.bad_cross_point(sym) and sym in bro.symbol_table:
break
elif i == (tries - 1):
msg = "chosen symbol not found in dad (%s tries)" % `tries`
@@ -342,7 +342,7 @@
node_a.set_parent(node_b.get_parent())
node_b.set_parent(temp)
sib1.evaluated = 0; sib2.evaluated = 0
- if self.cross_point.has_key(sym):
+ if sym in self.cross_point:
self.cross_point[sym] = self.cross_point[sym] + 1
else: self.cross_point[sym] = 1
return sib1,sib2
@@ -372,7 +372,7 @@
# def touch(self): calls genome touch because of inheritance order
def initialize(self,settings = None):
genome.initialize(self,settings)
- if settings and settings.has_key('p_mutate'):
+ if settings and 'p_mutate' in settings:
raise NotImplementedError
# XXX: what is g?
#g.root.set_mutation(settings['p_mutate'])
Modified: trunk/scipy/sandbox/ga/language.py
===================================================================
--- trunk/scipy/sandbox/ga/language.py 2007-11-13 07:13:14 UTC (rev 3528)
+++ trunk/scipy/sandbox/ga/language.py 2007-11-13 08:01:14 UTC (rev 3529)
@@ -37,7 +37,7 @@
else: self.derive_type = cur_sym.node_type
new_active_node = active_node
if type(cur_sym) == types.StringType:
- if self.lang.has_key(cur_sym):
+ if cur_sym in self.lang:
rule = prng.choice(self.lang[cur_sym])
for sym in rule:
new_active_node = self._gen(sym,new_active_node,depth)
Modified: trunk/scipy/sandbox/ga/tree.py
===================================================================
--- trunk/scipy/sandbox/ga/tree.py 2007-11-13 07:13:14 UTC (rev 3528)
+++ trunk/scipy/sandbox/ga/tree.py 2007-11-13 08:01:14 UTC (rev 3529)
@@ -87,7 +87,7 @@
"""
for child in self._children:
child._generate_symbol_table(symbol_table)
- if symbol_table.has_key(self.derive_type):
+ if self.derive_type in symbol_table:
symbol_table[self.derive_type].append(self)
else: symbol_table[self.derive_type] = [self]
@@ -206,11 +206,13 @@
# if not hasattr(self,'parent'):
# self.parent = weakdict.WeakDict()
# if parent: self.parent[0] = parent
-# elif self.parent.has_key(0): del self.parent[0]
+# elif 0 in self.parent:
+# del self.parent[0]
# print 'out set'
# def get_parent(self):
# print 'in get'
-# if self.parent.has_key(0): p = self.parent[0]
+# if 0 in self.parent:
+# p = self.parent[0]
# else: p = None
# print 'out get'
# return p
Modified: trunk/scipy/sandbox/maskedarray/testutils.py
===================================================================
--- trunk/scipy/sandbox/maskedarray/testutils.py 2007-11-13 07:13:14 UTC (rev 3528)
+++ trunk/scipy/sandbox/maskedarray/testutils.py 2007-11-13 08:01:14 UTC (rev 3529)
@@ -65,7 +65,7 @@
assert isinstance(actual, dict), repr(type(actual))
assert_equal(len(actual),len(desired),err_msg)
for k,i in desired.items():
- assert actual.has_key(k), repr(k)
+ assert k in actual, repr(k)
assert_equal(actual[k], desired[k], 'key=%r\n%s' % (k,err_msg))
return
# Case #2: lists .....
@@ -95,7 +95,7 @@
assert isinstance(actual, dict), repr(type(actual))
fail_if_equal(len(actual),len(desired),err_msg)
for k,i in desired.items():
- assert actual.has_key(k), repr(k)
+ assert k in actual, repr(k)
fail_if_equal(actual[k], desired[k], 'key=%r\n%s' % (k,err_msg))
return
if isinstance(desired, (list,tuple)) and isinstance(actual, (list,tuple)):
Modified: trunk/scipy/sandbox/netcdf/netcdf.py
===================================================================
--- trunk/scipy/sandbox/netcdf/netcdf.py 2007-11-13 07:13:14 UTC (rev 3528)
+++ trunk/scipy/sandbox/netcdf/netcdf.py 2007-11-13 08:01:14 UTC (rev 3529)
@@ -4,7 +4,7 @@
import sys
-if sys.modules.has_key('pythondoc'):
+if 'pythondoc' in sys.modules:
# Fake code just for the docstrings!
Modified: trunk/scipy/sandbox/newoptimize/log.py
===================================================================
--- trunk/scipy/sandbox/newoptimize/log.py 2007-11-13 07:13:14 UTC (rev 3528)
+++ trunk/scipy/sandbox/newoptimize/log.py 2007-11-13 08:01:14 UTC (rev 3529)
@@ -35,7 +35,7 @@
finished = False
if kwargs:
- if kwargs.has_key( 'finished' ):
+ if 'finished' in kwargs:
finished = kwargs['finished']
ls = len( args ), self.nArg
Modified: trunk/scipy/sandbox/timeseries/parser.py
===================================================================
--- trunk/scipy/sandbox/timeseries/parser.py 2007-11-13 07:13:14 UTC (rev 3528)
+++ trunk/scipy/sandbox/timeseries/parser.py 2007-11-13 08:01:14 UTC (rev 3529)
@@ -12,7 +12,8 @@
'DateFromString', 'DateTimeFromString'
]
-import types,re,string
+import types
+import re
import datetime as dt
class RangeError(Exception): pass
@@ -275,7 +276,7 @@
if not zone:
return 0
uzone = zone.upper()
- if _zonetable.has_key(uzone):
+ if uzone in _zonetable:
return _zonetable[uzone]*60
offset = _zoneoffsetRE.match(zone)
if not offset:
Modified: trunk/scipy/sandbox/timeseries/plotlib.py
===================================================================
--- trunk/scipy/sandbox/timeseries/plotlib.py 2007-11-13 07:13:14 UTC (rev 3528)
+++ trunk/scipy/sandbox/timeseries/plotlib.py 2007-11-13 08:01:14 UTC (rev 3529)
@@ -67,7 +67,7 @@
except TypeError:
key = str(key)
#
- if figure_instance._seen.has_key(key):
+ if key in figure_instance._seen:
ax = figure_instance._seen[key]
figure_instance.sca(ax)
return ax
Modified: trunk/scipy/stats/models/cox.py
===================================================================
--- trunk/scipy/stats/models/cox.py 2007-11-13 07:13:14 UTC (rev 3528)
+++ trunk/scipy/stats/models/cox.py 2007-11-13 08:01:14 UTC (rev 3529)
@@ -66,7 +66,7 @@
for i in range(len(subjects)):
s = subjects[i]
if s.delta:
- if not self.failures.has_key(s.time):
+ if s.time not in self.failures:
self.failures[s.time] = [i]
else:
self.failures[s.time].append(i)
Modified: trunk/scipy/stats/models/mixed.py
===================================================================
--- trunk/scipy/stats/models/mixed.py 2007-11-13 07:13:14 UTC (rev 3528)
+++ trunk/scipy/stats/models/mixed.py 2007-11-13 08:01:14 UTC (rev 3529)
@@ -36,7 +36,7 @@
perform a check whether formula just has an intercept in it, in
which case the number of rows must be computed.
"""
- if hasattr(self, 'n') and not extra.has_key('nrow'):
+ if hasattr(self, 'n') and 'nrow' not in extra:
extra['nrow'] = self.n
return formula(namespace=self.dict, **extra)
Modified: trunk/scipy/weave/build_tools.py
===================================================================
--- trunk/scipy/weave/build_tools.py 2007-11-13 07:13:14 UTC (rev 3528)
+++ trunk/scipy/weave/build_tools.py 2007-11-13 08:01:14 UTC (rev 3529)
@@ -83,7 +83,7 @@
# this is a screwy trick to get rid of a ton of warnings on Unix
distutils.sysconfig.get_config_vars()
- if distutils.sysconfig._config_vars.has_key('OPT'):
+ if 'OPT' in distutils.sysconfig._config_vars:
flags = distutils.sysconfig._config_vars['OPT']
flags = flags.replace('-Wall','')
distutils.sysconfig._config_vars['OPT'] = flags
@@ -103,7 +103,7 @@
# the user has also installed numerous packages in their own
# location.
#--------------------------------------------------------------------
- if os.environ.has_key('PYTHONINCLUDE'):
+ if 'PYTHONINCLUDE' in os.environ:
path_string = os.environ['PYTHONINCLUDE']
if sys.platform == "win32":
extra_include_dirs = path_string.split(';')
@@ -216,7 +216,7 @@
# this is a screwy trick to get rid of a ton of warnings on Unix
import distutils.sysconfig
distutils.sysconfig.get_config_vars()
- if distutils.sysconfig._config_vars.has_key('OPT'):
+ if 'OPT' in distutils.sysconfig._config_vars:
flags = distutils.sysconfig._config_vars['OPT']
flags = flags.replace('-Wall','')
distutils.sysconfig._config_vars['OPT'] = flags
Modified: trunk/scipy/weave/bytecodecompiler.py
===================================================================
--- trunk/scipy/weave/bytecodecompiler.py 2007-11-13 07:13:14 UTC (rev 3528)
+++ trunk/scipy/weave/bytecodecompiler.py 2007-11-13 08:01:14 UTC (rev 3529)
@@ -703,7 +703,7 @@
##################################################################
def evaluate(self, pc,code):
# See if we posted any forwards for this offset
- if self.forwards.has_key(pc):
+ if pc in self.forwards:
for f in self.forwards[pc]:
f()
self.forwards[pc] = []
@@ -948,7 +948,7 @@
# MEMBER POST #
##################################################################
def post(self,pc,action):
- if not self.forwards.has_key(pc):
+ if pc not in self.forwards:
self.forwards[pc] = []
self.forwards[pc].append(action)
return
Modified: trunk/scipy/weave/catalog.py
===================================================================
--- trunk/scipy/weave/catalog.py 2007-11-13 07:13:14 UTC (rev 3528)
+++ trunk/scipy/weave/catalog.py 2007-11-13 08:01:14 UTC (rev 3529)
@@ -371,7 +371,7 @@
directories. On Windows, a ';' separated list is used.
"""
paths = []
- if os.environ.has_key('PYTHONCOMPILED'):
+ if 'PYTHONCOMPILED' in os.environ:
path_string = os.environ['PYTHONCOMPILED']
if sys.platform == 'win32':
#probably should also look in registry
@@ -523,7 +523,7 @@
function_list = []
for path in self.build_search_order():
cat = get_catalog(path,mode)
- if cat is not None and cat.has_key(code):
+ if cat is not None and code in cat:
# set up the python path so that modules for this
# function can be loaded.
self.configure_path(cat,code)
@@ -565,7 +565,7 @@
# close the catalog
writable_cat.close()
return
- if writable_cat.has_key(code):
+ if code in writable_cat:
print 'repairing catalog by removing key'
del writable_cat[code]
@@ -573,7 +573,7 @@
# registered was a built-in function), so we have to check if the path
# exists before arbitrarily deleting it.
path_key = self.path_key(code)
- if writable_cat.has_key(path_key):
+ if path_key in writable_cat:
del writable_cat[path_key]
writable_cat.close()
@@ -603,7 +603,7 @@
for more info on the search path.
"""
# Fast!! try cache first.
- if self.cache.has_key(code):
+ if code in self.cache:
return self.cache[code]
# 2. Slow!! read previously compiled functions from disk.
@@ -633,7 +633,7 @@
"""
# 1. put it in the cache.
- if self.cache.has_key(code):
+ if code in self.cache:
if function not in self.cache[code]:
self.cache[code].insert(0,function)
else:
Modified: trunk/scipy/weave/tests/test_catalog.py
===================================================================
--- trunk/scipy/weave/tests/test_catalog.py 2007-11-13 07:13:14 UTC (rev 3528)
+++ trunk/scipy/weave/tests/test_catalog.py 2007-11-13 08:01:14 UTC (rev 3529)
@@ -102,7 +102,7 @@
class TestCatalog(NumpyTestCase):
def clear_environ(self):
- if os.environ.has_key('PYTHONCOMPILED'):
+ if 'PYTHONCOMPILED' in os.environ:
self.old_PYTHONCOMPILED = os.environ['PYTHONCOMPILED']
del os.environ['PYTHONCOMPILED']
else:
Modified: trunk/scipy/weave/tests/test_scxx_dict.py
===================================================================
--- trunk/scipy/weave/tests/test_scxx_dict.py 2007-11-13 07:13:14 UTC (rev 3528)
+++ trunk/scipy/weave/tests/test_scxx_dict.py 2007-11-13 08:01:14 UTC (rev 3529)
@@ -1,7 +1,8 @@
""" Test refcounting and behavior of SCXX.
"""
import time
-import os,sys
+import os
+import sys
from numpy.testing import *
set_package_path()
@@ -33,7 +34,7 @@
a = {}
a[key] = 12345
code = """
- return_val = a.has_key(key);
+ return_val = key in a;
"""
res = inline_tools.inline(code,['a','key'])
assert res
@@ -41,7 +42,7 @@
a = {}
a[1234] = 12345
code = """
- return_val = a.has_key(1234);
+ return_val = 1234 in a;
"""
res = inline_tools.inline(code,['a'])
assert res
@@ -49,7 +50,7 @@
a = {}
a[1234.] = 12345
code = """
- return_val = a.has_key(1234.);
+ return_val = 1234. in a;
"""
res = inline_tools.inline(code,['a'])
assert res
@@ -58,7 +59,7 @@
a[1+1j] = 12345
key = 1+1j
code = """
- return_val = a.has_key(key);
+ return_val = key in a;
"""
res = inline_tools.inline(code,['a','key'])
assert res
@@ -67,7 +68,7 @@
a = {}
a["b"] = 12345
code = """
- return_val = a.has_key("b");
+ return_val = "b" in a;
"""
res = inline_tools.inline(code,['a'])
assert res
@@ -76,7 +77,7 @@
a["b"] = 12345
key_name = "b"
code = """
- return_val = a.has_key(key_name);
+ return_val = key_name in a;
"""
res = inline_tools.inline(code,['a','key_name'])
assert res
@@ -84,7 +85,7 @@
a = {}
a["b"] = 12345
code = """
- return_val = a.has_key("c");
+ return_val = "c" in a;
"""
res = inline_tools.inline(code,['a'])
assert not res
@@ -207,11 +208,11 @@
a = {}
a[key] = 1
inline_tools.inline("a.del(key);",['a','key'])
- assert not a.has_key(key)
+ assert key not in a
a[key] = 1
before = sys.getrefcount(a), sys.getrefcount(key)
inline_tools.inline("a.del(key);",['a','key'])
- assert not a.has_key(key)
+ assert key not in a
after = sys.getrefcount(a), sys.getrefcount(key)
assert before[0] == after[0]
assert before[1] == after[1] + 1
More information about the Scipy-svn
mailing list