diff options
author | Sebastian Berg <sebastianb@nvidia.com> | 2022-12-02 11:52:40 +0100 |
---|---|---|
committer | Sebastian Berg <sebastianb@nvidia.com> | 2022-12-02 11:59:17 +0100 |
commit | fd30908f5c82447c96190ef74443ebda34fd52db (patch) | |
tree | a2b945ef6d331a7fe3c1be322c259efd409d969c /numpy/exceptions.py | |
parent | ba9136f601ef3ede98bde4651e9d3ab7e742c3fb (diff) | |
download | numpy-fd30908f5c82447c96190ef74443ebda34fd52db.tar.gz |
DOC,TST: address review comments and improve test coverage
Co-authored-by: Marten van Kerkwijk <mhvk@astro.utoronto.ca>
Diffstat (limited to 'numpy/exceptions.py')
-rw-r--r-- | numpy/exceptions.py | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/numpy/exceptions.py b/numpy/exceptions.py index 7363febf1..f0a78d9ac 100644 --- a/numpy/exceptions.py +++ b/numpy/exceptions.py @@ -208,11 +208,10 @@ class InvalidPromotion(TypeError): Notes ----- - ``InvalidPromotion`` derives from ``TypeError`` and if it occurs within - many functions (e.g. math functions will try to promote if they do not - find an implementation), it is chained with a more specific error. - In this case, it means that the function cannot be implemented or has no - implementation for the given dtype combination. + ``InvalidPromotion`` derives from ``TypeError``. Many functions will + use promotion to find the correct result and implementation. + For these functions the error will be chained with a more specific error + indicating that no implementation was found for the input dtypes. Typically promotion should be considered "invalid" between the dtypes of two arrays when `arr1 == arr2` can safely return all ``False`` because the @@ -223,7 +222,7 @@ class InvalidPromotion(TypeError): Datetimes and complex numbers are incompatible classes and cannot be promoted: - >>> np.result_type(np.dtype("M8", "D") + >>> np.result_type(np.dtype("M8[s]"), np.complex128) InvalidPromotion: The DType <class 'numpy.dtype[datetime64]'> could not be promoted by <class 'numpy.dtype[complex128]'>. This means that no common DType exists for the given inputs. For example they cannot be stored in a |