src/biotite/structure/charges.py
def _get_parameters(elements, amount_of_binding_partners):
    """
    Gather the parameters required for electronegativity computation of
    all atoms comprised in the input array `elements`.

    By doing so, the function accesses the nested dictionary
    ``EN_PARAMETERS``. The values originate from a publication of Johann
    Gasteiger and Mario Marsili. [1]_

    Parameters
    ----------
    elements: ndarray, dtype=str
        The array comprising the elememts which to retrieve the
        parameters for.
    amount_of_binding_partners: ndarray, dtype=int
        The array containing information about the amount of binding
        partners of the respective atom/element.
    
    Returns
    -------
    parameters: NumPy array, dtype=float, shape=(n,3)
        The array containing all three parameters required for the
        computation of the electronegativities of all atoms comprised
        in the `elements` array.
    
    References
    ----------
    .. [1] J Gasteiger and M Marsili,
       "Iterative partial equalization of orbital electronegativity - a
       rapid access to atomic charges"
       Tetrahedron, 36, 3219 - 3288 (1980).
    """
    parameters = np.zeros((elements.shape[0], 3))
    has_atom_key_error = False
    has_valence_key_error = False
    # Preparing warning in case of KeyError
    # It is differentiated between atoms that are not parametrized at
    # all and specific valence states that are parametrized
    list_of_unparametrized_elements = []
    unparametrized_valences = []
    unparam_valence_names = []
    for i, element in enumerate(elements):
        try:
            a, b, c = \
                EN_PARAMETERS[element][amount_of_binding_partners[i]]
            parameters[i, 0] = a
            parameters[i, 1] = b
            parameters[i, 2] = c
        except KeyError:
            # Considering the special case of ions
            if amount_of_binding_partners[i] == 0:
                parameters[i, :] = np.nan
                continue
            try:
                EN_PARAMETERS[element]
            except KeyError:
                list_of_unparametrized_elements.append(element)
                has_atom_key_error = True
            else:
                unparam_valence_names.append(element)
                unparametrized_valences.append(
                    amount_of_binding_partners[i]
                )
                has_valence_key_error = True
            parameters[i, :] = np.nan
    if has_valence_key_error:
        joined_list = []
        for i in range(len(unparam_valence_names)):
            joined_list.append(
                unparam_valence_names[i]
                +
                " " * (10 - len(unparam_valence_names[i]))
            )
            joined_list.append(str(unparametrized_valences[i]) + "\n")
            joined_array = np.reshape(
                joined_list,
                newshape=(int(len(joined_list) / 2), 2)
            )
            joined_array = np.unique(joined_array, axis=0)
            # Array must be flattened in order ro be able to apply the
            # 'join' method
            flattened_joined_array = np.reshape(
                joined_array, newshape=(2*joined_array.shape[0])
            )
        warnings.warn(
            f"Parameters for specific valence states of some atoms "
            f"are not available. These valence states are: \n"
            f"Atom:     Amount of binding partners:\n"
            f"{''.join(flattened_joined_array)}"
            f"Their electronegativity is given as NaN.",
            UserWarning
        )
    if has_atom_key_error:
        # Using NumPy's 'unique' function to ensure that each atom only
        # occurs once in the list
        unique_list = np.unique(list_of_unparametrized_elements)
        # Considering proper punctuation for the warning string
        warnings.warn(
            f"Parameters required for computation of "
            f"electronegativity aren't available for the following "
            f"atoms: {', '.join(unique_list)}. "
            f"Their electronegativity is given as NaN.", 
            UserWarning
        )
    return parameters

    Gather the parameters required for electronegativity computation of
    all atoms comprised in the input array `elements`.

    By doing so, the function accesses the nested dictionary
    ``EN_PARAMETERS``. The values originate from a publication of Johann
    Gasteiger and Mario Marsili. [1]_

    Parameters
    ----------
    elements: ndarray, dtype=str
        The array comprising the elememts which to retrieve the
        parameters for.
    amount_of_binding_partners: ndarray, dtype=int
        The array containing information about the amount of binding
        partners of the respective atom/element.
    
    Returns
    -------
    parameters: NumPy array, dtype=float, shape=(n,3)
        The array containing all three parameters required for the
        computation of the electronegativities of all atoms comprised
        in the `elements` array.
    
    References
    ----------
    .. [1] J Gasteiger and M Marsili,
       "Iterative partial equalization of orbital electronegativity - a
       rapid access to atomic charges"
       Tetrahedron, 36, 3219 - 3288 (1980).
    
Gather the parameters required for electronegativity computation of
all atoms comprised in the input array `elements`.

By doing so, the function accesses the nested dictionary
``EN_PARAMETERS``. The values originate from a publication of Johann
Gasteiger and Mario Marsili. [1]_

Parameters

ndarray, dtype=str
The array comprising the elememts which to retrieve the
parameters for.
amount_of_binding_partners: ndarray, dtype=int
The array containing information about the amount of binding
partners of the respective atom/element.

Returns

NumPy array, dtype=float, shape=(n,3)
The array containing all three parameters required for the
computation of the electronegativities of all atoms comprised
in the `elements` array.

References

[1] J Gasteiger and M Marsili,
"Iterative partial equalization of orbital electronegativity - a
rapid access to atomic charges"
Tetrahedron, 36, 3219 - 3288 (1980).
Gather the parameters required for electronegativity computation of all atoms comprised in the input array ` elements ` . By doing so the function accesses the nested dictionary ` ` EN_PARAMETERS ` ` . The values originate from a publication of Johann Gasteiger and Mario Marsili . [ 1 ] _ Parameters ndarray dtype = str The array comprising the elememts which to retrieve the parameters for . amount_of_binding_partners : ndarray dtype = int The array containing information about the amount of binding partners of the respective atom / element . Returns NumPy array dtype = float shape = ( n 3 ) The array containing all three parameters required for the computation of the electronegativities of all atoms comprised in the ` elements ` array . References [ 1 ] J Gasteiger and M Marsili " Iterative partial equalization of orbital electronegativity - a rapid access to atomic charges " Tetrahedron 36 3219 - 3288 ( 1980 ) .
def _get_parameters(elements, amount_of_binding_partners):
    parameters = np.zeros((elements.shape[0], 3))
    has_atom_key_error = False
    has_valence_key_error = False
    list_of_unparametrized_elements = []
    unparametrized_valences = []
    unparam_valence_names = []
    for i, element in enumerate(elements):
        try:
            a, b, c = \
                EN_PARAMETERS[element][amount_of_binding_partners[i]]
            parameters[i, 0] = a
            parameters[i, 1] = b
            parameters[i, 2] = c
        except KeyError:
            if amount_of_binding_partners[i] == 0:
                parameters[i, :] = np.nan
                continue
            try:
                EN_PARAMETERS[element]
            except KeyError:
                list_of_unparametrized_elements.append(element)
                has_atom_key_error = True
            else:
                unparam_valence_names.append(element)
                unparametrized_valences.append(
                    amount_of_binding_partners[i]
                )
                has_valence_key_error = True
            parameters[i, :] = np.nan
    if has_valence_key_error:
        joined_list = []
        for i in range(len(unparam_valence_names)):
            joined_list.append(
                unparam_valence_names[i]
                +
                " " * (10 - len(unparam_valence_names[i]))
            )
            joined_list.append(str(unparametrized_valences[i]) + "\n")
            joined_array = np.reshape(
                joined_list,
                newshape=(int(len(joined_list) / 2), 2)
            )
            joined_array = np.unique(joined_array, axis=0)
            flattened_joined_array = np.reshape(
                joined_array, newshape=(2*joined_array.shape[0])
            )
        warnings.warn(
            f"Parameters for specific valence states of some atoms "
            f"are not available. These valence states are: \n"
            f"Atom:     Amount of binding partners:\n"
            f"{''.join(flattened_joined_array)}"
            f"Their electronegativity is given as NaN.",
            UserWarning
        )
    if has_atom_key_error:
        unique_list = np.unique(list_of_unparametrized_elements)
        warnings.warn(
            f"Parameters required for computation of "
            f"electronegativity aren't available for the following "
            f"atoms: {', '.join(unique_list)}. "
            f"Their electronegativity is given as NaN.", 
            UserWarning
        )
    return parameters
def _get_parameters ( elements , amount_of_binding_partners ) : parameters = np . zeros ( ( elements . shape [ 0 ] , 3 ) ) has_atom_key_error = False has_valence_key_error = False list_of_unparametrized_elements = [ ] unparametrized_valences = [ ] unparam_valence_names = [ ] for i , element in enumerate ( elements ) : try : a , b , c = EN_PARAMETERS [ element ] [ amount_of_binding_partners [ i ] ] parameters [ i , 0 ] = a parameters [ i , 1 ] = b parameters [ i , 2 ] = c except KeyError : if amount_of_binding_partners [ i ] == 0 : parameters [ i , : ] = np . nan continue try : EN_PARAMETERS [ element ] except KeyError : list_of_unparametrized_elements . append ( element ) has_atom_key_error = True else : unparam_valence_names . append ( element ) unparametrized_valences . append ( amount_of_binding_partners [ i ] ) has_valence_key_error = True parameters [ i , : ] = np . nan if has_valence_key_error : joined_list = [ ] for i in range ( len ( unparam_valence_names ) ) : joined_list . append ( unparam_valence_names [ i ] + " " * ( 10 - len ( unparam_valence_names [ i ] ) ) ) joined_list . append ( str ( unparametrized_valences [ i ] ) + "\n" ) joined_array = np . reshape ( joined_list , newshape = ( int ( len ( joined_list ) / 2 ) , 2 ) ) joined_array = np . unique ( joined_array , axis = 0 ) flattened_joined_array = np . reshape ( joined_array , newshape = ( 2 * joined_array . shape [ 0 ] ) ) warnings . warn ( f"Parameters for specific valence states of some atoms " f"are not available. These valence states are: \n" f"Atom:     Amount of binding partners:\n" f"{''.join(flattened_joined_array)}" f"Their electronegativity is given as NaN." , UserWarning ) if has_atom_key_error : unique_list = np . unique ( list_of_unparametrized_elements ) warnings . warn ( f"Parameters required for computation of " f"electronegativity aren't available for the following " f"atoms: {', '.join(unique_list)}. " f"Their electronegativity is given as NaN." , UserWarning ) return parameters
Gather the parameters required for electronegativity computation of
all atoms comprised in the input array `elements`.
Gather the parameters required for electronegativity computation of all atoms comprised in the input array ` elements ` .
"""
    Gather the parameters required for electronegativity computation of
    all atoms comprised in the input array `elements`.

    By doing so, the function accesses the nested dictionary
    ``EN_PARAMETERS``. The values originate from a publication of Johann
    Gasteiger and Mario Marsili. [1]_

    Parameters
    ----------
    elements: ndarray, dtype=str
        The array comprising the elememts which to retrieve the
        parameters for.
    amount_of_binding_partners: ndarray, dtype=int
        The array containing information about the amount of binding
        partners of the respective atom/element.
    
    Returns
    -------
    parameters: NumPy array, dtype=float, shape=(n,3)
        The array containing all three parameters required for the
        computation of the electronegativities of all atoms comprised
        in the `elements` array.
    
    References
    ----------
    .. [1] J Gasteiger and M Marsili,
       "Iterative partial equalization of orbital electronegativity - a
       rapid access to atomic charges"
       Tetrahedron, 36, 3219 - 3288 (1980).
    """ # Preparing warning in case of KeyError # It is differentiated between atoms that are not parametrized at # all and specific valence states that are parametrized # Considering the special case of ions # Array must be flattened in order ro be able to apply the # 'join' method # Using NumPy's 'unique' function to ensure that each atom only # occurs once in the list # Considering proper punctuation for the warning string
elements
amount_of_binding_partners