Issue 1:
Building NumPy python wheel reports error in the end of process if CPU instruction set baseline flag is passed:

python3 setup.py build --cpu-baseline="avx" bdist_wheel

AttributeError: 'CCompilerOpt' object has no attribute '_requested_baseline'

Full error:

########### EXT COMPILER OPTIMIZATION ###########
Platform :
Architecture: x64
Compiler : gcc

CPU baseline :
Requested : 'avx'
Enabled : SSE SSE2 SSE3 SSSE3 SSE41 POPCNT SSE42 AVX
Flags : -msse -msse2 -msse3 -mssse3 -msse4.1 -mpopcnt -msse4.2 -mavx
Extra checks: none

CPU dispatch :
Requested : 'max -xop -fma4'
Enabled : F16C FMA3 AVX2 AVX512F AVX512CD AVX512_KNL AVX512_KNM AVX512_SKX AVX512_CLX AVX512_CNL AVX512_ICL
Generated :
:
AVX2 : SSE SSE2 SSE3 SSSE3 SSE41 POPCNT SSE42 AVX F16C
Flags : -msse -msse2 -msse3 -mssse3 -msse4.1 -mpopcnt -msse4.2 -mavx -mf16c -mavx2
Extra checks: none
Detect : AVX F16C AVX2
: numpy/core/src/umath/_umath_tests.dispatch.c
:
(FMA3 AVX2) : SSE SSE2 SSE3 SSSE3 SSE41 POPCNT SSE42 AVX F16C
Flags : -msse -msse2 -msse3 -mssse3 -msse4.1 -mpopcnt -msse4.2 -mavx -mf16c -mfma -mavx2
Extra checks: none
Detect : AVX F16C FMA3 AVX2
: build/src.linux-x86_64-3.8/numpy/core/src/_simd/_simd.dispatch.c
:
AVX512F : SSE SSE2 SSE3 SSSE3 SSE41 POPCNT SSE42 AVX F16C FMA3 AVX2
Flags : -msse -msse2 -msse3 -mssse3 -msse4.1 -mpopcnt -msse4.2 -mavx -mf16c -mfma -mavx2 -mavx512f
Extra checks: AVX512F_REDUCE
Detect : AVX512F
: build/src.linux-x86_64-3.8/numpy/core/src/_simd/_simd.dispatch.c
:
AVX512_SKX : SSE SSE2 SSE3 SSSE3 SSE41 POPCNT SSE42 AVX F16C FMA3 AVX2 AVX512F AVX512CD
Flags : -msse -msse2 -msse3 -mssse3 -msse4.1 -mpopcnt -msse4.2 -mavx -mf16c -mfma -mavx2 -mavx512f -mavx512cd -mavx512vl -mavx512bw -mavx512dq
Extra checks: AVX512BW_MASK AVX512DQ_MASK
Detect : AVX512_SKX
: build/src.linux-x86_64-3.8/numpy/core/src/_simd/_simd.dispatch.c
CCompilerOpt._cache_write[796] : write cache to path -> /home/user/Work/numpy-1.20.2/build/temp.linux-x86_64-3.8/ccompiler_opt_cache_ext.py

########### EXT COMPILER OPTIMIZATION ###########
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
File "/home/user/Work/numpy-1.20.2/numpy/distutils/command/build_ext.py", line 166, in report
log.info(self.compiler_opt.report(full=True))
File "/home/user/Work/numpy-1.20.2/numpy/distutils/ccompiler_opt.py", line 2331, in report
baseline_rows.append(("Requested", repr(self._requested_baseline)))
AttributeError: 'CCompilerOpt' object has no attribute '_requested_baseline'
CCompilerOpt._cache_write[796] : write cache to path -> /home/user/Work/numpy-1.20.2/build/temp.linux-x86_64-3.8/ccompiler_opt_cache_ext.py

########### CLIB COMPILER OPTIMIZATION ###########
Platform :
Architecture: x64
Compiler : gcc

CPU baseline :
Requested : 'avx'
Enabled : SSE SSE2 SSE3 SSSE3 SSE41 POPCNT SSE42 AVX
Flags : -msse -msse2 -msse3 -mssse3 -msse4.1 -mpopcnt -msse4.2 -mavx
Extra checks: none

CPU dispatch :
Requested : 'max -xop -fma4'
Enabled : F16C FMA3 AVX2 AVX512F AVX512CD AVX512_KNL AVX512_KNM AVX512_SKX AVX512_CLX AVX512_CNL AVX512_ICL
Generated : none
CCompilerOpt._cache_write[796] : write cache to path -> /home/user/Work/numpy-1.20.2/build/temp.linux-x86_64-3.8/ccompiler_opt_cache_clib.py

Although wheel file is successfully created and after installation it passes all standard tests.

Simply building NumPy without wheel goes without errors:

python3 setup.py build --cpu-baseline="avx"

########### EXT COMPILER OPTIMIZATION ###########
Platform :
Architecture: x64
Compiler : gcc

CPU baseline :
Requested : 'avx'
Enabled : SSE SSE2 SSE3 SSSE3 SSE41 POPCNT SSE42 AVX
Flags : -msse -msse2 -msse3 -mssse3 -msse4.1 -mpopcnt -msse4.2 -mavx
Extra checks: none

CPU dispatch :
Requested : 'max -xop -fma4'
Enabled : F16C FMA3 AVX2 AVX512F AVX512CD AVX512_KNL AVX512_KNM AVX512_SKX AVX512_CLX AVX512_CNL AVX512_ICL
Generated :
:
AVX2 : SSE SSE2 SSE3 SSSE3 SSE41 POPCNT SSE42 AVX F16C
Flags : -msse -msse2 -msse3 -mssse3 -msse4.1 -mpopcnt -msse4.2 -mavx -mf16c -mavx2
Extra checks: none
Detect : AVX F16C AVX2
: numpy/core/src/umath/_umath_tests.dispatch.c
:
(FMA3 AVX2) : SSE SSE2 SSE3 SSSE3 SSE41 POPCNT SSE42 AVX F16C
Flags : -msse -msse2 -msse3 -mssse3 -msse4.1 -mpopcnt -msse4.2 -mavx -mf16c -mfma -mavx2
Extra checks: none
Detect : AVX F16C FMA3 AVX2
: build/src.linux-x86_64-3.8/numpy/core/src/_simd/_simd.dispatch.c
:
AVX512F : SSE SSE2 SSE3 SSSE3 SSE41 POPCNT SSE42 AVX F16C FMA3 AVX2
Flags : -msse -msse2 -msse3 -mssse3 -msse4.1 -mpopcnt -msse4.2 -mavx -mf16c -mfma -mavx2 -mavx512f
Extra checks: AVX512F_REDUCE
Detect : AVX512F
: build/src.linux-x86_64-3.8/numpy/core/src/_simd/_simd.dispatch.c
:
AVX512_SKX : SSE SSE2 SSE3 SSSE3 SSE41 POPCNT SSE42 AVX F16C FMA3 AVX2 AVX512F AVX512CD
Flags : -msse -msse2 -msse3 -mssse3 -msse4.1 -mpopcnt -msse4.2 -mavx -mf16c -mfma -mavx2 -mavx512f -mavx512cd -mavx512vl -mavx512bw -mavx512dq
Extra checks: AVX512BW_MASK AVX512DQ_MASK
Detect : AVX512_SKX
: build/src.linux-x86_64-3.8/numpy/core/src/_simd/_simd.dispatch.c
CCompilerOpt._cache_write[796] : write cache to path -> /home/user/Work/numpy-1.20.2/build/temp.linux-x86_64-3.8/ccompiler_opt_cache_ext.py

########### CLIB COMPILER OPTIMIZATION ###########
Platform :
Architecture: x64
Compiler : gcc

CPU baseline :
Requested : 'avx'
Enabled : SSE SSE2 SSE3 SSSE3 SSE41 POPCNT SSE42 AVX
Flags : -msse -msse2 -msse3 -mssse3 -msse4.1 -mpopcnt -msse4.2 -mavx
Extra checks: none

CPU dispatch :
Requested : 'max -xop -fma4'
Enabled : F16C FMA3 AVX2 AVX512F AVX512CD AVX512_KNL AVX512_KNM AVX512_SKX AVX512_CLX AVX512_CNL AVX512_ICL
Generated : none
CCompilerOpt._cache_write[796] : write cache to path -> /home/user/Work/numpy-1.20.2/build/temp.linux-x86_64-3.8/ccompiler_opt_cache_clib.py

But if after building additionally request to create wheel distribution with the first command (python3 setup.py build --cpu-baseline="avx" bdist_wheel) it will end up with the same error.

Also, building wheel without specifying CPU instruction set has no errors:

python3 setup.py bdist_wheel

########### EXT COMPILER OPTIMIZATION ###########
Platform :
Architecture: x64
Compiler : gcc

CPU baseline :
Requested : 'min'
Enabled : SSE SSE2 SSE3
Flags : -msse -msse2 -msse3
Extra checks: none

CPU dispatch :
Requested : 'max -xop -fma4'
Enabled : SSSE3 SSE41 POPCNT SSE42 AVX F16C FMA3 AVX2 AVX512F AVX512CD AVX512_KNL AVX512_KNM AVX512_SKX AVX512_CLX AVX512_CNL AVX512_ICL
Generated :
:
SSE41 : SSE SSE2 SSE3 SSSE3
Flags : -msse -msse2 -msse3 -mssse3 -msse4.1
Extra checks: none
Detect : SSE SSE2 SSE3 SSSE3 SSE41
: numpy/core/src/umath/_umath_tests.dispatch.c
:
SSE42 : SSE SSE2 SSE3 SSSE3 SSE41 POPCNT
Flags : -msse -msse2 -msse3 -mssse3 -msse4.1 -mpopcnt -msse4.2
Extra checks: none
Detect : SSE SSE2 SSE3 SSSE3 SSE41 POPCNT SSE42
: build/src.linux-x86_64-3.8/numpy/core/src/_simd/_simd.dispatch.c
:
AVX2 : SSE SSE2 SSE3 SSSE3 SSE41 POPCNT SSE42 AVX F16C
Flags : -msse -msse2 -msse3 -mssse3 -msse4.1 -mpopcnt -msse4.2 -mavx -mf16c -mavx2
Extra checks: none
Detect : AVX F16C AVX2
: numpy/core/src/umath/_umath_tests.dispatch.c
:
(FMA3 AVX2) : SSE SSE2 SSE3 SSSE3 SSE41 POPCNT SSE42 AVX F16C
Flags : -msse -msse2 -msse3 -mssse3 -msse4.1 -mpopcnt -msse4.2 -mavx -mf16c -mfma -mavx2
Extra checks: none
Detect : AVX F16C FMA3 AVX2
: build/src.linux-x86_64-3.8/numpy/core/src/_simd/_simd.dispatch.c
:
AVX512F : SSE SSE2 SSE3 SSSE3 SSE41 POPCNT SSE42 AVX F16C FMA3 AVX2
Flags : -msse -msse2 -msse3 -mssse3 -msse4.1 -mpopcnt -msse4.2 -mavx -mf16c -mfma -mavx2 -mavx512f
Extra checks: AVX512F_REDUCE
Detect : AVX512F
: build/src.linux-x86_64-3.8/numpy/core/src/_simd/_simd.dispatch.c
:
AVX512_SKX : SSE SSE2 SSE3 SSSE3 SSE41 POPCNT SSE42 AVX F16C FMA3 AVX2 AVX512F AVX512CD
Flags : -msse -msse2 -msse3 -mssse3 -msse4.1 -mpopcnt -msse4.2 -mavx -mf16c -mfma -mavx2 -mavx512f -mavx512cd -mavx512vl -mavx512bw -mavx512dq
Extra checks: AVX512BW_MASK AVX512DQ_MASK
Detect : AVX512_SKX
: build/src.linux-x86_64-3.8/numpy/core/src/_simd/_simd.dispatch.c
CCompilerOpt._cache_write[796] : write cache to path -> /home/user/Work/numpy-1.20.2/build/temp.linux-x86_64-3.8/ccompiler_opt_cache_ext.py

########### CLIB COMPILER OPTIMIZATION ###########
Platform :
Architecture: x64
Compiler : gcc

CPU baseline :
Requested : 'min'
Enabled : SSE SSE2 SSE3
Flags : -msse -msse2 -msse3
Extra checks: none

CPU dispatch :
Requested : 'max -xop -fma4'
Enabled : SSSE3 SSE41 POPCNT SSE42 AVX F16C FMA3 AVX2 AVX512F AVX512CD AVX512_KNL AVX512_KNM AVX512_SKX AVX512_CLX AVX512_CNL AVX512_ICL
Generated : none
CCompilerOpt._cache_write[796] : write cache to path -> /home/user/Work/numpy-1.20.2/build/temp.linux-x86_64-3.8/ccompiler_opt_cache_clib.py

NumPy/Python version information:

1.20.2 3.8.5 (default, Jan 27 2021, 15:41:15)

[GCC 9.3.0]

Issue 2:
The np.clip function's documentation says:

Equivalent to but faster than ``np.maximum(a_min, np.minimum(a, a_max))``.
No check is performed to ensure ``a_min < a_max``.

This strict definition would imply that if a_min > a_max it will return a_min. However the experimental behavior is that a_max will be returned instead. This implies either the documentation should be changed to say np.minimum(a_max, np.maximum(a, a_min)) or the behavior should be changed to match the documentation, or at very least it should be made clear that this behavior is unspecified.

Note this may be a duplicate of #5142 but that seems to be outdated/not updated for 6 years, and this is specifically about the inconsistency with the documentation.

Reproducing code example:

>>> import numpy as np
>>> np.clip(0, 1, -1)
-1

Numpy/Python version information:

Numpy version: 1.17.4

Python version: 3.8.1 (tags/v3.8.1:1b293b6, Dec 18 2019, 23:11:46) [MSC v.1916 64 bit (AMD64)]