<p dir="auto"><code class="notranslate">broadcast_arrays</code> does not indicate the unbroadcastable shapes on failure, unlike implicit broadcasting and broadcast_to.  It would be nice if it did.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="In [1]: np.arange(2) + np.arange(3)
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
&lt;ipython-input-1-6b2dd1b1eacd&gt; in &lt;module&gt;()
----&gt; 1 np.arange(2) + np.arange(3)

ValueError: operands could not be broadcast together with shapes (2,) (3,) 

In [3]: np.broadcast_to(range(2), 3)
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
&lt;ipython-input-3-6521087bac95&gt; in &lt;module&gt;()
----&gt; 1 np.broadcast_to(range(2), 3)

/usr/lib/python3.6/site-packages/numpy/lib/stride_tricks.py in broadcast_to(array, shape, subok)
    113            [1, 2, 3]])
    114     &quot;&quot;&quot;
--&gt; 115     return _broadcast_to(array, shape, subok=subok, readonly=True)
    116 
    117 

/usr/lib/python3.6/site-packages/numpy/lib/stride_tricks.py in _broadcast_to(array, shape, subok, readonly)
     68     broadcast = np.nditer(
     69         (array,), flags=['multi_index', 'refs_ok', 'zerosize_ok'] + extras,
---&gt; 70         op_flags=[op_flag], itershape=shape, order='C').itviews[0]
     71     result = _maybe_view_as_subclass(array, broadcast)
     72     if needs_writeable and not result.flags.writeable:

ValueError: operands could not be broadcast together with remapped shapes [original-&gt;remapped]: (2,) and requested shape (3,)

In [4]: np.broadcast_arrays(range(2), range(3))
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
&lt;ipython-input-4-267514b78435&gt; in &lt;module&gt;()
----&gt; 1 np.broadcast_arrays(range(2), range(3))

/usr/lib/python3.6/site-packages/numpy/lib/stride_tricks.py in broadcast_arrays(*args, **kwargs)
    189     args = [np.array(_m, copy=False, subok=subok) for _m in args]
    190 
--&gt; 191     shape = _broadcast_shape(*args)
    192 
    193     if all(array.shape == shape for array in args):

/usr/lib/python3.6/site-packages/numpy/lib/stride_tricks.py in _broadcast_shape(*args)
    124     # use the old-iterator because np.nditer does not handle size 0 arrays
    125     # consistently
--&gt; 126     b = np.broadcast(*args[:32])
    127     # unfortunately, it cannot handle 32 or more arguments directly
    128     for pos in range(32, len(args), 31):

ValueError: shape mismatch: objects cannot be broadcast to a single shape"><pre class="notranslate"><code class="notranslate">In [1]: np.arange(2) + np.arange(3)
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
&lt;ipython-input-1-6b2dd1b1eacd&gt; in &lt;module&gt;()
----&gt; 1 np.arange(2) + np.arange(3)

ValueError: operands could not be broadcast together with shapes (2,) (3,) 

In [3]: np.broadcast_to(range(2), 3)
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
&lt;ipython-input-3-6521087bac95&gt; in &lt;module&gt;()
----&gt; 1 np.broadcast_to(range(2), 3)

/usr/lib/python3.6/site-packages/numpy/lib/stride_tricks.py in broadcast_to(array, shape, subok)
    113            [1, 2, 3]])
    114     """
--&gt; 115     return _broadcast_to(array, shape, subok=subok, readonly=True)
    116 
    117 

/usr/lib/python3.6/site-packages/numpy/lib/stride_tricks.py in _broadcast_to(array, shape, subok, readonly)
     68     broadcast = np.nditer(
     69         (array,), flags=['multi_index', 'refs_ok', 'zerosize_ok'] + extras,
---&gt; 70         op_flags=[op_flag], itershape=shape, order='C').itviews[0]
     71     result = _maybe_view_as_subclass(array, broadcast)
     72     if needs_writeable and not result.flags.writeable:

ValueError: operands could not be broadcast together with remapped shapes [original-&gt;remapped]: (2,) and requested shape (3,)

In [4]: np.broadcast_arrays(range(2), range(3))
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
&lt;ipython-input-4-267514b78435&gt; in &lt;module&gt;()
----&gt; 1 np.broadcast_arrays(range(2), range(3))

/usr/lib/python3.6/site-packages/numpy/lib/stride_tricks.py in broadcast_arrays(*args, **kwargs)
    189     args = [np.array(_m, copy=False, subok=subok) for _m in args]
    190 
--&gt; 191     shape = _broadcast_shape(*args)
    192 
    193     if all(array.shape == shape for array in args):

/usr/lib/python3.6/site-packages/numpy/lib/stride_tricks.py in _broadcast_shape(*args)
    124     # use the old-iterator because np.nditer does not handle size 0 arrays
    125     # consistently
--&gt; 126     b = np.broadcast(*args[:32])
    127     # unfortunately, it cannot handle 32 or more arguments directly
    128     for pos in range(32, len(args), 31):

ValueError: shape mismatch: objects cannot be broadcast to a single shape
</code></pre></div>
<p dir="auto">Currently, <code class="notranslate">np.broadcast_to</code> prints the nonbroadcastable shapes in its error message, but not <code class="notranslate">np.broadcast_arrays</code>:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="In [1]: np.broadcast_to([1, 2], 3)
&lt;elided&gt;
ValueError: operands could not be broadcast together with remapped shapes [original-&gt;remapped]: (2,) and requested shape (3,)

In [2]: np.broadcast_arrays([1, 2], [3, 4, 5])
&lt;elided&gt;
ValueError: shape mismatch: objects cannot be broadcast to a single shape"><pre class="notranslate"><code class="notranslate">In [1]: np.broadcast_to([1, 2], 3)
&lt;elided&gt;
ValueError: operands could not be broadcast together with remapped shapes [original-&gt;remapped]: (2,) and requested shape (3,)

In [2]: np.broadcast_arrays([1, 2], [3, 4, 5])
&lt;elided&gt;
ValueError: shape mismatch: objects cannot be broadcast to a single shape
</code></pre></div>
<p dir="auto">It would be mildly helpful if the second error message also reported the incorrect shapes.</p>