Skip to content

Commit

Permalink
MAINT: Dictionary litteral
Browse files Browse the repository at this point in the history
  • Loading branch information
remyleone committed Nov 7, 2015
1 parent 98f8f9c commit def49ba
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 49 deletions.
15 changes: 4 additions & 11 deletions numpy/core/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,17 +257,10 @@ def check_types(config_cmd, ext, build_dir):
# Expected size (in number of bytes) for each type. This is an
# optimization: those are only hints, and an exhaustive search for the size
# is done if the hints are wrong.
expected = {}
expected['short'] = [2]
expected['int'] = [4]
expected['long'] = [8, 4]
expected['float'] = [4]
expected['double'] = [8]
expected['long double'] = [16, 12, 8]
expected['Py_intptr_t'] = [8, 4]
expected['PY_LONG_LONG'] = [8]
expected['long long'] = [8]
expected['off_t'] = [8, 4]
expected = {'short': [2], 'int': [4], 'long': [8, 4],
'float': [4], 'double': [8], 'long double': [16, 12, 8],
'Py_intptr_t': [8, 4], 'PY_LONG_LONG': [8], 'long long': [8],
'off_t': [8, 4]}

# Check we have the python header (-dev* packages on Linux)
result = config_cmd.check_header('Python.h')
Expand Down
7 changes: 3 additions & 4 deletions numpy/core/tests/test_item_selection.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@ def test_simple(self):
index_arrays = [np.empty(0, dtype=np.intp),
np.empty(tuple(), dtype=np.intp),
np.empty((1, 1), dtype=np.intp)]
real_indices = {}
real_indices['raise'] = {-1:1, 4:IndexError}
real_indices['wrap'] = {-1:1, 4:0}
real_indices['clip'] = {-1:0, 4:1}
real_indices = {'raise': {-1: 1, 4: IndexError},
'wrap': {-1: 1, 4: 0},
'clip': {-1: 0, 4: 1}}
# Currently all types but object, use the same function generation.
# So it should not be necessary to test all. However test also a non
# refcounted struct on top of object.
Expand Down
18 changes: 8 additions & 10 deletions numpy/core/tests/test_umath.py
Original file line number Diff line number Diff line change
Expand Up @@ -1836,16 +1836,14 @@ def test_spacing_gfortran():
# WRITE(*,*) spacing(1000._SGL)
# WRITE(*,*) spacing(10500._SGL)
# END PROGRAM
ref = {}
ref[np.float64] = [1.69406589450860068E-021,
2.22044604925031308E-016,
1.13686837721616030E-013,
1.81898940354585648E-012]
ref[np.float32] = [
9.09494702E-13,
1.19209290E-07,
6.10351563E-05,
9.76562500E-04]
ref = {np.float64: [1.69406589450860068E-021,
2.22044604925031308E-016,
1.13686837721616030E-013,
1.81898940354585648E-012],
np.float32: [9.09494702E-13,
1.19209290E-07,
6.10351563E-05,
9.76562500E-04]}

for dt, dec_ in zip([np.float32, np.float64], (10, 20)):
x = np.array([1e-5, 1, 1000, 10500], dtype=dt)
Expand Down
16 changes: 7 additions & 9 deletions numpy/distutils/system_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -470,15 +470,13 @@ def __init__(self,
):
self.__class__.info = {}
self.local_prefixes = []
defaults = {}
defaults['library_dirs'] = os.pathsep.join(default_lib_dirs)
defaults['include_dirs'] = os.pathsep.join(default_include_dirs)
defaults['runtime_library_dirs'] = os.pathsep.join(default_runtime_dirs)
defaults['rpath'] = ''
defaults['src_dirs'] = os.pathsep.join(default_src_dirs)
defaults['search_static_first'] = str(self.search_static_first)
defaults['extra_compile_args'] = ''
defaults['extra_link_args'] = ''
defaults = {'library_dirs': os.pathsep.join(default_lib_dirs),
'include_dirs': os.pathsep.join(default_include_dirs),
'runtime_library_dirs': os.pathsep.join(default_runtime_dirs),
'rpath': '',
'src_dirs': os.pathsep.join(default_src_dirs),
'search_static_first': str(self.search_static_first),
'extra_compile_args': '', 'extra_link_args': ''}
self.cp = ConfigParser(defaults)
self.files = []
self.files.extend(get_standard_file('.numpy-site.cfg'))
Expand Down
17 changes: 8 additions & 9 deletions numpy/distutils/tests/test_system_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,14 @@ def __init__(self,
):
self.__class__.info = {}
self.local_prefixes = []
defaults = {}
defaults['library_dirs'] = ''
defaults['include_dirs'] = ''
defaults['runtime_library_dirs'] = ''
defaults['rpath'] = ''
defaults['src_dirs'] = ''
defaults['search_static_first'] = "0"
defaults['extra_compile_args'] = ''
defaults['extra_link_args'] = ''
defaults = {'library_dirs': '',
'include_dirs': '',
'runtime_library_dirs': '',
'rpath': '',
'src_dirs': '',
'search_static_first': "0",
'extra_compile_args': '',
'extra_link_args': ''}
self.cp = ConfigParser(defaults)
# We have to parse the config files afterwards
# to have a consistent temporary filepath
Expand Down
6 changes: 2 additions & 4 deletions numpy/f2py/capi_maps.py
Original file line number Diff line number Diff line change
Expand Up @@ -519,8 +519,7 @@ def sign2map(a, var):
if k[:4] == 'out=':
out_a = k[4:]
break
ret = {'varname': a, 'outvarname': out_a}
ret['ctype'] = getctype(var)
ret = {'varname': a, 'outvarname': out_a, 'ctype': getctype(var)}
intent_flags = []
for f, s in isintent_dict.items():
if f(var):
Expand Down Expand Up @@ -823,8 +822,7 @@ def cb_routsign2map(rout, um):


def common_sign2map(a, var): # obsolute
ret = {'varname': a}
ret['ctype'] = getctype(var)
ret = {'varname': a, 'ctype': getctype(var)}
if isstringarray(var):
ret['ctype'] = 'char'
if ret['ctype'] in c2capi_map:
Expand Down
3 changes: 1 addition & 2 deletions numpy/lib/format.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,7 @@ def header_data_from_array_1_0(array):
This has the appropriate entries for writing its string representation
to the header of the file.
"""
d = {}
d['shape'] = array.shape
d = {'shape': array.shape}
if array.flags.c_contiguous:
d['fortran_order'] = False
elif array.flags.f_contiguous:
Expand Down

0 comments on commit def49ba

Please sign in to comment.