Skip to content

Commit

Permalink
Merge pull request #10 from KrishnaswamyLab/dev
Browse files Browse the repository at this point in the history
Bump version to 0.1.4
  • Loading branch information
scottgigante committed Jun 12, 2018
2 parents 6a28922 + 62acd69 commit ae09095
Show file tree
Hide file tree
Showing 11 changed files with 273 additions and 184 deletions.
68 changes: 25 additions & 43 deletions graphtools/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ def Graph(data,
decay=10,
distance='euclidean',
thresh=1e-4,
kernel_symm='+',
gamma=None,
n_landmark=None,
n_svd=100,
beta=1,
gamma=0.5,
n_jobs=-1,
verbose=False,
random_state=None,
Expand Down Expand Up @@ -71,6 +72,17 @@ def Graph(data,
All affinities below `thresh` will be set to zero in order to save
on time and memory constraints.
kernel_symm : string, optional (default: '+')
Defines method of MNN symmetrization.
'+' : additive
'*' : multiplicative
'gamma' : min-max
'none' : no symmetrization
gamma: float (default: None)
Min-max symmetrization constant or matrix. Only used if kernel_symm='gamma'.
K = `gamma * min(K, K.T) + (1 - gamma) * max(K, K.T)`
precomputed : {'distance', 'affinity', 'adjacency', `None`}, optional (default: `None`)
If the graph is precomputed, this variable denotes which graph
matrix is provided as `data`.
Expand All @@ -79,11 +91,6 @@ def Graph(data,
beta: float, optional(default: 1)
Multiply within - batch connections by(1 - beta)
gamma: float or {'+', '*'} (default: 0.99)
Symmetrization method. If '+', use `(K + K.T) / 2`,
if '*', use `K * K.T`, if a float, use
`gamma * min(K, K.T) + (1 - gamma) * max(K, K.T)`
sample_idx: array-like
Batch index for MNN kernel
Expand Down Expand Up @@ -205,44 +212,19 @@ class Graph(parent_classes[0], parent_classes[1]):
class Graph(parent_classes[0], parent_classes[1], parent_classes[2]):
pass
else:
raise RuntimeError("unknown graph classes")
raise RuntimeError("unknown graph classes {}".format(parent_classes))

params = kwargs
for parent_class in parent_classes:
for param in parent_class._get_param_names():
try:
params[param] = eval(param)
except NameError:
# keyword argument not specified above - no problem
pass

# build graph and return
log_debug("Initializing {} with arguments {}".format(
parent_classes,
{
'n_pca': n_pca,
'sample_idx': sample_idx,
'adaptive_k': adaptive_k,
'precomputed': precomputed,
'knn': knn,
'decay': decay,
'distance': distance,
'thresh': thresh,
'n_landmark': n_landmark,
'n_svd': n_svd,
'beta': beta,
'gamma': gamma,
'n_jobs': n_jobs,
'verbose': verbose,
'random_state': random_state,
'initialize': initialize
}))
return Graph(data,
n_pca=n_pca,
sample_idx=sample_idx,
adaptive_k=adaptive_k,
precomputed=precomputed,
knn=knn,
decay=decay,
distance=distance,
thresh=thresh,
n_landmark=n_landmark,
n_svd=n_svd,
beta=beta,
gamma=gamma,
n_jobs=n_jobs,
verbose=verbose,
random_state=random_state,
initialize=initialize,
**kwargs)
params))
return Graph(**params)

0 comments on commit ae09095

Please sign in to comment.