8000 Merge pull request #28984 from DimitriPapadopoulos/type== · numpy/numpy@5fe514b · GitHub
[go: up one dir, main page]

Skip to content

Commit 5fe514b

Browse files
authored
Merge pull request #28984 from DimitriPapadopoulos/type==
2 parents 1943e07 + 685890b commit 5fe514b

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

numpy/_core/shape_base.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,7 @@ def _block_check_depths_match(arrays, parent_index=[]):
587587
the choice of algorithm used using benchmarking wisdom.
588588
589589
"""
590-
if type(arrays) is tuple:
590+
if isinstance(arrays, tuple):
591591
# not strictly necessary, but saves us from:
592592
# - more than one way to do things - no point treating tuples like
593593
# lists
@@ -598,7 +598,7 @@ def _block_check_depths_match(arrays, parent_index=[]):
598598
'Only lists can be used to arrange blocks, and np.block does '
599599
'not allow implicit conversion from tuple to ndarray.'
600600
)
601-
elif type(arrays) is list and len(arrays) > 0:
601+
elif isinstance(arrays, list) and len(arrays) > 0:
602602
idxs_ndims = (_block_check_depths_match(arr, parent_index + [i])
603603
for i, arr in enumerate(arrays))
604604

@@ -618,7 +618,7 @@ def _block_check_depths_match(arrays, parent_index=[]):
618618
first_index = index
619619

620620
return first_index, max_arr_ndim, final_size
621-
elif type(arrays) is list and len(arrays) == 0:
621+
elif isinstance(arrays, list) and len(arrays) == 0:
622622
# We've 'bottomed out' on an empty list
623623
return parent_index + [None], 0, 0
624624
else:
@@ -770,7 +770,7 @@ def _block_dispatcher(arrays):
770770
# Use type(...) is list to match the behavior of np.block(), which special
771771
# cases list specifically rather than allowing for generic iterables or
772772
# tuple. Also, we know that list.__array_function__ will never exist.
773-
if type(arrays) is list:
773+
if isinstance(arrays, list):
774774
for subarrays in arrays:
775775
yield from _block_dispatcher(subarrays)
776776
else:

numpy/_core/tests/test_nditer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1486,7 +1486,7 @@ def test_iter_copy_casts_structured2():
14861486
# Array of two structured scalars:
14871487
for res in res1, res2:
14881488
# Cast to tuple by getitem, which may be weird and changeable?:
1489-
assert type(res["a"][0]) == tuple
1489+
assert isinstance(res["a"][0], tuple)
14901490
assert res["a"][0] == (1, 1)
14911491

14921492
for res in res1, res2:

numpy/lib/tests/test_io.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def strptime(s, fmt=None):
8282
2.5.
8383
8484
"""
85-
if type(s) == bytes:
85+
if isinstance(s, bytes):
8686
s = s.decode("latin1")
8787
return datetime(*time.strptime(s, fmt)[:3])
8888

numpy/polynomial/_polybase.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1016,7 +1016,7 @@ class domain in NumPy 1.4 and ``None`` in later versions.
10161016
if domain[0] == domain[1]:
10171017
domain[0] -= 1
10181018
domain[1] += 1
1019-
elif type(domain) is list and len(domain) == 0:
1019+
elif isinstance(domain, list) and len(domain) == 0:
10201020
domain = cls.domain
10211021

10221022
if window is None:
@@ -1064,7 +1064,7 @@ def fromroots(cls, roots, domain=[], window=None, symbol='x'):
10641064
[roots] = pu.as_series([roots], trim=False)
10651065
if domain is None:
10661066
domain = pu.getdomain(roots)
1067-
elif type(domain) is list and len(domain) == 0:
1067+
elif isinstance(domain, list) and len(domain) == 0:
10681068
domain = cls.domain
10691069

10701070
if window is None:

0 commit comments

Comments
 (0)
0