2
0
mirror of https://github.com/Shawn-Shan/fawkes.git synced 2024-09-20 07:26:37 +05:30

Use ==/!= to compare constant literals (str, bytes, int, float, tuple)

Avoid [SyntaxWarnings on Python >= 3.8](https://docs.python.org/3/whatsnew/3.8.html#porting-to-python-3-8).

% `python3.8`
```
>>> 0 is 0
<stdin>:1: SyntaxWarning: "is" with a literal. Did you mean "=="?
```
This commit is contained in:
Christian Clauss 2020-07-24 23:02:39 +02:00 committed by GitHub
parent 0180c98e20
commit b61dfadb97
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,3 +1,4 @@
import errno
import glob import glob
import gzip import gzip
import json import json
@ -243,9 +244,9 @@ def fix_gpu_memory(mem_fraction=1):
def preprocess(X, method): def preprocess(X, method):
assert method in {'raw', 'imagenet', 'inception', 'mnist'} assert method in {'raw', 'imagenet', 'inception', 'mnist'}
if method is 'raw': if method == 'raw':
pass pass
elif method is 'imagenet': elif method == 'imagenet':
X = imagenet_preprocessing(X) X = imagenet_preprocessing(X)
else: else:
raise Exception('unknown method %s' % method) raise Exception('unknown method %s' % method)
@ -256,9 +257,9 @@ def preprocess(X, method):
def reverse_preprocess(X, method): def reverse_preprocess(X, method):
assert method in {'raw', 'imagenet', 'inception', 'mnist'} assert method in {'raw', 'imagenet', 'inception', 'mnist'}
if method is 'raw': if method == 'raw':
pass pass
elif method is 'imagenet': elif method == 'imagenet':
X = imagenet_reverse_preprocessing(X) X = imagenet_reverse_preprocessing(X)
else: else:
raise Exception('unknown method %s' % method) raise Exception('unknown method %s' % method)