Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit912a167

Browse files
MNT: Use ininstance() instead of comparing type()
Not entirely equivalent, in case of derived classes. Yet, I believethe new behaviour is the desired behaviour.
1 parent4e628f4 commit912a167

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-
iftype(arrays)istuple:
590+
ifisinstance(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-
eliftype(arrays)islistandlen(arrays)>0:
601+
elifisinstance(arrays,list)andlen(arrays)>0:
602602
idxs_ndims= (_block_check_depths_match(arr,parent_index+ [i])
603603
fori,arrinenumerate(arrays))
604604

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

620620
returnfirst_index,max_arr_ndim,final_size
621-
eliftype(arrays)islistandlen(arrays)==0:
621+
elifisinstance(arrays,list)andlen(arrays)==0:
622622
# We've 'bottomed out' on an empty list
623623
returnparent_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-
iftype(arrays)islist:
773+
ifisinstance(arrays,list):
774774
forsubarraysinarrays:
775775
yieldfrom_block_dispatcher(subarrays)
776776
else:

‎numpy/distutils/command/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ def check_func(self, func,
321321
self._check_compiler()
322322
body= []
323323
ifdecl:
324-
iftype(decl)==str:
324+
ifisinstance(decl,str):
325325
body.append(decl)
326326
else:
327327
body.append("int %s (void);"%func)

‎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-
iftype(s)==bytes:
85+
ifisinstance(s,bytes):
8686
s=s.decode("latin1")
8787
returndatetime(*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
ifdomain[0]==domain[1]:
10171017
domain[0]-=1
10181018
domain[1]+=1
1019-
eliftype(domain)islistandlen(domain)==0:
1019+
elifisinstance(domain,list)andlen(domain)==0:
10201020
domain=cls.domain
10211021

10221022
ifwindowisNone:
@@ -1064,7 +1064,7 @@ def fromroots(cls, roots, domain=[], window=None, symbol='x'):
10641064
[roots]=pu.as_series([roots],trim=False)
10651065
ifdomainisNone:
10661066
domain=pu.getdomain(roots)
1067-
eliftype(domain)islistandlen(domain)==0:
1067+
elifisinstance(domain,list)andlen(domain)==0:
10681068
domain=cls.domain
10691069

10701070
ifwindowisNone:

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp