Skip to content

Commit

Permalink
Fixed unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffrey-hokanson committed Nov 27, 2018
1 parent c49dfc4 commit 0cc4aad
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions psdr/opt/check_gradient.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import numpy as np

def check_gradient(f, x, grad, verbose = False):
def check_gradient(f, x, grad, verbose = True):
grad_est_best = np.zeros(grad.shape)
for h in np.logspace(-14, -2,20):
grad_est = np.zeros(grad.shape)
Expand All @@ -20,5 +20,5 @@ def check_gradient(f, x, grad, verbose = False):
print "index, grad, grad est., ratio"
for i in np.ndindex(grad.shape):
print i, "%+5.2e %+5.2e %+5.2e" %(grad[i], grad_est_best[i], grad[i]/grad_est_best[i])

return np.max(np.abs( (grad - grad_est_best)/grad ))
np.max(np.abs( (grad - grad_est_best)/(np.abs(grad)+1e-10) ))
2 changes: 1 addition & 1 deletion psdr/poly_ridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import scipy.linalg
from scipy.linalg import norm
from scipy.linalg import svd
from scipy.misc import comb
from scipy.special import comb
from scipy.optimize import minimize, check_grad
from scipy.spatial import Voronoi
from copy import deepcopy
Expand Down
2 changes: 1 addition & 1 deletion tests/test_ridge.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import numpy as np
from psdr.poly_ridge import residual, build_J, LegendreTensorBasis
from psdr.util import check_gradient
from psdr.opt import check_gradient


def test_jacobian():
Expand Down

0 comments on commit 0cc4aad

Please sign in to comment.