# Path: calliope/preprocess/util.py
# def get_all_carriers(config, direction="both"):
# def flatten_list(unflattened_list):
# def split_loc_techs_transmission(transmission_string):
# def get_systemwide_constraints(tech_config):
# def vincenty(coord1, coord2):
#     U1 = np.arctan((1 - f) * np.tan(np.radians(coord1[0])))
#     U2 = np.arctan((1 - f) * np.tan(np.radians(coord2[0])))
#     L = np.radians(coord2[1] - coord1[1])
#         C = f / 16 * cosSqAlpha * (4 + f * (4 - 3 * cosSqAlpha))
#     A = 1 + uSq / 16384 * (4096 + uSq * (-768 + uSq * (320 - 175 * uSq)))
#     B = uSq / 1024 * (256 + uSq * (-128 + uSq * (74 - 47 * uSq)))
#     D = b * A * (sigma - deltaSigma)
# 
# Path: calliope/preprocess/checks.py
# DEFAULTS = AttrDict.from_yaml(
#     os.path.join(os.path.dirname(calliope.__file__), "config", "defaults.yaml")
# )
# POSSIBLE_COSTS = [i for i in DEFAULTS.techs.default_tech.costs.default_cost.keys()]
# def check_overrides(config_model, override):
# def check_initial(config_model):
# def _check_tech_final(
#     model_run, tech_id, tech_config, loc_id, model_warnings, errors, comments
# ):
# def check_final(model_run):
# def check_model_data(model_data):
# 
# Path: calliope/exceptions.py
# def _formatwarning(message, category, filename, lineno, line=None):
# def warn(message, _class=ModelWarning):
# def print_warnings_and_raise_errors(warnings=None, errors=None):
# class ModelError(Exception):
# class BackendError(Exception):
# class ModelWarning(Warning):
# class BackendWarning(Warning):


from itertools import product
from calliope.preprocess.util import constraint_exists, concat_iterable
from calliope.preprocess import checks
from calliope import exceptions
import numpy as np
        techs = [i for i in techs if ":" not in techs or i.split(":")[-1] in locs]

        trans_techs = set(techs).intersection(sets["techs_transmission_names"])
        for i in trans_techs:
            techs += [i + ":" + j for j in locs]
            techs.remove(i)

        # If the group constraint defines its own techs, remove those that are not allowed
        techs = list(set(techs).intersection(allowed_techs))

        # All possible loc_techs for this constraint
        loc_techs_all = list(
            set(concat_iterable([(l, t) for l, t in product(locs, techs)], ["::"]))
        )

        # Some loc_techs may not actually exist in the actual model,
        # so we must filter with actually exising loc_techs
        loc_techs = [i for i in loc_techs_all if i in sets.loc_techs]
        default_group_config = checks.DEFAULTS.group_constraints.default_group
        _constraints = {
            k: v
            for k, v in group_constraint.items()
            if k not in ["locs", "techs", "exists"]
        }
        if any(
            isinstance(default_group_config.get(_constraint, False), dict)
            and "default_carrier" in default_group_config[_constraint].keys()
            for _constraint in _constraints.keys()
        ):
            if len(_constraints) > 1:

# Path: calliope/preprocess/util.py
# def get_all_carriers(config, direction="both"):
# def flatten_list(unflattened_list):
# def split_loc_techs_transmission(transmission_string):
# def get_systemwide_constraints(tech_config):
# def vincenty(coord1, coord2):
#     U1 = np.arctan((1 - f) * np.tan(np.radians(coord1[0])))
#     U2 = np.arctan((1 - f) * np.tan(np.radians(coord2[0])))
#     L = np.radians(coord2[1] - coord1[1])
#         C = f / 16 * cosSqAlpha * (4 + f * (4 - 3 * cosSqAlpha))
#     A = 1 + uSq / 16384 * (4096 + uSq * (-768 + uSq * (320 - 175 * uSq)))
#     B = uSq / 1024 * (256 + uSq * (-128 + uSq * (74 - 47 * uSq)))
#     D = b * A * (sigma - deltaSigma)
# 
# Path: calliope/preprocess/checks.py
# DEFAULTS = AttrDict.from_yaml(
#     os.path.join(os.path.dirname(calliope.__file__), "config", "defaults.yaml")
# )
# POSSIBLE_COSTS = [i for i in DEFAULTS.techs.default_tech.costs.default_cost.keys()]
# def check_overrides(config_model, override):
# def check_initial(config_model):
# def _check_tech_final(
#     model_run, tech_id, tech_config, loc_id, model_warnings, errors, comments
# ):
# def check_final(model_run):
# def check_model_data(model_data):
# 
# Path: calliope/exceptions.py
# def _formatwarning(message, category, filename, lineno, line=None):
# def warn(message, _class=ModelWarning):
# def print_warnings_and_raise_errors(warnings=None, errors=None):
# class ModelError(Exception):
# class BackendError(Exception):
# class ModelWarning(Warning):
# class BackendWarning(Warning):


# Path: calliope/preprocess/constraint_sets.py
from itertools import product
from calliope.preprocess.util import constraint_exists, concat_iterable
from calliope.preprocess import checks
from calliope import exceptions
import numpy as np

        techs = [i for i in techs if ":" not in techs or i.split(":")[-1] in locs]

        trans_techs = set(techs).intersection(sets["techs_transmission_names"])
        for i in trans_techs:
            techs += [i + ":" + j for j in locs]
            techs.remove(i)

        # If the group constraint defines its own techs, remove those that are not allowed
        techs = list(set(techs).intersection(allowed_techs))

        # All possible loc_techs for this constraint
        loc_techs_all = list(
            set(concat_iterable([(l, t) for l, t in product(locs, techs)], ["::"]))
        )

        # Some loc_techs may not actually exist in the actual model,
        # so we must filter with actually exising loc_techs
        loc_techs = [i for i in loc_techs_all if i in sets.loc_techs]
        default_group_config = checks.DEFAULTS.group_constraints.default_group
        _constraints = {
            k: v
            for k, v in group_constraint.items()
            if k not in ["locs", "techs", "exists"]
        }
        if any(
            isinstance(default_group_config.get(_constraint, False), dict)
            and "default_carrier" in default_group_config[_constraint].keys()
            for _constraint in _constraints.keys()
        ):
            if len(_constraints) > 1:

                raise exceptions.ModelError(