 ValueError
* `#16709 <https://github.com/numpy/numpy/pull/16709>`__: DOC: Add dep directive to alen docstring.
* `#16710 <https://github.com/numpy/numpy/pull/16710>`__: ENH, BLD: Add RPATH support for AIX
* `#16718 <https://github.com/numpy/numpy/pull/16718>`__: DOC: fix typo
* `#16720 <https://github.com/numpy/numpy/pull/16720>`__: BUG: Fix PyArray_SearchSorted signature.
* `#16723 <https://github.com/numpy/numpy/pull/16723>`__: NEP: Initial draft for NEP 43 for extensible ufuncs
* `#16729 <https://github.com/numpy/numpy/pull/16729>`__: ENH: Add annotations to the last 8 functions in numpy.core.fromnumeric
* `#16730 <https://github.com/numpy/numpy/pull/16730>`__: ENH: Use f90 compiler specified in f2py command line args for...
* `#16731 <https://github.com/numpy/numpy/pull/16731>`__: DOC: reword random c-api introduction, cython is documented in...
* `#16735 <https://github.com/numpy/numpy/pull/16735>`__: DOC: Tweak a sentence about broadcasting.
* `#16736 <https://github.com/numpy/numpy/pull/16736>`__: DOC: Prepend ``ma.`` to references in ``numpy.ma``
* `#16738 <https://github.com/numpy/numpy/pull/16738>`__: DOC: Remove redundant word
* `#16742 <https://github.com/numpy/numpy/pull/16742>`__: DOC: add unique() to See Also of repeat()
* `#16743 <https://github.com/numpy/numpy/pull/16743>`__: DOC: add example to unique() and make connection to repeat()
* `#16747 <https://github.com/numpy/numpy/pull/16747>`__: MAINT: Chaining exceptions in numpy/core/_internal.py
* `#16752 <https://github.com/numpy/numpy/pull/16752>`__: BLD: add manylinux1 OpenBlAS 0.3.10 hashes and test for them
* `#16757 <https://github.com/numpy/numpy/pull/16757>`__: DOC: Add Matti Picus to steering council page
* `#16759 <https://github.com/numpy/numpy/pull/16759>`__: ENH: make dtype generic over scalar type
* `#16760 <https://github.com/numpy/numpy/pull/16760>`__: DOC: Added a section in the 'Iterating over arrays' doc page...
* `#16761 <https://github.com/numpy/numpy/pull/16761>`__: MAINT: Tidy exception chaining in _datasource.py
* `#16762 <https://github.com/numpy/numpy/pull/16762>`__: MAINT: Fixes for deprecated functions in scalartypes.c.src
* `#16764 <https://github.com/numpy/numpy/pull/16764>`__: MAINT: Bump mypy from 0.781 to 0.782
* `#16765 <https://github.com/numpy/numpy/pull/16765>`__: MAINT: Bump hypothesis from 5.16.3 to 5.19.0
* `#16767 <https://github.com/numpy/numpy/pull/16767>`__: ENH: Update NumPy logos
* `#16770 <https://github.com/numpy/numpy/pull/16770>`__: MAINT: Remove unneeded call to PyUnicode_READY
* `#16771 <https://github.com/numpy/numpy/pull/16771>`__: MAINT: Fix deprecated functions in scalarapi.c
* `#16775 <https://github.com/numpy/numpy/pull/16775>`__: DOC: switch to logo with text
* `#16777 <https://github.com/numpy/numpy/pull/16777>`__: BUG: Added missing return after raising error in methods.c
* `#16778 <https://github.com/numpy/numpy/pull/16778>`__: NEP: Update NEP 42 to note the issue of circular references
* `#16782 <https://github.com/numpy/numpy/pull/16782>`__: ENH, TST: Bring the NumPy C SIMD vectorization interface "NPYV"...
* `#16786 <https://github.com/numpy/numpy/pull/16786>`__: BENCH: Add basic benchmarks for scalar indexing and assignment
* `#16789 <https://github.com/numpy/numpy/pull/16789>`__: BUG: fix decode error when building and get rid of warn
* `#16792 <https://github.com/numpy/numpy/pull/16792>`__: DOC: Minor RST formatting.
* `#16793 <https://github.com/numpy/numpy/pull/16793>`__: BLD, MAINT: update cython to 0.29.21
* `#16794 <https://github.com/numpy/numpy/pull/16794>`__: TST: Upgrade to Python 3.8 for DEBUG testing.
* `#16798 <https://github.com/numpy/numpy/pull/16798>`__: DOC: Fix RST/numpydoc standard.
* `#16800 <https://github.com/numpy/numpy/pull/16800>`__: MAINT: Move typing tests
* `#16802 <https://github.com/numpy/numpy/pull/16802>`__: MAINT: Explicitly disallow object user dtypes
* `#16805 <https://github.com/numpy/numpy/pull/16805>`__: DOC: add example to corrcoef function
* `#16806 <https://github.com/numpy/numpy/pull/16806>`__: DOC: adding docs on passing dimensions as tuple to ndindex
* `#16807 <https://github.com/numpy/numpy/pull/16807>`__: BUG, MAINT: Remove overzealous automatic RST link
* `#16811 <https://github.com/numpy/numpy/pull/16811>`__: DOC: Add explanation of 'K' and 'A' layout options to 'asarray*'...
* `#16814 <https://github.com/numpy/numpy/pull/16814>`__: DOC: Add a reST label to /user/building.rst
* `#16815 <https://github.com/numpy/numpy/pull/16815>`__: BUG: fix mgrid output for lower precision float inputs
* `#16816 <https://github.com/numpy/numpy/pull/16816>`__: BLD: temporarily disable OpenBLAS hash checks
* `#16817 <https://github.com/numpy/numpy/pull/16817>`__: BUG: Do not inherit flags from the structured part of a union...
* `#16819 <https://github.com/numpy/numpy/pull/16819>`__: DOC: replace dec.slow with pytest.mark.slow
* `#16820 <https://github.com/numpy/numpy/pull/16820>`__: MAINT: Make void scalar to array creation copy when dtype is...
* `#16821 <https://github.com/numpy/numpy/pull/16821>`__: DOC: fix inconsistent parameter name in np.ndindex docstring
* `#16822 <https://github.com/numpy/numpy/pull/16822>`__: MAINT: setuptools 49.2.0 emits a warning, avoid it
* `#16824 <https://github.com/numpy/numpy/pull/16824>`__: DOC: add examples to random number generator pages
* `#16826 <https://github.com/numpy/numpy/pull/16826>`__: DOC: describe ufunc copy behavior when input and output overlap
* `#16827 <https://github.com/numpy/numpy/pull/16827>`__: MAINT: Fix ``runtest.py`` warning.
* `#16829 <https://github.com/numpy/numpy/pull/16829>`__: DOC,BLD: Add pandas to doc_requirements.txt
* `#16831 <https://github.com/numpy/numpy/pull/16831>`__: MAINT: fix sphinx deprecation
* `#16834 <https://github.com/numpy/numpy/pull/16834>`__: Avoid using uninitialized bytes in getlimits.py.
* `#16835 <https://github.com/numpy/numpy/pull/16835>`__: DOC: Explaining why datetime64 doesn't work for allclose + isclose
* `#16836 <https://github.com/numpy/numpy/pull/16836>`__: DOC: improve SIMD features tables
* `#16837 <https://github.com/numpy/numpy/pull/16837>`__: BLD: update openblas hashes, re-enable check
* `#16838 <https://github.com/numpy/numpy/pull/16838>`__: MAINT: Remove code that will never run
* `#16840 <https://github.com/numpy/numpy/pull/16840>`__: MAINT: Bump hypothesis from 5.19.0 to 5.19.1
* `#16841 <https://github.com/numpy/numpy/pull/16841>`__: BUG: linspace should round towards -infinity
* `#16845 <https://github.com/numpy/numpy/pull/16845>`__: TST: Disable shippable until we can fix it.
* `#16847 <https://github.com/numpy/numpy/pull/16847>`__: MAINT: Remove Duplicated Code (function extract rmap)
* `#16848 <https://github.com/numpy/numpy/pull/16848>`__: MAINT: Remove Duplicated Code
* `#16849 <https://github.com/numpy/numpy/pull/16849>`__: MAINT: Change for loop (range -> for each)
* `#16850 <https://github.com/numpy/numpy/pull/16850>`__: DEP: Deprecate NumPy object scalars
* `#16854 <https://github.com/numpy/numpy/pull/16854>`__: DOC: clarify whats required for new features see #13924
* `#16857 <https://github.com/numpy/numpy/pull/16857>`__: MAINT: fix new compiler warnings on clang
* `#16858 <https://github.com/numpy/numpy/pull/16858>`__: BUG: fix the search dir of dispatch-able sources
* `#16860 <https://github.com/numpy/numpy/pull/16860>`__: MAINT: Remove deprecated python function 'file()'
* `#16868 <https://github.com/numpy/numpy/pull/16868>`__: BUG: Validate output size in bin- and multinomial
* `#16870 <https://github.com/numpy/numpy/pull/16870>`__: BLD, MAINT: Pin setuptools
* `#16871 <https://github.com/numpy/numpy/pull/16871>`__: BUG: Update compiler check for AVX-512F
* `#16874 <https://github.com/numpy/numpy/pull/16874>`__: TST, MAINT: fix the test for ``np.ones``
* `#16878 <https://github.com/numpy/numpy/pull/16878>`__: DOC: edit to the documentation of lib/polynomial.py/polyfit
* `#16879 <https://github.com/numpy/numpy/pull/16879>`__: MAINT: Configure hypothesis in ``np.test()`` for determinism,...
* `#16882 <https://github.com/numpy/numpy/pull/16882>`__: BLD: Remove unused pip install
* `#16883 <https://github.com/numpy/numpy/pull/16883>`__: BUG,DOC: Fix bad MPL kwarg in docs
* `#16886 <https://github.com/numpy/numpy/pull/16886>`__: DOC: Fix types including curly braces
* `#16887 <https://github.com/numpy/numpy/pull/16887>`__: DOC: Remove the links for ``True`` and ``False``
* `#16888 <https://github.com/numpy/numpy/pull/16888>`__: ENH: Integrate the new CPU dispatcher with umath generator
* `#16890 <https://github.com/numpy/numpy/pull/16890>`__: TST, BUG: Re-raise MemoryError exception in test_large_zip's...
* `#16894 <https://github.com/numpy/numpy/pull/16894>`__: DOC: Fix wrong markups in ``arrays.dtypes``
* `#16896 <https://github.com/numpy/numpy/pull/16896>`__: DOC: Remove links for C codes
* `#16897 <https://github.com/numpy/numpy/pull/16897>`__: DOC: Fix the declarations of C fuctions
* `#16899 <https://github.com/numpy/numpy/pull/16899>`__: MNT: also use Py_SET_REFCNT instead of Py_REFCNT
* `#16900 <https://github.com/numpy/numpy/pull/16900>`__: MAINT: Chaining exceptions in numpy/__init__.py
* `#16907 <https://github.com/numpy/numpy/pull/16907>`__: DOC: update val to be scalar or array like optional closes #16901
* `#16910 <https://github.com/numpy/numpy/pull/16910>`__: MAINT: Bump hypothesis from 5.19.1 to 5.20.2
* `#16911 <https://github.com/numpy/numpy/pull/16911>`__: ENH: Speed up trim_zeros
* `#16914 <https://github.com/numpy/numpy/pull/16914>`__: BUG: Fix string/bytes to complex assignment
* `#16917 <https://github.com/numpy/numpy/pull/16917>`__: DOC: Add correctness vs strictness consideration for np.dtype
* `#16919 <https://github.com/numpy/numpy/pull/16919>`__: DOC: Add ufunc docstring to generated docs.
* `#16925 <https://github.com/numpy/numpy/pull/16925>`__: REL: Update master after 1.19.1 release.
* `#16931 <https://github.com/numpy/numpy/pull/16931>`__: Revert "Merge pull request #16248 from alexrockhill/edge"
* `#16935 <https://github.com/numpy/numpy/pull/16935>`__: ENH: implement NEP-35's ``like=`` argument
* `#16936 <https://github.com/numpy/numpy/pull/16936>`__: BUG: Fix memory leak of buffer-info cache due to relaxed strides
* `#16938 <https://github.com/numpy/numpy/pull/16938>`__: ENH,API: Store exported buffer info on the array
* `#16940 <https://github.com/numpy/numpy/pull/16940>`__: BLD: update OpenBLAS build
* `#16941 <https://github.com/numpy/numpy/pull/16941>`__: BUG: Allow array-like types to be coerced as object array elements
* `#16943 <https://github.com/numpy/numpy/pull/16943>`__: DEP: Deprecate size-one ragged array coercion
* `#16944 <https://github.com/numpy/numpy/pull/16944>`__: Change the name of the folder "icons" to "logo".
* `#16949 <https://github.com/numpy/numpy/pull/16949>`__: ENH: enable colors for ``runtests.py --ipython``
* `#16950 <https://github.com/numpy/numpy/pull/16950>`__: DOC: Clarify input to irfft/irfft2/irfftn
* `#16952 <https://github.com/numpy/numpy/pull/16952>`__: MAINT: Bump hypothesis from 5.20.2 to 5.23.2
* `#16953 <https://github.com/numpy/numpy/pull/16953>`__: update numpy/lib/arraypad.py with appropriate chain exception
* `#16957 <https://github.com/numpy/numpy/pull/16957>`__: MAINT: Use arm64 instead of aarch64 on travisCI.
* `#16962 <https://github.com/numpy/numpy/pull/16962>`__: MAINT: Chain exception in ``distutils/fcompiler/environment.py``.
* `#16966 <https://github.com/numpy/numpy/pull/16966>`__: MAINT: Added the ``order`` parameter to ``np.array()``
* `#16969 <https://github.com/numpy/numpy/pull/16969>`__: ENH: Add Neon SIMD implementations for add, sub, mul, and div
* `#16973 <https://github.com/numpy/numpy/pull/16973>`__: DOC: Fixed typo in lib/recfunctions.py
* `#16974 <https://github.com/numpy/numpy/pull/16974>`__: TST: Add pypy win32 CI testing.
* `#16982 <https://github.com/numpy/numpy/pull/16982>`__: ENH: Increase the use of ``Literal`` types
* `#16986 <https://github.com/numpy/numpy/pull/16986>`__: ENH: Add NumPy declarations to be used by Cython 3.0+
* `#16988 <https://github.com/numpy/numpy/pull/16988>`__: DOC: Add the new NumPy logo to Sphinx pages
* `#16991 <https://github.com/numpy/numpy/pull/16991>`__: MAINT: Bump hypothesis from 5.23.2 to 5.23.9
* `#16992 <https://github.com/numpy/numpy/pull/16992>`__: MAINT: Bump pytest from 5.4.3 to 6.0.1
* `#16993 <https://github.com/numpy/numpy/pull/16993>`__: BLD: pin setuptools < 49.2.0
* `#16996 <https://github.com/numpy/numpy/pull/16996>`__: DOC: Revise glossary page
* `#17002 <https://github.com/numpy/numpy/pull/17002>`__: DOC: clip() allows arguments.
* `#17009 <https://github.com/numpy/numpy/pull/17009>`__: NEP: Updated NEP-35 with keyword-only instruction
* `#17010 <https://github.com/numpy/numpy/pull/17010>`__: BUG: Raise correct errors in boolean indexing fast path
* `#17013 <https://github.com/numpy/numpy/pull/17013>`__: MAINT: Simplify scalar power
* `#17014 <https://github.com/numpy/numpy/pull/17014>`__: MAINT: Improve error handling in umathmodule setup
* `#17022 <https://github.com/numpy/numpy/pull/17022>`__: DOC: Fix non-matching pronoun.
* `#17028 <https://github.com/numpy/numpy/pull/17028>`__: DOC: Disclaimer for FFT library
* `#17029 <https://github.com/numpy/numpy/pull/17029>`__: MAINT: Add error return to all casting functionality and NpyIter
* `#17033 <https://github.com/numpy/numpy/pull/17033>`__: BUG: fix a compile and a test warning
* `#17036 <https://github.com/numpy/numpy/pull/17036>`__: DOC: Clarify that ``np.char`` comparison functions always return...
* `#17039 <https://github.com/numpy/numpy/pull/17039>`__: DOC: Use a less ambiguous example for array_split
* `#17041 <https://github.com/numpy/numpy/pull/17041>`__: MAINT: Bump hypothesis from 5.23.9 to 5.23.12
* `#17048 <https://github.com/numpy/numpy/pull/17048>`__: STY: core._internal style fixups
* `#17050 <https://github.com/numpy/numpy/pull/17050>`__: MAINT: Remove _EXTRAFLAGS variable
* `#17050 <https://github.com/numpy/numpy/pull/17051>`__: MAINT: change ``for line in open()`` to ``with open() as f``
* `#17052 <https://github.com/numpy/numpy/pull/17052>`__: MAINT: Delete obsolete conversion to list
* `#17053 <https://github.com/numpy/numpy/pull/17053>`__: BUG: fix typo in polydiv that prevented promotion to poly1d
* `#17055 <https://github.com/numpy/numpy/pull/17055>`__: MAINT: Replace lambda function by list comprehension
* `#17058 <https://github.com/numpy/numpy/pull/17058>`__: MAINT: Revert boolean casting back to elementwise comparisons...
* `#17059 <https://github.com/numpy/numpy/pull/17059>`__: BUG: fix pickling of arrays larger than 2GiB
* `#17062 <https://github.com/numpy/numpy/pull/17062>`__: API, BUG: Raise error on complex input to i0
* `#17063 <https://github.com/numpy/numpy/pull/17063>`__: MAINT: Remove obsolete conversion to set
* `#17067 <https://github.com/numpy/numpy/pull/17067>`__: DEP: lib: Remove the deprecated financial functions.
* `#17068 <https://github.com/numpy/numpy/pull/17068>`__: MAINT, BUG: Remove uses of PyString_FromString.
* `#17074 <https://github.com/numpy/numpy/pull/17074>`__: DOC: use the pydata_sphinx_theme
* `#17078 <https://github.com/numpy/numpy/pull/17078>`__: DOC: Fixes duplication of toctree content (Closes #17077)
* `#17091 <https://github.com/numpy/numpy/pull/17091>`__: MAINT: Bump pytest-cov from 2.10.0 to 2.10.1
* `#17092 <https://github.com/numpy/numpy/pull/17092>`__: MAINT: Bump hypothesis from 5.23.12 to 5.26.0
* `#17093 <https://github.com/numpy/numpy/pull/17093>`__: NEP: Adjust NEP-35 to make it more user-accessible
* `#17104 <https://github.com/numpy/numpy/pull/17104>`__: ENH: Add placeholder stubs for all sub-modules
* `#17109 <https://github.com/numpy/numpy/pull/17109>`__: MAINT: Split einsum into multiple files
* `#17112 <https://github.com/numpy/numpy/pull/17112>`__: BUG: Handle errors from the PyCapsule API
* `#17115 <https://github.com/numpy/numpy/pull/17115>`__: DOC: Fix spacing in vectorize doc
* `#17116 <https://github.com/numpy/numpy/pull/17116>`__: API: Remove ``np.ctypeslib.ctypes_load_library``
* `#17119 <https://github.com/numpy/numpy/pull/17119>`__: DOC: make spacing consistent in NEP 41 bullet points
* `#17121 <https://github.com/numpy/numpy/pull/17121>`__: BUG: core: fix ilp64 blas dot/vdot/... for strides > int32 max
* `#17123 <https://github.com/numpy/numpy/pull/17123>`__: ENH: allow running mypy through runtests.py
* `#17127 <https://github.com/numpy/numpy/pull/17127>`__: MAINT: Remove duplicated symbols from link step
* `#17129 <https://github.com/numpy/numpy/pull/17129>`__: BLD: Check for reduce intrinsics and AVX512BW mask operations
* `#17132 <https://github.com/numpy/numpy/pull/17132>`__: MAINT: Chain some exceptions in arraysetops.
* `#17133 <https://github.com/numpy/numpy/pull/17133>`__: MAINT: Chain ValueError in ma.timer_comparison
* `#17137 <https://github.com/numpy/numpy/pull/17137>`__: API,MAINT: Rewrite promotion using common DType and common instance
* `#17141 <https://github.com/numpy/numpy/pull/17141>`__: MAINT: Make arrayprint str and repr the ndarray defaults.
* `#17142 <https://github.com/numpy/numpy/pull/17142>`__: DOC: NEP-42: Fix a few typos.
* `#17143 <https://github.com/numpy/numpy/pull/17143>`__: MAINT: Change handling of the expired financial functions.
* `#17144 <https://github.com/numpy/numpy/pull/17144>`__: ENH: Add annotations to 3 functions in ``np.core.function_base``
* `#17145 <https://github.com/numpy/numpy/pull/17145>`__: MAINT, BUG: Replace uses of PyString_AsString.
* `#17146 <https://github.com/numpy/numpy/pull/17146>`__: MAINT: ``Replace PyUString_*`` by ``PyUnicode_*`` equivalents.
* `#17149 <https://github.com/numpy/numpy/pull/17149>`__: MAINT: Replace PyInt macros with their PyLong replacement
* `#17150 <https://github.com/numpy/numpy/pull/17150>`__: ENH: Add support for the abstract scalars to cython code
* `#17151 <https://github.com/numpy/numpy/pull/17151>`__: BUG: Fix incorrect cython definition of npy_cfloat
* `#17152 <https://github.com/numpy/numpy/pull/17152>`__: MAINT: Clean up some ``Npy_`` vs ``Py_`` macro usage
* `#17154 <https://github.com/numpy/numpy/pull/17154>`__: DOC: Remove references to PyCObject
* `#17159 <https://github.com/numpy/numpy/pull/17159>`__: DOC: Update numpy4matlab
* `#17160 <https://github.com/numpy/numpy/pull/17160>`__: Clean up some more bytes vs unicode handling
* `#17161 <https://github.com/numpy/numpy/pull/17161>`__: BUG: Remove Void special case for "safe casting"
* `#17163 <https://github.com/numpy/numpy/pull/17163>`__: MAINT: Remove redundant headers
* `#17164 <https://github.com/numpy/numpy/pull/17164>`__: MAINT: Remove NPY_COPY_PYOBJECT_PTR
* `#17167 <https://github.com/numpy/numpy/pull/17167>`__: BLD: Merge the npysort library into multiarray
* `#17168 <https://github.com/numpy/numpy/pull/17168>`__: TST: Add tests mapping out the rules for metadata in promotion
* `#17171 <https://github.com/numpy/numpy/pull/17171>`__: BUG: revert trim_zeros changes from gh-16911
* `#17172 <https://github.com/numpy/numpy/pull/17172>`__: ENH: Make ``np.complexfloating`` generic w.r.t. ``np.floating``
* `#17176 <https://github.com/numpy/numpy/pull/17176>`__: MAINT/ENH: datetime: remove calls to PyUnicode_AsASCIIString,...
* `#17180 <https://github.com/numpy/numpy/pull/17180>`__: ENH: Added missing methods to ``np.flatiter``
* `#17181 <https://github.com/numpy/numpy/pull/17181>`__: DOC: Correct error in description of ndarray.base
* `#17182 <https://github.com/numpy/numpy/pull/17182>`__: DOC: Document ``dtype.metadata``
* `#17186 <https://github.com/numpy/numpy/pull/17186>`__: MAINT: Use utf8 strings in more of datetime
* `#17188 <https://github.com/numpy/numpy/pull/17188>`__: MAINT: Add placeholder stubs for ``ndarray`` and ``generic``
* `#17191 <https://github.com/numpy/numpy/pull/17191>`__: MAINT: Bump hypothesis from 5.26.0 to 5.30.0
* `#17193 <https://github.com/numpy/numpy/pull/17193>`__: MAINT: Remove some callers of functions in numpy.compat
* `#17195 <https://github.com/numpy/numpy/pull/17195>`__: ENH: Make the window functions exactly symmetric
* `#17197 <https://github.com/numpy/numpy/pull/17197>`__: MAINT: Improve error handling in npy_cpu_init
* `#17199 <https://github.com/numpy/numpy/pull/17199>`__: DOC: Fix the documented signatures of four ``ufunc`` methods
* `#17201 <https://github.com/numpy/numpy/pull/17201>`__: MAINT: Make the ``NPY_CPU_DISPATCH_CALL`` macros expressions not...
* `#17204 <https://github.com/numpy/numpy/pull/17204>`__: DOC: Fixed headings for tutorials so they appear at new theme...
* `#17210 <https://github.com/numpy/numpy/pull/17210>`__: DOC: Canonical_urls
* `#17214 <https://github.com/numpy/numpy/pull/17214>`__: MAINT: Fix various issues with the ``np.generic`` annotations
* `#17215 <https://github.com/numpy/numpy/pull/17215>`__: DOC: Use official MATLAB spelling in numpy-for-matlab-users.rst
* `#17219 <https://github.com/numpy/numpy/pull/17219>`__: BLD: enabled negation of library choices in NPY_*_ORDER
* `#17220 <https://github.com/numpy/numpy/pull/17220>`__: BUG, DOC: comment out metadata added via javascript
* `#17222 <https://github.com/numpy/numpy/pull/17222>`__: MAINT, DOC: move informational files from numpy.doc.*.py to their...
* `#17223 <https://github.com/numpy/numpy/pull/17223>`__: MAINT: use sysconfig not distutils.sysconfig where possible
* `#17225 <https://github.com/numpy/numpy/pull/17225>`__: BUG: Fix dimension discovery of within array ragged cases
* `#17227 <https://github.com/numpy/numpy/pull/17227>`__: DOC: Added templates for different types of issues.
* `#17233 <https://github.com/numpy/numpy/pull/17233>`__: DEP: Deprecated ndindex.ndincr
* `#17235 <https://github.com/numpy/numpy/pull/17235>`__: MAINT: Remove old PY_VERSION_HEX and sys.version_info code
* `#17237 <https://github.com/numpy/numpy/pull/17237>`__: BUG: Avoid using ``np.random`` in typing tests.
* `#17238 <https://github.com/numpy/numpy/pull/17238>`__: DOC: Use SPDX license expressions with correct license
* `#17239 <https://github.com/numpy/numpy/pull/17239>`__: DOC: Fix link quick-start in old random API functions
* `#17240 <https://github.com/numpy/numpy/pull/17240>`__: MAINT: added exception chaining in shape_base.py
* `#17241 <https://github.com/numpy/numpy/pull/17241>`__: MAINT: ``__array_interface__`` data address cannot be bytes
* `#17242 <https://github.com/numpy/numpy/pull/17242>`__: MAINT: Run slow CI jobs earlier so builds finishes sooner
* `#17247 <https://github.com/numpy/numpy/pull/17247>`__: ENH: Add tool to help speed up Travis CI
* `#17250 <https://github.com/numpy/numpy/pull/17250>`__: DOC: Fix docstring cross-referencing
* `#17252 <https://github.com/numpy/numpy/pull/17252>`__: DOC: Added a PR "Reviewer guidelines" document.
* `#17257 <https://github.com/numpy/numpy/pull/17257>`__: DOC: work around a bug in the new theme
* `#17258 <https://github.com/numpy/numpy/pull/17258>`__: SIMD: add fused multiply subtract/add intrinics for all supported...
* `#17259 <https://github.com/numpy/numpy/pull/17259>`__: MAINT: Bump hypothesis from 5.30.0 to 5.33.0
* `#17260 <https://github.com/numpy/numpy/pull/17260>`__: MAINT: Bump pydata-sphinx-theme from 0.3.2 to 0.4.0
* `#17263 <https://github.com/numpy/numpy/pull/17263>`__: DOC: add new glossary terms
* `#17264 <https://github.com/numpy/numpy/pull/17264>`__: DOC: remove some glosssary terms
* `#17267 <https://github.com/numpy/numpy/pull/17267>`__: TST: Fix the path to ``mypy.ini`` in ``runtests.py``
* `#17268 <https://github.com/numpy/numpy/pull/17268>`__: BUG: sysconfig attributes/"""CSS selector structure items."""
import copyreg
from .pretty import pretty
from typing import Any, Type, Tuple, Union, Dict, Iterator, Hashable, Optional, Pattern, Iterable, Mapping

__all__ = (
    'Selector',
    'SelectorNull',
    'SelectorTag',
    'SelectorAttribute',
    'SelectorContains',
    'SelectorNth',
    'SelectorLang',
    'SelectorList',
    'Namespaces',
    'CustomSelectors'
)


SEL_EMPTY = 0x1
SEL_ROOT = 0x2
SEL_DEFAULT = 0x4
SEL_INDETERMINATE = 0x8
SEL_SCOPE = 0x10
SEL_DIR_LTR = 0x20
SEL_DIR_RTL = 0x40
SEL_IN_RANGE = 0x80
SEL_OUT_OF_RANGE = 0x100
SEL_DEFINED = 0x200
SEL_PLACEHOLDER_SHOWN = 0x400


class Immutable:
    """Immutable."""

    __slots__: Tuple[str, ...] = ('_hash',)

    _hash: int

    def __init__(self, **kwargs: Any) -> None:
        """Initialize."""

        temp = []
        for k, v in kwargs.items():
            temp.append(type(v))
            temp.append(v)
            super(Immutable, self).__setattr__(k, v)
        super(Immutable, self).__setattr__('_hash', hash(tuple(temp)))

    @classmethod
    def __base__(cls) -> "Type[Immutable]":
        """Get base class."""

        return cls

    def __eq__(self, other: Any) -> bool:
        """Equal."""

        return (
            isinstance(other, self.__base__()) and
            all([getattr(other, key) == getattr(self, key) for key in self.__slots__ if key != '_hash'])
        )

    def __ne__(self, other: Any) -> bool:
        """Equal."""

        return (
            not isinstance(other, self.__base__()) or
            any([getattr(other, key) != getattr(self, key) for key in self.__slots__ if key != '_hash'])
        )

    def __hash__(self) -> int:
        """Hash."""

        return self._hash

    def __setattr__(self, name: str, value: Any) -> None:
        """Prevent mutability."""

        raise AttributeError("'{}' is immutable".format(self.__class__.__name__))

    def __repr__(self) -> str:  # pragma: no cover
        """Representation."""

        return "{}({})".format(
            self.__class__.__name__, ', '.join(["{}={!r}".format(k, getattr(self, k)) for k in self.__slots__[:-1]])
        )

    __str__ = __repr__

    def pretty(self) -> None:  # pragma: no cover
        """Pretty print."""

        print(pretty(self))


class ImmutableDict(Mapping[Any, Any]):
    """Hashable, immutable dictionary."""

    def __init__(
        self,
        arg: Union[Dict[Any, Any], Iterable[Tuple[Any, Any]]]
    ) -> None:
        """Initialize."""

        self._validate(arg)
        self._d = dict(arg)
        self._hash = hash(tuple([(type(x), x, type(y), y) for x, y in sorted(self._d.items())]))

    def _validate(self, arg: Union[Dict[Any, Any], Iterable[Tuple[Any, Any]]]) -> None:
        """Validate arguments."""

        if isinstance(arg, dict):
            if not all([isinstance(v, Hashable) for v in arg.values()]):
                raise TypeError('{} values must be hashable'.format(self.__class__.__name__))
        elif not all([isinstance(k, Hashable) and isinstance(v, Hashable) for k, v in arg]):
            raise TypeError('{} values must be hashable'.format(self.__class__.__name__))

    def __iter__(self) -> Iterator[Any]:
        """Iterator."""

        return iter(self._d)

    def __len__(self) -> int:
        """Length."""

        return len(self._d)

    def __getitem__(self, key: Any) -> Any:
        """Get item: `namespace['key']`."""

        return self._d[key]

    def __hash__(self) -> int:
        """Hash."""

        return self._hash

    def __repr__(self) -> str:  # pragma: no cover
        """Representation."""

        return "{!r}".format(self._d)

    __str__ = __repr__


class Namespaces(ImmutableDict):
    """Namespaces."""

    def __init__(self, arg: Union[Dict[str, str], Iterable[Tuple[str, str]]]) -> None:
        """Initialize."""

        super().__init__(arg)

    def _validate(self, arg: Union[Dict[str, str], Iterable[Tuple[str, str]]]) -> None:
        """Validate arguments."""

        if isinstance(arg, dict):
            if not all([isinstance(v, str) for v in arg.values()]):
                raise TypeError('{} values must be hashable'.format(self.__class__.__name__))
        elif not all([isinstance(k, str) and isinstance(v, str) for k, v in arg]):
            raise TypeError('{} keys and values must be Unicode strings'.format(self.__class__.__name__))


class CustomSelectors(ImmutableDict):
    """Custom selectors."""

    def __init__(self, arg: Union[Dict[str, str], Iterable[Tuple[str, str]]]) -> None:
        """Initialize."""

        super().__init__(arg)

    def _validate(self, arg: Union[Dict[str, str], Iterable[Tuple[str, str]]]) -> None:
        """Validate arguments."""

        if isinstance(arg, dict):
            if not all([isinstance(v, str) for v in arg.values()]):
                raise TypeError('{} values must be hashable'.format(self.__class__.__name__))
        elif not all([isinstance(k, str) and isinstance(v, str) for k, v in arg]):
            raise TypeError('{} keys and values must be Unicode strings'.format(self.__class__.__name__))


class Selector(Immutable):
    """Selector."""

    __slots__ = (
        'tag', 'ids', 'classes', 'attributes', 'nth', 'selectors',
        'relation', 'rel_type', 'contains', 'lang', 'flags', '_hash'
    )

    tag: Optional['SelectorTag']
    ids: Tuple[str, ...]
    classes: Tuple[str, ...]
    attributes: Tuple['SelectorAttribute', ...]
    nth: Tuple['SelectorNth', ...]
    selectors: Tuple['SelectorList', ...]
    relation: 'SelectorList'
    rel_type: Optional[str]
    contains: Tuple['SelectorContains', ...]
    lang: Tuple['SelectorLang', ...]
    flags: int

    def __init__(
        self,
        tag: Optional['SelectorTag'],
        ids: Tuple[str, ...],
        classes: Tuple[str, ...],
        attributes: Tuple['SelectorAttribute', ...],
        nth: Tuple['SelectorNth', ...],
        selectors: Tuple['SelectorList', ...],
        relation: 'SelectorList',
        rel_type: Optional[str],
        contains: Tuple['SelectorContains', ...],
        lang: Tuple['SelectorLang', ...],
        flags: int
    ):
        """Initialize."""

        super().__init__(
            tag=tag,
            ids=ids,
            classes=classes,
            attributes=attributes,
            nth=nth,
            selectors=selectors,
            relation=relation,
            rel_type=rel_type,
            contains=contains,
            lang=lang,
            flags=flags
        )


class SelectorNull(Immutable):
    """Null Selector."""

    def __init__(self) -> None:
        """Initialize."""

        super().__init__()


class SelectorTag(Immutable):
    """Selector tag."""

    __slots__ = ("name", "prefix", "_hash")

    name: str
    prefix: Optional[str]

    def __init__(self, name: str, prefix: Optional[str]) -> None:
        """Initialize."""

        super().__init__(name=name, prefix=prefix)


class SelectorAttribute(Immutable):
    """Selector attribute rule."""

    __slots__ = ("attribute", "prefix", "pattern", "xml_type_pattern", "_hash")

    attribute: str
    prefix: str
    pattern: Optional[Pattern[str]]
    xml_type_pattern: Optional[Pattern[str]]

    def __init__(
        self,
        attribute: str,
        prefix: str,
        pattern: Optional[Pattern[str]],
        xml_type_pattern: Optional[Pattern[str]]
    ) -> None:
        """Initialize."""

        super().__init__(
            attribute=attribute,
            prefix=prefix,
            pattern=pattern,
            xml_type_pattern=xml_type_pattern
        )


class SelectorContains(Immutable):
    """Selector contains rule."""

    __slots__ = ("text", "own", "_hash")

    text: Tuple[str, ...]
    own: bool

    def __init__(self, text: Iterable[str], own: bool) -> None:
        """Initialize."""

        super().__init__(text=tuple(text), own=own)


class SelectorNth(Immutable):
    """Selector nth type."""

    __slots__ = ("a", "n", "b", "of_type", "last", "selectors", "_hash")

    a: int
    n: bool
    b: int
    of_type: bool
    last: bool
    selectors: 'SelectorList'

    def __init__(self, a: int, n: bool, b: int, of_type: bool, last: bool, selectors: 'SelectorList') -> None:
        """Initialize."""

        super().__init__(
            a=a,
            n=n,
            b=b,
            of_type=of_type,
            last=last,
            selectors=selectors
        )


class SelectorLang(Immutable):
    """Selector language rules."""

    __slots__ = ("languages", "_hash",)

    languages: Tuple[str, ...]

    def __init__(self, languages: Iterable[str]):
        """Initialize."""

        super().__init__(languages=tuple(languages))

    def __iter__(self) -> Iterator[str]:
        """Iterator."""

        return iter(self.languages)

    def __len__(self) -> int:  # pragma: no cover
        """Length."""

        return len(self.languages)

    def __getitem__(self, index: int) -> str:  # pragma: no cover
        """Get item."""

        return self.languages[index]


class SelectorList(Immutable):
    """Selector list."""

    __slots__ = ("selectors", "is_not", "is_html", "_hash")

    selectors: Tuple[Union['Selector', 'SelectorNull'], ...]
    is_not: bool
    is_html: bool

    def __init__(
        self,
        selectors: Optional[Iterable[Union['Selector', 'SelectorNull']]] = None,
        is_not: bool = False,
        is_html: bool = False
    ) -> None:
        """Initialize."""

        super().__init__(
            selectors=tuple(selectors) if selectors is not None else tuple(),
            is_not=is_not,
            is_html=is_html
        )

    def __iter__(self) -> Iterator[Union['Selector', 'SelectorNull']]:
        """Iterator."""

        return iter(self.selectors)

    def __len__(self) -> int:
        """Length."""

        return len(self.selectors)

    def __getitem__(self, index: int) -> Union['Selector', 'SelectorNull']:
        """Get item."""

        return self.selectors[index]


def _pickle(p: Any) -> Any:
    return p.__base__(), tuple([getattr(p, s) for s in p.__slots__[:-1]])


def pickle_register(obj: Any) -> None:
    """Allow object to be pickled."""

    copyreg.pickle(obj, _pickle)


pickle_register(Selector)
pickle_register(SelectorNull)
pickle_register(SelectorTag)
pickle_register(SelectorAttribute)
pickle_register(SelectorContains)
pickle_register(SelectorNth)
pickle_register(SelectorLang)
pickle_register(SelectorList)
