diff options
Diffstat (limited to 'numpy/lib/utils.py')
-rw-r--r-- | numpy/lib/utils.py | 44 |
1 files changed, 35 insertions, 9 deletions
diff --git a/numpy/lib/utils.py b/numpy/lib/utils.py index 91e7cb8a3..12a7cacdc 100644 --- a/numpy/lib/utils.py +++ b/numpy/lib/utils.py @@ -197,20 +197,20 @@ def deprecate(*args, **kwargs): def deprecate_with_doc(msg): """ Deprecates a function and includes the deprecation in its docstring. - - This function is used as a decorator. It returns an object that can be - used to issue a DeprecationWarning, by passing the to-be decorated - function as argument, this adds warning to the to-be decorated function's + + This function is used as a decorator. It returns an object that can be + used to issue a DeprecationWarning, by passing the to-be decorated + function as argument, this adds warning to the to-be decorated function's docstring and returns the new function object. - + See Also -------- - deprecate : Decorate a function such that it issues a `DeprecationWarning` - + deprecate : Decorate a function such that it issues a `DeprecationWarning` + Parameters ---------- msg : str - Additional explanation of the deprecation. Displayed in the + Additional explanation of the deprecation. Displayed in the docstring after the warning. Returns @@ -218,7 +218,7 @@ def deprecate_with_doc(msg): obj : object """ - return _Deprecate(message=msg) + return _Deprecate(message=msg) #-------------------------------------------- @@ -1042,4 +1042,30 @@ def _median_nancheck(data, result, axis, out): result[n] = np.nan return result +def _opt_info(): + """ + Returns a string contains the supported CPU features by the current build. + + The string format can be explained as follows: + - dispatched features that are supported by the running machine + end with `*`. + - dispatched features that are "not" supported by the running machine + end with `?`. + - remained features are representing the baseline. + """ + from numpy.core._multiarray_umath import ( + __cpu_features__, __cpu_baseline__, __cpu_dispatch__ + ) + + if len(__cpu_baseline__) == 0 and len(__cpu_dispatch__) == 0: + return '' + + enabled_features = ' '.join(__cpu_baseline__) + for feature in __cpu_dispatch__: + if __cpu_features__[feature]: + enabled_features += f" {feature}*" + else: + enabled_features += f" {feature}?" + + return enabled_features #----------------------------------------------------------------------------- |