# Path: onecodex/exceptions.py
# class OneCodexException(Exception):
#     pass
# 
# Path: onecodex/lib/enums.py
# class BetaDiversityMetric(BaseEnum):
#     Jaccard = "jaccard"
#     BrayCurtis = "braycurtis"
#     CityBlock = "cityblock"
#     Manhattan = "manhattan"
#     WeightedUnifrac = "weighted_unifrac"
#     UnweightedUnifrac = "unweighted_unifrac"
#     Aitchison = "aitchison"


import mock
import pytest
import pandas as pd
import skbio
from onecodex.exceptions import OneCodexException
from onecodex.lib.enums import BetaDiversityMetric

    # must be a metric that exists
    with pytest.raises(OneCodexException) as e:
        samples.alpha_diversity("does_not_exist")
    assert "metric must be one of" in str(e.value)


def test_alpha_diversity_warnings(ocx, api_data):
    samples = ocx.Samples.where(project="4b53797444f846c4")

    with pytest.warns(DeprecationWarning, match="`Chao1` is deprecated"):
        samples.alpha_diversity(metric="chao1")


@pytest.mark.parametrize(
    "metric,value,kwargs",
    [
        ("braycurtis", [0.886014, 0.84694, 0.905716], {}),
        ("cityblock", [1.772028, 1.693879, 1.811432], {}),
        ("manhattan", [1.772028, 1.693879, 1.811432], {}),
        ("jaccard", [0.742616, 0.697561, 0.752632], {}),
        ("unweighted_unifrac", [0.6, 0.547486, 0.591304], {}),
        ("weighted_unifrac", [0.503168, 0.403155, 0.605155], {}),
        ("aitchison", [59.800677, 51.913911, 52.693709], {}),
    ],
)
def test_beta_diversity(ocx, api_data, metric, value, kwargs):
    samples = ocx.Samples.where(project="4b53797444f846c4")
    dm = samples.beta_diversity(metric=metric, **kwargs)
    assert isinstance(dm, skbio.stats.distance._base.DistanceMatrix)

# Path: onecodex/exceptions.py
# class OneCodexException(Exception):
#     pass
# 
# Path: onecodex/lib/enums.py
# class BetaDiversityMetric(BaseEnum):
#     Jaccard = "jaccard"
#     BrayCurtis = "braycurtis"
#     CityBlock = "cityblock"
#     Manhattan = "manhattan"
#     WeightedUnifrac = "weighted_unifrac"
#     UnweightedUnifrac = "unweighted_unifrac"
#     Aitchison = "aitchison"


# Path: tests/test_distance.py
import mock
import pytest
import pandas as pd
import skbio
from onecodex.exceptions import OneCodexException
from onecodex.lib.enums import BetaDiversityMetric


    # must be a metric that exists
    with pytest.raises(OneCodexException) as e:
        samples.alpha_diversity("does_not_exist")
    assert "metric must be one of" in str(e.value)


def test_alpha_diversity_warnings(ocx, api_data):
    samples = ocx.Samples.where(project="4b53797444f846c4")

    with pytest.warns(DeprecationWarning, match="`Chao1` is deprecated"):
        samples.alpha_diversity(metric="chao1")


@pytest.mark.parametrize(
    "metric,value,kwargs",
    [
        ("braycurtis", [0.886014, 0.84694, 0.905716], {}),
        ("cityblock", [1.772028, 1.693879, 1.811432], {}),
        ("manhattan", [1.772028, 1.693879, 1.811432], {}),
        ("jaccard", [0.742616, 0.697561, 0.752632], {}),
        ("unweighted_unifrac", [0.6, 0.547486, 0.591304], {}),
        ("weighted_unifrac", [0.503168, 0.403155, 0.605155], {}),
        ("aitchison", [59.800677, 51.913911, 52.693709], {}),
    ],
)
def test_beta_diversity(ocx, api_data, metric, value, kwargs):
    samples = ocx.Samples.where(project="4b53797444f846c4")
    dm = samples.beta_diversity(metric=metric, **kwargs)
    assert isinstance(dm, skbio.stats.distance._base.DistanceMatrix)

    assert dm.condensed_form().round(6).tolist() == value