# Path: ndd/exceptions.py
# class NddError(Exception):
#     """Base class for ndd exceptions."""


import json
import logging
import numpy
import ndd.fnsb
from collections.abc import Mapping, MappingView
from types import GeneratorType
from ndd.exceptions import NddError
    if isinstance(counts, (Mapping, MappingView)):
        return numpy.fromiter(counts.values(), dtype=int)
    if isinstance(counts, (GeneratorType, map, filter)):
        return numpy.fromiter(counts, dtype=int)
    return numpy.asarray(counts)


def check_k(k):
    """
    if k is an integer, just check
    if an array set k = prod(k)
    if None, return

    Raises
    ------
    NddError
        If k is not valid (wrong type, negative, too large...)

    """
    MAX_LOGK = 200 * numpy.log(2)

    if k is None:
        return k
    try:
        k = numpy.float64(k)
    except ValueError:
        raise NddError('%r is not a valid cardinality' % k)
    if k.ndim:
        # if k is a sequence, set k = prod(k)
        if k.ndim > 1:

# Path: ndd/exceptions.py
# class NddError(Exception):
#     """Base class for ndd exceptions."""


# Path: ndd/counts.py
import json
import logging
import numpy
import ndd.fnsb
from collections.abc import Mapping, MappingView
from types import GeneratorType
from ndd.exceptions import NddError

    if isinstance(counts, (Mapping, MappingView)):
        return numpy.fromiter(counts.values(), dtype=int)
    if isinstance(counts, (GeneratorType, map, filter)):
        return numpy.fromiter(counts, dtype=int)
    return numpy.asarray(counts)


def check_k(k):
    """
    if k is an integer, just check
    if an array set k = prod(k)
    if None, return

    Raises
    ------
    NddError
        If k is not valid (wrong type, negative, too large...)

    """
    MAX_LOGK = 200 * numpy.log(2)

    if k is None:
        return k
    try:
        k = numpy.float64(k)
    except ValueError:
        raise NddError('%r is not a valid cardinality' % k)
    if k.ndim:
        # if k is a sequence, set k = prod(k)
        if k.ndim > 1:

            raise NddError('k must be a scalar or 1D array')