Improve exception type.

ImportError isn't really appropriate when there's no import involved.
This commit is contained in:
Aymeric Augustin
2019-12-23 21:23:08 +01:00
parent 4c09a96096
commit c8b0c1e551
5 changed files with 7 additions and 7 deletions

View File

@@ -324,7 +324,7 @@ def squad_convert_examples_to_features(
del new_features
if return_dataset == "pt":
if not is_torch_available():
raise ImportError("Pytorch must be installed to return a pytorch dataset.")
raise RuntimeError("PyTorch must be installed to return a PyTorch dataset.")
# Convert to Tensors and build dataset
all_input_ids = torch.tensor([f.input_ids for f in features], dtype=torch.long)
@@ -354,7 +354,7 @@ def squad_convert_examples_to_features(
return features, dataset
elif return_dataset == "tf":
if not is_tf_available():
raise ImportError("TensorFlow must be installed to return a TensorFlow dataset.")
raise RuntimeError("TensorFlow must be installed to return a TensorFlow dataset.")
def gen():
for ex in features: