# Path: treeCl/tasks.py
# def _fast_geo(tree1, tree2, normalise=False):
#     return getGeodesicDistance(tree1, tree2, normalise)
# 
# Path: treeCl/constants.py
# ISPY3 = sys.version_info.major>=3


import numpy as np
from scipy.spatial.distance import pdist, squareform
from .tasks import _fast_geo
from .constants import ISPY3
from tree_distance import PhyloTree



GOLDEN = (np.sqrt(5)-1)/2

# Functions for OutOfSampleMDS

def _eigen(mtx, inverse=False):
    if np.allclose(mtx, mtx.T):
        fn = np.linalg.eigh
    else:
        fn = np.linalg.eig
    vals, vecs = fn(mtx)
    ix = np.argsort(vals)[::-1]
    vals = vals[ix]
    vecs = vecs[:,ix]
    if inverse:
        return vecs, vals, np.linalg.inv(vecs)

# Path: treeCl/tasks.py
# def _fast_geo(tree1, tree2, normalise=False):
#     return getGeodesicDistance(tree1, tree2, normalise)
# 
# Path: treeCl/constants.py
# ISPY3 = sys.version_info.major>=3


# Path: treeCl/bootstrap.py
import numpy as np
from scipy.spatial.distance import pdist, squareform
from .tasks import _fast_geo
from .constants import ISPY3
from tree_distance import PhyloTree




GOLDEN = (np.sqrt(5)-1)/2

# Functions for OutOfSampleMDS

def _eigen(mtx, inverse=False):
    if np.allclose(mtx, mtx.T):
        fn = np.linalg.eigh
    else:
        fn = np.linalg.eig
    vals, vecs = fn(mtx)
    ix = np.argsort(vals)[::-1]
    vals = vals[ix]
    vecs = vecs[:,ix]
    if inverse:
        return vecs, vals, np.linalg.inv(vecs)

    return vecs, vals