Skip to content

Commit

Permalink
Merge pull request #221 from dswah/filter-warnings
Browse files Browse the repository at this point in the history
Filter warnings
  • Loading branch information
dswah authored Oct 26, 2018
2 parents 1f93d98 + 9abdc2d commit 349473c
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions pygam/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,16 +218,15 @@ def check_y(y, link, dist, min_samples=1, verbose=True):
y = check_array(y, force_2d=False, min_samples=min_samples, ndim=1,
name='y data', verbose=verbose)

warnings.filterwarnings('ignore', 'divide by zero encountered in log')
warnings.filterwarnings('ignore', 'invalid value encountered in log')
if np.any(np.isnan(link.link(y, dist))):
raise ValueError('y data is not in domain of {} link function. ' \
'Expected domain: {}, but found {}' \
.format(link, get_link_domain(link, dist),
[float('%.2f'%np.min(y)),
float('%.2f'%np.max(y))]))
warnings.resetwarnings()

with warnings.catch_warnings():
warnings.simplefilter("ignore")

if np.any(np.isnan(link.link(y, dist))):
raise ValueError('y data is not in domain of {} link function. ' \
'Expected domain: {}, but found {}' \
.format(link, get_link_domain(link, dist),
[float('%.2f'%np.min(y)),
float('%.2f'%np.max(y))]))
return y

def check_X(X, n_feats=None, min_samples=1, edge_knots=None, dtypes=None,
Expand Down

0 comments on commit 349473c

Please sign in to comment.