summaryrefslogtreecommitdiff
path: root/numpy/core
diff options
context:
space:
mode:
authorEric Wieser <wieser.eric@gmail.com>2018-12-01 10:15:57 -0800
committerGitHub <noreply@github.com>2018-12-01 10:15:57 -0800
commite0122a4fc3bf9453220c2802a50c253a381b59c9 (patch)
tree24f7828dc7feeba92d6ca739b132818847952b18 /numpy/core
parent0ee245bc6df60b911fafe81a743ec2a68a063c20 (diff)
parente4c14fb48851bc38d59c57dd2c2ed4993f7f8a42 (diff)
downloadnumpy-e0122a4fc3bf9453220c2802a50c253a381b59c9.tar.gz
Merge pull request #12443 from rth/set-litteral
MAINT Use set litterals
Diffstat (limited to 'numpy/core')
-rw-r--r--numpy/core/_type_aliases.py2
-rw-r--r--numpy/core/einsumfunc.py4
-rw-r--r--numpy/core/numeric.py4
-rw-r--r--numpy/core/shape_base.py2
-rw-r--r--numpy/core/tests/test_dtype.py4
-rw-r--r--numpy/core/tests/test_scalarmath.py4
6 files changed, 10 insertions, 10 deletions
diff --git a/numpy/core/_type_aliases.py b/numpy/core/_type_aliases.py
index cce6c0425..d6e1a1fb7 100644
--- a/numpy/core/_type_aliases.py
+++ b/numpy/core/_type_aliases.py
@@ -60,7 +60,7 @@ for k, v in typeinfo.items():
else:
_concrete_typeinfo[k] = v
-_concrete_types = set(v.type for k, v in _concrete_typeinfo.items())
+_concrete_types = {v.type for k, v in _concrete_typeinfo.items()}
def _bits_of(obj):
diff --git a/numpy/core/einsumfunc.py b/numpy/core/einsumfunc.py
index 963c696ae..832ff3057 100644
--- a/numpy/core/einsumfunc.py
+++ b/numpy/core/einsumfunc.py
@@ -169,7 +169,7 @@ def _optimal_path(input_sets, output_set, idx_dict, memory_limit):
Examples
--------
>>> isets = [set('abd'), set('ac'), set('bdc')]
- >>> oset = set('')
+ >>> oset = set()
>>> idx_sizes = {'a': 1, 'b':2, 'c':3, 'd':4}
>>> _path__optimal_path(isets, oset, idx_sizes, 5000)
[(0, 2), (0, 1)]
@@ -340,7 +340,7 @@ def _greedy_path(input_sets, output_set, idx_dict, memory_limit):
Examples
--------
>>> isets = [set('abd'), set('ac'), set('bdc')]
- >>> oset = set('')
+ >>> oset = set()
>>> idx_sizes = {'a': 1, 'b':2, 'c':3, 'd':4}
>>> _path__greedy_path(isets, oset, idx_sizes, 5000)
[(0, 2), (0, 1)]
diff --git a/numpy/core/numeric.py b/numpy/core/numeric.py
index 0289add3b..8768cbe56 100644
--- a/numpy/core/numeric.py
+++ b/numpy/core/numeric.py
@@ -745,7 +745,7 @@ def require(a, dtype=None, requirements=None):
if not requirements:
return asanyarray(a, dtype=dtype)
else:
- requirements = set(possible_flags[x.upper()] for x in requirements)
+ requirements = {possible_flags[x.upper()] for x in requirements}
if 'E' in requirements:
requirements.remove('E')
@@ -754,7 +754,7 @@ def require(a, dtype=None, requirements=None):
subok = True
order = 'A'
- if requirements >= set(['C', 'F']):
+ if requirements >= {'C', 'F'}:
raise ValueError('Cannot specify both "C" and "F" order')
elif 'F' in requirements:
order = 'F'
diff --git a/numpy/core/shape_base.py b/numpy/core/shape_base.py
index 6d234e527..a529d2ad7 100644
--- a/numpy/core/shape_base.py
+++ b/numpy/core/shape_base.py
@@ -410,7 +410,7 @@ def stack(arrays, axis=0, out=None):
if not arrays:
raise ValueError('need at least one array to stack')
- shapes = set(arr.shape for arr in arrays)
+ shapes = {arr.shape for arr in arrays}
if len(shapes) != 1:
raise ValueError('all input arrays must have the same shape')
diff --git a/numpy/core/tests/test_dtype.py b/numpy/core/tests/test_dtype.py
index 8cde19612..c55751e3c 100644
--- a/numpy/core/tests/test_dtype.py
+++ b/numpy/core/tests/test_dtype.py
@@ -156,9 +156,9 @@ class TestRecord(object):
the dtype constructor.
"""
assert_raises(TypeError, np.dtype,
- dict(names=set(['A', 'B']), formats=['f8', 'i4']))
+ dict(names={'A', 'B'}, formats=['f8', 'i4']))
assert_raises(TypeError, np.dtype,
- dict(names=['A', 'B'], formats=set(['f8', 'i4'])))
+ dict(names=['A', 'B'], formats={'f8', 'i4'}))
def test_aligned_size(self):
# Check that structured dtypes get padded to an aligned size
diff --git a/numpy/core/tests/test_scalarmath.py b/numpy/core/tests/test_scalarmath.py
index a55f06b69..423e437f1 100644
--- a/numpy/core/tests/test_scalarmath.py
+++ b/numpy/core/tests/test_scalarmath.py
@@ -565,10 +565,10 @@ class TestMultiply(object):
# Some of this behaviour may be controversial and could be open for
# change.
accepted_types = set(np.typecodes["AllInteger"])
- deprecated_types = set('?')
+ deprecated_types = {'?'}
forbidden_types = (
set(np.typecodes["All"]) - accepted_types - deprecated_types)
- forbidden_types -= set('V') # can't default-construct void scalars
+ forbidden_types -= {'V'} # can't default-construct void scalars
for seq_type in (list, tuple):
seq = seq_type([1, 2, 3])