# Path: src/naima/extern/validator.py
# def validate_array(
#     name, value, domain=None, ndim=1, shape=None, physical_type=None
# ):
# 
#     validate_physical_type(name, value, physical_type)
# 
#     # First convert to a Numpy array:
#     if type(value) in [list, tuple]:
#         value = np.array(value)
# 
#     # Check the value is an array with the right number of dimensions
#     if not isinstance(value, np.ndarray) or value.ndim != ndim:
#         if ndim == 1:
#             raise TypeError("{0} should be a 1-d sequence".format(name))
#         else:
#             raise TypeError("{0} should be a {1:d}-d array".format(name, ndim))
# 
#     # Check that the shape matches that expected
#     if shape is not None and value.shape != shape:
#         if ndim == 1:
#             raise ValueError(
#                 "{0} has incorrect length (expected {1} but found {2})".format(
#                     name, shape[0], value.shape[0]
#                 )
#             )
#         else:
#             raise ValueError(
#                 "{0} has incorrect shape (expected {1} but found {2})".format(
#                     name, shape, value.shape
#                 )
#             )
# 
#     return value
# 
# def validate_scalar(name, value, domain=None, physical_type=None):
# 
#     validate_physical_type(name, value, physical_type)
# 
#     if not physical_type:
#         if not np.isscalar(value) or not np.isreal(value):
#             raise TypeError(
#                 "{0} should be a scalar floating point value".format(name)
#             )
# 
#     if domain == "positive":
#         if value < 0.0:
#             raise ValueError("{0} should be positive".format(name))
#     elif domain == "strictly-positive":
#         if value <= 0.0:
#             raise ValueError("{0} should be strictly positive".format(name))
#     elif domain == "negative":
#         if value > 0.0:
#             raise ValueError("{0} should be negative".format(name))
#     elif domain == "strictly-negative":
#         if value >= 0.0:
#             raise ValueError("{0} should be strictly negative".format(name))
#     elif type(domain) in [tuple, list] and len(domain) == 2:
#         if value < domain[0] or value > domain[-1]:
#             raise ValueError(
#                 "{0} should be in the range [{1}:{2}]".format(
#                     name, domain[0], domain[-1]
#                 )
#             )
# 
#     return value


import ast
import warnings
import astropy.units as u
import numpy as np
from astropy import log
from astropy.table import QTable, Table
from .extern.validator import validate_array, validate_scalar

    flux_error, flux_error_hi, flux_error_lo : :class:`~astropy.units.Quantity`
    array instance
        68% CL gaussian uncertainty of the flux [physical type ``flux`` or
        ``differential flux``]. Either ``flux_error`` (symmetrical uncertainty)
        or ``flux_error_hi`` and ``flux_error_lo`` (asymmetrical uncertainties)
        must be provided.

    energy_width, energy_lo, energy_hi : :class:`~astropy.units.Quantity` array
    instance, optional
        Width of the energy bins [physical type ``energy``]. Either
        ``energy_width`` (bin width) or ``energy_lo`` and ``energy_hi``
        (Energies of the lower and upper bin edges) can be provided. If none
        are provided, ``generate_energy_edges`` will be used.

    ul : boolean or int array, optional
        Boolean array indicating which of the flux values given in ``flux``
        correspond to upper limits.

    cl : float, optional
        Confidence level of the flux upper limits given by ``ul``.

    Returns
    -------
    data : :class:`astropy.table.QTable`
        Data stored in an astropy Table.
    """
    table = QTable()

    if cl is not None:

# Path: src/naima/extern/validator.py
# def validate_array(
#     name, value, domain=None, ndim=1, shape=None, physical_type=None
# ):
# 
#     validate_physical_type(name, value, physical_type)
# 
#     # First convert to a Numpy array:
#     if type(value) in [list, tuple]:
#         value = np.array(value)
# 
#     # Check the value is an array with the right number of dimensions
#     if not isinstance(value, np.ndarray) or value.ndim != ndim:
#         if ndim == 1:
#             raise TypeError("{0} should be a 1-d sequence".format(name))
#         else:
#             raise TypeError("{0} should be a {1:d}-d array".format(name, ndim))
# 
#     # Check that the shape matches that expected
#     if shape is not None and value.shape != shape:
#         if ndim == 1:
#             raise ValueError(
#                 "{0} has incorrect length (expected {1} but found {2})".format(
#                     name, shape[0], value.shape[0]
#                 )
#             )
#         else:
#             raise ValueError(
#                 "{0} has incorrect shape (expected {1} but found {2})".format(
#                     name, shape, value.shape
#                 )
#             )
# 
#     return value
# 
# def validate_scalar(name, value, domain=None, physical_type=None):
# 
#     validate_physical_type(name, value, physical_type)
# 
#     if not physical_type:
#         if not np.isscalar(value) or not np.isreal(value):
#             raise TypeError(
#                 "{0} should be a scalar floating point value".format(name)
#             )
# 
#     if domain == "positive":
#         if value < 0.0:
#             raise ValueError("{0} should be positive".format(name))
#     elif domain == "strictly-positive":
#         if value <= 0.0:
#             raise ValueError("{0} should be strictly positive".format(name))
#     elif domain == "negative":
#         if value > 0.0:
#             raise ValueError("{0} should be negative".format(name))
#     elif domain == "strictly-negative":
#         if value >= 0.0:
#             raise ValueError("{0} should be strictly negative".format(name))
#     elif type(domain) in [tuple, list] and len(domain) == 2:
#         if value < domain[0] or value > domain[-1]:
#             raise ValueError(
#                 "{0} should be in the range [{1}:{2}]".format(
#                     name, domain[0], domain[-1]
#                 )
#             )
# 
#     return value


# Path: src/naima/utils.py
import ast
import warnings
import astropy.units as u
import numpy as np
from astropy import log
from astropy.table import QTable, Table
from .extern.validator import validate_array, validate_scalar


    flux_error, flux_error_hi, flux_error_lo : :class:`~astropy.units.Quantity`
    array instance
        68% CL gaussian uncertainty of the flux [physical type ``flux`` or
        ``differential flux``]. Either ``flux_error`` (symmetrical uncertainty)
        or ``flux_error_hi`` and ``flux_error_lo`` (asymmetrical uncertainties)
        must be provided.

    energy_width, energy_lo, energy_hi : :class:`~astropy.units.Quantity` array
    instance, optional
        Width of the energy bins [physical type ``energy``]. Either
        ``energy_width`` (bin width) or ``energy_lo`` and ``energy_hi``
        (Energies of the lower and upper bin edges) can be provided. If none
        are provided, ``generate_energy_edges`` will be used.

    ul : boolean or int array, optional
        Boolean array indicating which of the flux values given in ``flux``
        correspond to upper limits.

    cl : float, optional
        Confidence level of the flux upper limits given by ``ul``.

    Returns
    -------
    data : :class:`astropy.table.QTable`
        Data stored in an astropy Table.
    """
    table = QTable()

    if cl is not None:

        cl = validate_scalar("cl", cl)