# Path: sedfitter/utils/integrate.py
# def integrate_subset(x, y, xmin, xmax):
#     """
#     Perform trapezium integration of a set of points (x,y) between bounds xmin
#     and xmax. The interpolation between the points is done in linear space, so
#     this is designed for functions that are piecewise linear in linear space.
#     """
# 
#     # Swap arrays if necessary
#     if x[-1] < x[0]:
#         x = x[::-1]
#         y = y[::-1]
# 
#     # Swap limits if necessary
#     if xmin > xmax:
#         xmin, xmax = xmax, xmin
#     elif xmin == xmax:
#         return 0.
# 
#     # Find the subset of points to use and the value of the function at the
#     # end-points of the integration
# 
#     if xmin == x[0]:
#         i1 = 1
#         ymin = y[0]
#     else:
#         i1 = np.searchsorted(x, xmin)
#         ymin = interp1d_fast(x[i1 - 1:i1 + 1], y[i1 - 1:i1 + 1], xmin)
# 
#     if xmax == x[-1]:
#         i2 = -2
#         ymax = y[-1]
#     else:
#         i2 = np.searchsorted(x, xmax)
#         ymax = interp1d_fast(x[i2 - 1:i2 + 1], y[i2 - 1:i2 + 1], xmax)
# 
#     # Construct sub-arrays of the relevant data
#     x = np.hstack([xmin, x[i1:i2], xmax])
#     y = np.hstack([ymin, y[i1:i2], ymax])
# 
#     # Call function to integrate the whole subset
#     return integrate(x, y)
# 
# def integrate(x, y):
#     """
#     Perform trapezium integration of a set of points (x,y). The interpolation
#     between the points is done in linear space, so this is designed for
#     functions that are piecewise linear in linear space.
#     """
# 
#     # Fix NaN values
#     y[np.isnan(y)] = 0.
# 
#     # Find the integral of all the chunks
#     integrals = 0.5 * (x[1:] - x[:-1]) * (y[1:] + y[:-1])
# 
#     # Sum them all up
#     integral = np.sum(integrals)
# 
#     # Check if the integral is NaN or infinity
#     if np.isnan(integral) or np.isinf(integral):
#         raise Exception("Integral is NaN or Inf")
# 
#     return integral
# 
# Path: sedfitter/utils/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:
#             # On Windows, shapes can contain long integers, so we fix this to
#             # have consistent error messages across platforms.
#             expected_shape = tuple(int(x) for x in shape)
#             actual_shape = tuple(int(x) for x in value.shape)
#             raise ValueError("{0} has incorrect shape (expected {1} but found {2})".format(name, expected_shape, actual_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 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.:
#             raise ValueError("{0} should be positive".format(name))
#     elif domain == 'strictly-positive':
#         if value <= 0.:
#             raise ValueError("{0} should be strictly positive".format(name))
#     elif domain == 'negative':
#         if value > 0.:
#             raise ValueError("{0} should be negative".format(name))
#     elif domain == 'strictly-negative':
#         if value >= 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 os
import numpy as np
from astropy import units as u
from ..utils.integrate import integrate_subset, integrate
from ..utils.validator import validate_array, validate_scalar
                                               domain='strictly-positive',
                                               physical_type='length')

    @property
    def nu(self):
        """
        The frequencies at which the filter is defined
        """
        return self._nu

    @nu.setter
    def nu(self, value):
        if value is None:
            self._nu = None
        else:
            self._nu = validate_array('nu', value, domain='strictly-positive', ndim=1,
                                      physical_type='frequency')

    @property
    def response(self):
        """
        The filter response
        """
        return self._r

    @response.setter
    def response(self, value):
        if value is None:
            self._r = None
        else:

# Path: sedfitter/utils/integrate.py
# def integrate_subset(x, y, xmin, xmax):
#     """
#     Perform trapezium integration of a set of points (x,y) between bounds xmin
#     and xmax. The interpolation between the points is done in linear space, so
#     this is designed for functions that are piecewise linear in linear space.
#     """
# 
#     # Swap arrays if necessary
#     if x[-1] < x[0]:
#         x = x[::-1]
#         y = y[::-1]
# 
#     # Swap limits if necessary
#     if xmin > xmax:
#         xmin, xmax = xmax, xmin
#     elif xmin == xmax:
#         return 0.
# 
#     # Find the subset of points to use and the value of the function at the
#     # end-points of the integration
# 
#     if xmin == x[0]:
#         i1 = 1
#         ymin = y[0]
#     else:
#         i1 = np.searchsorted(x, xmin)
#         ymin = interp1d_fast(x[i1 - 1:i1 + 1], y[i1 - 1:i1 + 1], xmin)
# 
#     if xmax == x[-1]:
#         i2 = -2
#         ymax = y[-1]
#     else:
#         i2 = np.searchsorted(x, xmax)
#         ymax = interp1d_fast(x[i2 - 1:i2 + 1], y[i2 - 1:i2 + 1], xmax)
# 
#     # Construct sub-arrays of the relevant data
#     x = np.hstack([xmin, x[i1:i2], xmax])
#     y = np.hstack([ymin, y[i1:i2], ymax])
# 
#     # Call function to integrate the whole subset
#     return integrate(x, y)
# 
# def integrate(x, y):
#     """
#     Perform trapezium integration of a set of points (x,y). The interpolation
#     between the points is done in linear space, so this is designed for
#     functions that are piecewise linear in linear space.
#     """
# 
#     # Fix NaN values
#     y[np.isnan(y)] = 0.
# 
#     # Find the integral of all the chunks
#     integrals = 0.5 * (x[1:] - x[:-1]) * (y[1:] + y[:-1])
# 
#     # Sum them all up
#     integral = np.sum(integrals)
# 
#     # Check if the integral is NaN or infinity
#     if np.isnan(integral) or np.isinf(integral):
#         raise Exception("Integral is NaN or Inf")
# 
#     return integral
# 
# Path: sedfitter/utils/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:
#             # On Windows, shapes can contain long integers, so we fix this to
#             # have consistent error messages across platforms.
#             expected_shape = tuple(int(x) for x in shape)
#             actual_shape = tuple(int(x) for x in value.shape)
#             raise ValueError("{0} has incorrect shape (expected {1} but found {2})".format(name, expected_shape, actual_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 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.:
#             raise ValueError("{0} should be positive".format(name))
#     elif domain == 'strictly-positive':
#         if value <= 0.:
#             raise ValueError("{0} should be strictly positive".format(name))
#     elif domain == 'negative':
#         if value > 0.:
#             raise ValueError("{0} should be negative".format(name))
#     elif domain == 'strictly-negative':
#         if value >= 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: sedfitter/filter/filter.py
import os
import numpy as np
from astropy import units as u
from ..utils.integrate import integrate_subset, integrate
from ..utils.validator import validate_array, validate_scalar

                                               domain='strictly-positive',
                                               physical_type='length')

    @property
    def nu(self):
        """
        The frequencies at which the filter is defined
        """
        return self._nu

    @nu.setter
    def nu(self, value):
        if value is None:
            self._nu = None
        else:
            self._nu = validate_array('nu', value, domain='strictly-positive', ndim=1,
                                      physical_type='frequency')

    @property
    def response(self):
        """
        The filter response
        """
        return self._r

    @response.setter
    def response(self, value):
        if value is None:
            self._r = None
        else:

            self._r = validate_array('r', value, domain='positive', ndim=1,