summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
authorJaime <jaime.frio@gmail.com>2015-11-07 21:00:01 +0100
committerJaime <jaime.frio@gmail.com>2015-11-07 21:00:01 +0100
commit694f628bb9bb0da4a05d279b22cdb0987e2b3203 (patch)
tree7017d8443b51a471af9098162ce415ac6dcfe507 /numpy
parent3a41be170909854ff666828b76e0b6e065faf354 (diff)
parentdef49ba8fa3fe252c26c210d7730ed5c3a42c60e (diff)
downloadnumpy-694f628bb9bb0da4a05d279b22cdb0987e2b3203.tar.gz
Merge pull request #6649 from sieben/dict_litteral
MAINT: Dictionary litteral
Diffstat (limited to 'numpy')
-rw-r--r--numpy/core/setup.py15
-rw-r--r--numpy/core/tests/test_item_selection.py7
-rw-r--r--numpy/core/tests/test_umath.py18
-rw-r--r--numpy/distutils/system_info.py16
-rw-r--r--numpy/distutils/tests/test_system_info.py17
-rw-r--r--numpy/f2py/capi_maps.py6
-rw-r--r--numpy/lib/format.py3
7 files changed, 33 insertions, 49 deletions
diff --git a/numpy/core/setup.py b/numpy/core/setup.py
index aa9e03e06..2e9e277af 100644
--- a/numpy/core/setup.py
+++ b/numpy/core/setup.py
@@ -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')
diff --git a/numpy/core/tests/test_item_selection.py b/numpy/core/tests/test_item_selection.py
index 5e9cadd8f..ddce20fe9 100644
--- a/numpy/core/tests/test_item_selection.py
+++ b/numpy/core/tests/test_item_selection.py
@@ -18,10 +18,9 @@ class TestTake(TestCase):
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.
diff --git a/numpy/core/tests/test_umath.py b/numpy/core/tests/test_umath.py
index ebf8e0380..541ad974b 100644
--- a/numpy/core/tests/test_umath.py
+++ b/numpy/core/tests/test_umath.py
@@ -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)
diff --git a/numpy/distutils/system_info.py b/numpy/distutils/system_info.py
index 0da13a7df..a0c6f44f7 100644
--- a/numpy/distutils/system_info.py
+++ b/numpy/distutils/system_info.py
@@ -470,15 +470,13 @@ class system_info(object):
):
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'))
diff --git a/numpy/distutils/tests/test_system_info.py b/numpy/distutils/tests/test_system_info.py
index f9d45319e..58ad05a59 100644
--- a/numpy/distutils/tests/test_system_info.py
+++ b/numpy/distutils/tests/test_system_info.py
@@ -64,15 +64,14 @@ class test_system_info(system_info):
):
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
diff --git a/numpy/f2py/capi_maps.py b/numpy/f2py/capi_maps.py
index 6e5293cc8..5270cabb5 100644
--- a/numpy/f2py/capi_maps.py
+++ b/numpy/f2py/capi_maps.py
@@ -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):
@@ -823,8 +822,7 @@ void
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:
diff --git a/numpy/lib/format.py b/numpy/lib/format.py
index 66a1b356c..a0f2c5497 100644
--- a/numpy/lib/format.py
+++ b/numpy/lib/format.py
@@ -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: