# Path: ndd/entry.py
# def compute_estimate(data, k=None, estimator=None, alpha=None):
#     """Entropy estimation given data."""
# 
#     zk = None
#     if isinstance(data, dict) and 'nk' in data:
#         nk = data['nk']
#         k = k or data.get('k', None)
#         zk = data.get('zk', None)
#     else:
#         # list of integers counts or mapping to ints
#         nk = data
# 
#     if estimator is not None:
#         try:
#             algorithm = ndd.entropy_estimators[estimator]
#         except KeyError:
#             raise ValueError('Invalid estimator. Available estimators:\n'
#                              '%s' % available_estimators)
#         if alpha is not None:  # use alpha only if the estimator is given
#             try:
#                 estimator = algorithm(alpha=alpha)
#             except TypeError:
#                 estimator = algorithm()
#     else:
#         estimator = None
# 
#     if zk:
#         _ = ndd.entropy((nk, zk), k=k, estimator=estimator)
#     else:
#         _ = ndd.entropy(nk, k=k, estimator=estimator)
# 
#     return ndd.entropy.info


from ndd.entry import compute_estimate
# -*- coding: utf-8 -*-
# pylint: disable=missing-docstring
# pylint: disable=redefined-outer-name
"""Counts class module."""

X = [2, 1, 1, 1, 3]
K = 100


def test_dict():
    data = {k: x for k, x in enumerate(X)}
    assert compute_estimate(X) == compute_estimate(data)


def test_dict_with_alphabet_size():
    data = {'nk': {k: x for k, x in enumerate(X)}, 'k': K}

# Path: ndd/entry.py
# def compute_estimate(data, k=None, estimator=None, alpha=None):
#     """Entropy estimation given data."""
# 
#     zk = None
#     if isinstance(data, dict) and 'nk' in data:
#         nk = data['nk']
#         k = k or data.get('k', None)
#         zk = data.get('zk', None)
#     else:
#         # list of integers counts or mapping to ints
#         nk = data
# 
#     if estimator is not None:
#         try:
#             algorithm = ndd.entropy_estimators[estimator]
#         except KeyError:
#             raise ValueError('Invalid estimator. Available estimators:\n'
#                              '%s' % available_estimators)
#         if alpha is not None:  # use alpha only if the estimator is given
#             try:
#                 estimator = algorithm(alpha=alpha)
#             except TypeError:
#                 estimator = algorithm()
#     else:
#         estimator = None
# 
#     if zk:
#         _ = ndd.entropy((nk, zk), k=k, estimator=estimator)
#     else:
#         _ = ndd.entropy(nk, k=k, estimator=estimator)
# 
#     return ndd.entropy.info


# Path: tests/test_entry.py
from ndd.entry import compute_estimate

# -*- coding: utf-8 -*-
# pylint: disable=missing-docstring
# pylint: disable=redefined-outer-name
"""Counts class module."""

X = [2, 1, 1, 1, 3]
K = 100


def test_dict():
    data = {k: x for k, x in enumerate(X)}
    assert compute_estimate(X) == compute_estimate(data)


def test_dict_with_alphabet_size():
    data = {'nk': {k: x for k, x in enumerate(X)}, 'k': K}

    assert compute_estimate(X, k=K) == compute_estimate(data)