Skip to content

Commit

Permalink
#2922: Changed misleading variable name
Browse files Browse the repository at this point in the history
  • Loading branch information
Kischy committed Aug 21, 2019
1 parent 7986e5b commit d79e9c1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions testsuite/python/interactions_non-bonded.py
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,7 @@ def get_reference_force(gb_params, r, dir1, dir2):
force_ref[i] = tests_common.calc_derivative(
lambda x: get_reference_energy(gb_params, x, dir1, dir2),
x=r,
axis=i)
index=i)

return -force_ref

Expand All @@ -661,7 +661,7 @@ def get_reference_torque(gb_params, r, dir1, dir2):
force_in_dir1[i] = tests_common.calc_derivative(
lambda x: get_reference_energy(gb_params, r, x, dir2),
x=dir1,
axis=i)
index=i)

torque_ref = numpy.cross(-dir1, force_in_dir1)
return torque_ref
Expand Down
10 changes: 5 additions & 5 deletions testsuite/python/tests_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -596,16 +596,16 @@ def gay_berne_potential(r_ij, u_i, u_j, epsilon_0, sigma_0, mu, nu, k_1, k_2):
return 4. * epsilon * (rr**-12 - rr**-6)


def calc_derivative(func, x, eps=1.0e-7, axis=None):
if(axis is None):
def calc_derivative(func, x, eps=1.0e-7, index=None):
if(index is None):
x_plus = np.copy(x) + eps
x_minus = np.copy(x) - eps

elif(axis >= 0):
elif(index >= 0):
x_plus = np.copy(x)
x_minus = np.copy(x)
x_plus[axis] += eps
x_minus[axis] -= eps
x_plus[index] += eps
x_minus[index] -= eps

return (func(x_plus) - func(x_minus)) / (2.0 * eps)

Expand Down

0 comments on commit d79e9c1

Please sign in to comment.