Skip to content

Commit

Permalink
test for gamma/theta parameter confusion
Browse files Browse the repository at this point in the history
  • Loading branch information
scottgigante committed Nov 22, 2018
1 parent 305a861 commit 73528d9
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
9 changes: 9 additions & 0 deletions graphtools/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,16 @@ class BaseGraph(with_metaclass(abc.ABCMeta, Base)):

def __init__(self, kernel_symm='+',
theta=None,
gamma=None,
initialize=True, **kwargs):
if gamma is not None:
warnings.warn("gamma is deprecated. "
"Setting theta={}".format(gamma), FutureWarning)
theta = gamma
if kernel_symm == 'gamma':
warnings.warn("kernel_symm='gamma' is deprecated. "
"Setting kernel_symm='theta'", FutureWarning)
kernel_symm = 'theta'
self.kernel_symm = kernel_symm
self.theta = theta
self._check_symmetrization(kernel_symm, theta)
Expand Down
21 changes: 21 additions & 0 deletions test/test_mnn.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
generate_swiss_roll,
assert_raises,
raises,
warns,
cdist,
)
from scipy.linalg import norm
Expand Down Expand Up @@ -74,6 +75,26 @@ def test_mnn_with_vector_theta():
theta=np.linspace(0, 1, n_sample - 1))


@warns(FutureWarning)
def test_mnn_with_gamma():
build_graph(
data, thresh=0, n_pca=20,
decay=10, knn=5, random_state=42,
sample_idx=digits['target'],
kernel_symm='theta',
gamma=0.9)


@warns(FutureWarning)
def test_mnn_with_kernel_symm_gamma():
build_graph(
data, thresh=0, n_pca=20,
decay=10, knn=5, random_state=42,
sample_idx=digits['target'],
kernel_symm='gamma',
theta=0.9)


def test_mnn_with_non_zero_indexed_sample_idx():
X, sample_idx = generate_swiss_roll()
G = build_graph(X, sample_idx=sample_idx,
Expand Down

0 comments on commit 73528d9

Please sign in to comment.