src/estimagic/parameters/check_constraints.py
def check_for_incompatible_overlaps(params, pc):
    """Check that there are no overlaps between constraints that transform parameters.

    Since the constraints are already consolidated such that only those that transform
    a parameter are left and all equality constraints are already plugged in, this
    boils down to checking that no parameter appears more than once.

    Args:
        params (pd.DataFrame): see :ref:`params`. Only used for error messages.
        pc (list): List with consolidated constraint dictionaries.

    """
    all_ilocs = []
    for constr in pc:
        all_ilocs += constr["index"]

    msg = (
        "Transforming constraints such as 'covariance', 'sdcorr', 'probability' "
        "and 'linear' cannot overlap. This includes overlaps induced by equality "
        "constraints. This was violated for the following parameters:\n{}"
    )

    if len(set(all_ilocs)) < len(all_ilocs):
        unique, counts = np.unique(all_ilocs, return_counts=True)
        invalid_indices = unique[counts >= 2]
        invalid_names = params.iloc[invalid_indices].index

        raise ValueError(msg.format(invalid_names))
Check that there are no overlaps between constraints that transform parameters.

    Since the constraints are already consolidated such that only those that transform
    a parameter are left and all equality constraints are already plugged in, this
    boils down to checking that no parameter appears more than once.

    Args:
        params (pd.DataFrame): see :ref:`params`. Only used for error messages.
        pc (list): List with consolidated constraint dictionaries.

    
Check that there are no overlaps between constraints that transform parameters.
Since the constraints are already consolidated such that only those that transform
a parameter are left and all equality constraints are already plugged in, this
boils down to checking that no parameter appears more than once.
Check that there are no overlaps between constraints that transform parameters . Since the constraints are already consolidated such that only those that transform a parameter are left and all equality constraints are already plugged in this boils down to checking that no parameter appears more than once .
def check_for_incompatible_overlaps(params, pc):
    all_ilocs = []
    for constr in pc:
        all_ilocs += constr["index"]
    msg = (
        "Transforming constraints such as 'covariance', 'sdcorr', 'probability' "
        "and 'linear' cannot overlap. This includes overlaps induced by equality "
        "constraints. This was violated for the following parameters:\n{}"
    )
    if len(set(all_ilocs)) < len(all_ilocs):
        unique, counts = np.unique(all_ilocs, return_counts=True)
        invalid_indices = unique[counts >= 2]
        invalid_names = params.iloc[invalid_indices].index
        raise ValueError(msg.format(invalid_names))
def check_for_incompatible_overlaps ( params , pc ) : all_ilocs = [ ] for constr in pc : all_ilocs += constr [ "index" ] msg = ( "Transforming constraints such as 'covariance', 'sdcorr', 'probability' " "and 'linear' cannot overlap. This includes overlaps induced by equality " "constraints. This was violated for the following parameters:\n{}" ) if len ( set ( all_ilocs ) ) < len ( all_ilocs ) : unique , counts = np . unique ( all_ilocs , return_counts = True ) invalid_indices = unique [ counts >= 2 ] invalid_names = params . iloc [ invalid_indices ] . index raise ValueError ( msg . format ( invalid_names ) )
Check that there are no overlaps between constraints that transform parameters.
Check that there are no overlaps between constraints that transform parameters .
"""Check that there are no overlaps between constraints that transform parameters.

    Since the constraints are already consolidated such that only those that transform
    a parameter are left and all equality constraints are already plugged in, this
    boils down to checking that no parameter appears more than once.

    Args:
        params (pd.DataFrame): see :ref:`params`. Only used for error messages.
        pc (list): List with consolidated constraint dictionaries.

    """
params
see :ref:`params`. Only used for error messages.
see : ref : ` params ` . Only used for error messages .
pc
List with consolidated constraint dictionaries.
List with consolidated constraint dictionaries .