When detecting numpy, assign relavant variables outside the try block (#20739)

Summary:
When detecting the presence of NumPy using import, move numpy-related variable assignments outside the try block (i.e., to an else block) to improve readability.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/20739

Differential Revision: D15453916

Pulled By: ezyang

fbshipit-source-id: d3c37f2b290846be3c6a1462251cbb3e95d493be
This commit is contained in:
Hong Xu
2019-05-22 11:21:31 -07:00
committed by Facebook Github Bot
parent fd95947e68
commit 795a1a6ffa

View File

@ -594,10 +594,11 @@ main_link_args.extend(CAFFE2_LIBS)
try:
import numpy as np
NUMPY_INCLUDE_DIR = np.get_include()
USE_NUMPY = True
except ImportError:
USE_NUMPY = False
else:
NUMPY_INCLUDE_DIR = np.get_include()
USE_NUMPY = True
if USE_CUDA:
if IS_WINDOWS: