<commit_before>"""

    Copyright (c) 2014, The University of Texas at Austin..
    All rights reserved.

    This file is part of BLASpy and is available under the 3-Clause
    BSD License, which can be found in the LICENSE file at the top-level
    directory or at http://opensource.org/licenses/BSD-3-Clause

"""

from .config import _libblas as lib
from .errors import (raise_invalid_dtypes, raise_not_vector, raise_not_2d_numpy, raise_not_square,
                     raise_size_mismatch, raise_strides_not_one, raise_invalid_parameter)
from ctypes import c_double, c_float
from numpy import asmatrix, zeros
from numpy import matrix as np_matrix

# CBLAS_ORDER
ROW_MAJOR = 101
COL_MAJOR = 102

# CBLAS_TRANSPOSE
NO_TRANS = 111
TRANS = 112
CONJ_TRANS = 113
CONJ_NO_TRANS = 114

# CBLAS_UPLO
UPPER = 121
LOWER = 122

# CBLAS_DIAG
NON_UNIT = 131
UNIT = 132

# CBLAS_SIDE
LEFT = 141
RIGHT = 142

# dictionary of BLASpy functions mapping to CBLAS subroutines
# - first entry in value pair is for double precision reals
# - second entry in value pair is for single precision reals
# - sdot is omitted as a special case
FUNC_DICT = {'amax':  (lib.cblas_idamax, lib.cblas_isamax),  # level 1
             'asum':  (lib.cblas_dasum,  lib.cblas_sasum),
             'axpy':  (lib.cblas_daxpy,  lib.cblas_saxpy),
             'copy':  (lib.cblas_dcopy,  lib.cblas_scopy),
             'dot':   (lib.cblas_ddot,   lib.cblas_sdot),
             'nrm2':  (lib.cblas_dnrm2,  lib.cblas_snrm2),
             'scal':  (lib.cblas_dscal,  lib.cblas_sscal),
             'swap':  (lib.cblas_dswap,  lib.cblas_sswap),
             'gemv':  (lib.cblas_dgemv,  lib.cblas_sgemv),   # level 2
             'ger':   (lib.cblas_dger,   lib.cblas_sger),
             'symv':  (lib.cblas_dsymv,  lib.cblas_ssymv),
             'syr':   (lib.cblas_dsyr,   lib.cblas_ssyr),
             'syr2':  (lib.cblas_dsyr2,  lib.cblas_ssyr2),
             'trmv':  (lib.cblas_dtrmv,  lib.cblas_strmv),
             'trsv':  (lib.cblas_dtrsv,  lib.cblas_strsv),
             'gemm':  (lib.cblas_dgemm,  lib.cblas_sgemm),   # level 3
             'symm':  (lib.cblas_dsymm,  lib.cblas_ssymm),
             'syrk':  (lib.cblas_dsyrk,  lib.cblas_ssyrk),
             'syr2k': (lib.cblas_dsyr2k, lib.cblas_ssyr2k),
             'trmm':  (lib.cblas_dtrmm,  lib.cblas_strmm)
            }


def get_cblas_info(calling_func, dtypes):
    """
    Return the appropriate CBLAS subroutine and ctype data type based on the calling function and
    dtypes of args.

    Args:
        calling_func:    a string representation of the calling function
        dtypes:          a tuple of the dtypes of all of the matrices or vectors passed into the
                         calling function

    Returns:
        A tuple of two elements where each element is described in order below:

        - appropriate CBLAS function
        - appropriate ctypes data type

    Raises:
        ValueError: if all matrices and/or vectors do not have the same dtype
    """

    if all(dtype == 'float64' for dtype in dtypes):
        return FUNC_DICT[calling_func][0], c_double

    elif all(dtype == 'float32' for dtype in dtypes):
        return FUNC_DICT[calling_func][1], c_float
<commit_msg>Update functions in helpers.py<commit_after>"""

    Copyright (c) 2014, The University of Texas at Austin..
    All rights reserved.

    This file is part of BLASpy and is available under the 3-Clause
    BSD License, which can be found in the LICENSE file at the top-level
    directory or at http://opensource.org/licenses/BSD-3-Clause

"""

from .config import _libblas as lib
from .errors import (raise_invalid_dtypes, raise_not_vector, raise_not_2d_numpy, raise_not_square,
                     raise_size_mismatch, raise_strides_not_one, raise_invalid_parameter)
from ctypes import c_double, c_float
from numpy import asmatrix, zeros
from numpy import matrix as np_matrix

# CBLAS_ORDER
ROW_MAJOR = 101
COL_MAJOR = 102

# CBLAS_TRANSPOSE
NO_TRANS = 111
TRANS = 112
CONJ_TRANS = 113
CONJ_NO_TRANS = 114

# CBLAS_UPLO
UPPER = 121
LOWER = 122

# CBLAS_DIAG
NON_UNIT = 131
UNIT = 132

# CBLAS_SIDE
LEFT = 141
RIGHT = 142

# dictionary of BLASpy functions mapping to CBLAS subroutines
# - first entry in value pair is for double precision reals
# - second entry in value pair is for single precision reals
# - sdot is omitted as a special case
FUNC_DICT = {'amax':  (lib.cblas_idamax, lib.cblas_isamax),  # level 1
             'asum':  (lib.cblas_dasum,  lib.cblas_sasum),
             'axpy':  (lib.cblas_daxpy,  lib.cblas_saxpy),
             'copy':  (lib.cblas_dcopy,  lib.cblas_scopy),
             'dot':   (lib.cblas_ddot,   lib.cblas_sdot),
             'nrm2':  (lib.cblas_dnrm2,  lib.cblas_snrm2),
             'scal':  (lib.cblas_dscal,  lib.cblas_sscal),
             'swap':  (lib.cblas_dswap,  lib.cblas_sswap),
             'gemv':  (lib.cblas_dgemv,  lib.cblas_sgemv),   # level 2
             'ger':   (lib.cblas_dger,   lib.cblas_sger),
             'symv':  (lib.cblas_dsymv,  lib.cblas_ssymv),
             'syr':   (lib.cblas_dsyr,   lib.cblas_ssyr),
             'syr2':  (lib.cblas_dsyr2,  lib.cblas_ssyr2),
             'trmv':  (lib.cblas_dtrmv,  lib.cblas_strmv),
             'trsv':  (lib.cblas_dtrsv,  lib.cblas_strsv),
             'gemm':  (lib.cblas_dgemm,  lib.cblas_sgemm),   # level 3
             'symm':  (lib.cblas_dsymm,  lib.cblas_ssymm),
             'syrk':  (lib.cblas_dsyrk,  lib.cblas_ssyrk),
             'syr2k': (lib.cblas_dsyr2k, lib.cblas_ssyr2k),
             'trmm':  (lib.cblas_dtrmm,  lib.cblas_strmm),
             'trsm':  (lib.cblas_dtrsm,  lib.cblas_strsm)
            }


def get_cblas_info(calling_func, dtypes):
    """
    Return the appropriate CBLAS subroutine and ctype data type based on the calling function and
    dtypes of args.

    Args:
        calling_func:    a string representation of the calling function
        dtypes:          a tuple of the dtypes of all of the matrices or vectors passed into the
                         calling function

    Returns:
        A tuple of two elements where each element is described in order below:

        - appropriate CBLAS function
        - appropriate ctypes data type

    Raises:
        ValueError: if all matrices and/or vectors do not have the same dtype
    """

    if all(dtype == 'float64' for dtype in dtypes):
        return FUNC_DICT[calling_func][0], c_double

    elif all(dtype == 'float32' for dtype in dtypes):
        return FUNC_DICT[calling_func][1], c_float

{'fraction_non_alphanumeric': 0.09085347200978892, 'fraction_numerical': 0.018660140715815236, 'mean_word_length': 2.55573681348559, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6840559', 'n_tokens_mistral': 2507, 'n_tokens_neox': 2400, 'n_words': 620}