# 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
    if "ul" in data_table.keys():
        # Check if it is a integer or boolean flag
        ul_col = data_table["ul"]
        if ul_col.dtype.type is np.int_ or ul_col.dtype.type is np.bool_:
            data["ul"] = np.array(ul_col, dtype=bool)
        elif ul_col.dtype.type is np.str_:
            strbool = True
            for ul in ul_col:
                if ul != "True" and ul != "False":
                    strbool = False
            if strbool:
                data["ul"] = np.array(
                    [ast.literal_eval(ul) for ul in ul_col], dtype=bool
                )
            else:
                raise TypeError("UL column is in wrong format")
        else:
            raise TypeError("UL column is in wrong format")
    else:
        data["ul"] = np.array([False] * len(data["energy"]))

    if "flux_ul" in data_table.keys():
        data["flux"][data["ul"]] = u.Quantity(data_table["flux_ul"])[
            data["ul"]
        ]

    HAS_CL = False
    if "keywords" in data_table.meta.keys():
        if "cl" in data_table.meta["keywords"].keys():
            HAS_CL = True

# 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

    if "ul" in data_table.keys():
        # Check if it is a integer or boolean flag
        ul_col = data_table["ul"]
        if ul_col.dtype.type is np.int_ or ul_col.dtype.type is np.bool_:
            data["ul"] = np.array(ul_col, dtype=bool)
        elif ul_col.dtype.type is np.str_:
            strbool = True
            for ul in ul_col:
                if ul != "True" and ul != "False":
                    strbool = False
            if strbool:
                data["ul"] = np.array(
                    [ast.literal_eval(ul) for ul in ul_col], dtype=bool
                )
            else:
                raise TypeError("UL column is in wrong format")
        else:
            raise TypeError("UL column is in wrong format")
    else:
        data["ul"] = np.array([False] * len(data["energy"]))

    if "flux_ul" in data_table.keys():
        data["flux"][data["ul"]] = u.Quantity(data_table["flux_ul"])[
            data["ul"]
        ]

    HAS_CL = False
    if "keywords" in data_table.meta.keys():
        if "cl" in data_table.meta["keywords"].keys():
            HAS_CL = True

            CL = validate_scalar(