Skip to content

Commit b85cc70

Browse files
committed
fix: replace bare except and generic Exception with specific types
1 parent b0359af commit b85cc70

5 files changed

Lines changed: 5 additions & 5 deletions

File tree

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def linkcode_resolve(domain, info):
8383
file = inspect.getsourcefile(obj)
8484
if file is None:
8585
return None
86-
except:
86+
except Exception:
8787
return None
8888

8989
file = os.path.relpath(file, start=os.path.abspath(".."))

numpy_ml/nonparametric/gp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
try:
66
_SCIPY = True
77
from scipy.stats import norm
8-
except:
8+
except ImportError:
99
_SCIPY = False
1010
warnings.warn(
1111
"Could not import scipy.stats. Confidence scores "

numpy_ml/nonparametric/knn.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def fit(self, X, y):
5656
Targets for the `N` rows in `X`.
5757
"""
5858
if X.ndim != 2:
59-
raise Exception("X must be two-dimensional")
59+
raise ValueError("X must be two-dimensional")
6060
self._ball_tree.fit(X, y)
6161

6262
def predict(self, X):

numpy_ml/preprocessing/general.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ def transform(self, X):
238238
The feature-wise standardized version of `X`.
239239
"""
240240
if not self._is_fit:
241-
raise Exception("Must call `fit` before using the `transform` method")
241+
raise RuntimeError("Must call `fit` before using the `transform` method")
242242
return (X - self._mean) / self._std
243243

244244
def inverse_transform(self, Z):

numpy_ml/rl_models/trainer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def plot_rewards(self, rwd_greedy):
122122
# https://seaborn.pydata.org/generated/seaborn.set_style.html
123123
sns.set_style("white")
124124
sns.set_context("notebook", font_scale=1)
125-
except:
125+
except ImportError:
126126
fstr = "Error importing `matplotlib` and `seaborn` -- plotting functionality is disabled"
127127
raise ImportError(fstr)
128128

0 commit comments

Comments
 (0)