# 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
        ("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


def test_beta_diversity_braycurtis_nans(ocx, api_data):
    samples = ocx.Samples.where(project="4b53797444f846c4")
    mock_df = samples.to_df()
    mock_df.loc[:, :] = 0

    with mock.patch.object(samples, "to_df", return_value=mock_df):
        dm = samples.beta_diversity(metric=BetaDiversityMetric.BrayCurtis)

    assert isinstance(dm, skbio.stats.distance._base.DistanceMatrix)
    assert (dm.condensed_form() == 0.0).all()


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

    # must be a metric that exists

# 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

        ("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


def test_beta_diversity_braycurtis_nans(ocx, api_data):
    samples = ocx.Samples.where(project="4b53797444f846c4")
    mock_df = samples.to_df()
    mock_df.loc[:, :] = 0

    with mock.patch.object(samples, "to_df", return_value=mock_df):
        dm = samples.beta_diversity(metric=BetaDiversityMetric.BrayCurtis)

    assert isinstance(dm, skbio.stats.distance._base.DistanceMatrix)
    assert (dm.condensed_form() == 0.0).all()


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

    # must be a metric that exists

    with pytest.raises(OneCodexException) as e: