Compatibility fixes for older version of python, numpy and scipy If you add content to this file, please give the version of the package at which the fix is no longer needed and adapted from sklearn.utils.fixes

watex.utils.thread.get_config()[source]#

Retrieve current values for configuration set by set_config(). :returns: config – Keys are parameter names that can be passed to set_config(). :rtype: dict

See also

config_context

Context manager for global scikit-learn configuration.

set_config

Set global scikit-learn configuration.

watex.utils.thread.threadpool_info()[source]#

Return the maximal number of threads for each detected library.

Return a list with all the supported libraries that have been found. Each library is represented by a dict with the following information:

  • “user_api” : user API. Possible values are [‘openmp’, ‘blas’].

  • “internal_api”: internal API. Possible values are [‘openmp’, ‘openblas’, ‘mkl’, ‘blis’].

  • “prefix” : filename prefix of the specific implementation.

  • “filepath”: path to the loaded library.

  • “version”: version of the library (if available).

  • “num_threads”: the current thread limit.

In addition, each library may contain internal_api specific entries.

watex.utils.thread.threadpool_limits(limits=None, user_api=None)[source]#

Change the maximal number of threads that can be used in thread pools.

This object can be used either as a callable (the construction of this object limits the number of threads), as a context manager in a with block to automatically restore the original state of the controlled libraries when exiting the block, or as a decorator through its wrap method.

Set the maximal number of threads that can be used in thread pools used in the supported libraries to limit. This function works for libraries that are already loaded in the interpreter and can be changed dynamically.

This effect is global and impacts the whole Python process. There is no thread level isolation as these libraries do not offer thread-local APIs to configure the number of threads to use in nested parallel calls.

Parameters:
  • limits (int, dict, 'sequential_blas_under_openmp' or None (default=None)) –

    The maximal number of threads that can be used in thread pools

    • If int, sets the maximum number of threads to limits for each library selected by user_api.

    • If it is a dictionary {key: max_threads}, this function sets a custom maximum number of threads for each key which can be either a user_api or a prefix for a specific library.

    • If ‘sequential_blas_under_openmp’, it will chose the appropriate limits and user_api parameters for the specific use case of sequential BLAS calls within an OpenMP parallel region. The user_api parameter is ignored.

    • If None, this function does not do anything.

  • user_api ("openmp", "blas" or None (default=None)) –

    APIs of libraries to limit. Used only if limits is an int.

    • If “blas”, it will only limit BLAS supported libraries (openblas, mkl, blis).

    • If “openmp”, it will only limit OpenMP supported libraries (libiomp, libgomp, libomp, vcomp). Note that it can affect the number of threads used by the BLAS libraries if they rely on OpenMP.

    • If None, this function will apply to all supported libraries.