From c76e447acc5ba79809856c169de2e8684dd8e508 Mon Sep 17 00:00:00 2001 From: Eric Wieser Date: Thu, 8 Feb 2018 22:52:51 -0800 Subject: DOC: promote_types is _not_ associative by design, despite the fact it would be nice if it was Also give an example of the non-associative case. --- numpy/add_newdocs.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'numpy/add_newdocs.py') diff --git a/numpy/add_newdocs.py b/numpy/add_newdocs.py index 7dfecdb80..868f63632 100644 --- a/numpy/add_newdocs.py +++ b/numpy/add_newdocs.py @@ -1775,7 +1775,7 @@ add_newdoc('numpy.core.multiarray', 'promote_types', kind to which both ``type1`` and ``type2`` may be safely cast. The returned data type is always in native byte order. - This function is symmetric and associative. + This function is symmetric, and _usually_ associative. Parameters ---------- @@ -1817,6 +1817,14 @@ add_newdoc('numpy.core.multiarray', 'promote_types', >>> np.promote_types('i4', 'S8') dtype('S11') + An example of a non-associative case: + + >>> p = np.promote_types + >>> p('S', p('i1', 'u1')) + dtype('S6') + >>> p(p('S', 'i1'), 'u1') + dtype('S4') + """) add_newdoc('numpy.core.multiarray', 'min_scalar_type', -- cgit v1.2.1 From 348c47c20ab7f04f439a4a91f0652edfefffd576 Mon Sep 17 00:00:00 2001 From: Eric Wieser Date: Fri, 16 Feb 2018 15:34:03 -0800 Subject: Update add_newdocs.py --- numpy/add_newdocs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'numpy/add_newdocs.py') diff --git a/numpy/add_newdocs.py b/numpy/add_newdocs.py index 868f63632..9740292bb 100644 --- a/numpy/add_newdocs.py +++ b/numpy/add_newdocs.py @@ -1775,7 +1775,7 @@ add_newdoc('numpy.core.multiarray', 'promote_types', kind to which both ``type1`` and ``type2`` may be safely cast. The returned data type is always in native byte order. - This function is symmetric, and _usually_ associative. + This function is symmetric, but rarely associative. Parameters ---------- -- cgit v1.2.1