internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: numpy/numpy

Issue:
Documentation fix for routines.fft (Trac #1531)
_Original ticket http://projects.scipy.org/numpy/ticket/1531 on 2010-06-30 by trac user valhallasw, assigned to unknown._

http://docs.scipy.org/doc/numpy/reference/routines.fft.html reads:

```
If A = fft(a, n), then A[0] contains the zero-frequency term (the mean of the signal), which is always purely real for real inputs.
```

This is, however, incorrect. A[0] contains the zero-frequency term _multiplied by the number of data points_.

The same error is in more docs, for example http://docs.scipy.org/doc/numpy/reference/generated/numpy.fft.rfft.html#numpy.fft.rfft.



Discussion:
_@rgommers wrote on 2010-07-26_

This is not actually incorrect, it is just not explained how normalization is done. That's explained in http://docs.scipy.org/doc/numpy/reference/routines.fft.html#module-numpy.fft to avoid duplicating the same explanation in each fft docstring. Note that it should soon be possible to specify the normalization with a keyword (not at all, /n in ifft, 1/sqrt(n) in both fft and ifft).

_trac user valhallasw wrote on 2010-07-26_

That makes sense. However, the text "(the mean of the signal)" should be removed then, as this is incorrect without the correct normalization.

_@rgommers wrote on 2010-07-26_

Has already been changed to "sum of the data" at http://docs.scipy.org/numpy/docs/numpy.fft/. Of course if the keyword is implement that whole phrase should be left out (commented there too).

If you find more minor doc issues like this, you can fix them in the doc wiki (http://docs.scipy.org/doc/) directly after signing up and asking for edit rights on the mailing lists. That's much more effective than filing a ticket. 

Thanks for reporting!

Milestone changed to `1.6.0` by @mwiebe on 2011-05-24


Resolving patch:
diff --git a/numpy/fft/info.py b/numpy/fft/info.py
--- a/numpy/fft/info.py
+++ b/numpy/fft/info.py
@@ -91,7 +91,7 @@
 is the sampling interval.
 
 The values in the result follow so-called "standard" order: If ``A =
-fft(a, n)``, then ``A[0]`` contains the zero-frequency term (the mean of
+fft(a, n)``, then ``A[0]`` contains the zero-frequency term (the sum of
 the signal), which is always purely real for real inputs. Then ``A[1:n/2]``
 contains the positive-frequency terms, and ``A[n/2+1:]`` contains the
 negative-frequency terms, in order of decreasingly negative frequency.


Test patch:
Repository: numpy/numpy

Issue:
ma.empty/zeros/ones do not accept shape keyword
Using 1.9.2, the following gives an unexpected error:

```
In [1]: ma.zeros(shape=(10,))
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-16-1a80688e7cb0> in <module>()
----> 1 ma.zeros(shape=(10,))

TypeError: __call__() takes at least 2 arguments (1 given)
```

Removing the `shape` keyword behaves as expected.  The non-ma versions of empty/zeros/ones do not show this behavior.



Discussion:

Resolving patch:
diff --git a/numpy/ma/core.py b/numpy/ma/core.py
--- a/numpy/ma/core.py
+++ b/numpy/ma/core.py
@@ -7536,7 +7536,7 @@ def getdoc(self):
             doc = sig + doc
         return doc
 
-    def __call__(self, a, *args, **params):
+    def __call__(self, *args, **params):
         # Find the common parameters to the call and the definition
         _extras = self._extras
         common_params = set(params).intersection(_extras)
@@ -7544,7 +7544,7 @@ def __call__(self, a, *args, **params):
         for p in common_params:
             _extras[p] = params.pop(p)
         # Get the result
-        result = self._func.__call__(a, *args, **params).view(MaskedArray)
+        result = self._func.__call__(*args, **params).view(MaskedArray)
         if "fill_value" in common_params:
             result.fill_value = _extras.get("fill_value", None)
         if "hardmask" in common_params:


Test patch:
diff --git a/numpy/ma/tests/test_core.py b/numpy/ma/tests/test_core.py
--- a/numpy/ma/tests/test_core.py
+++ b/numpy/ma/tests/test_core.py
@@ -1670,6 +1670,18 @@ def test_fillvalue_as_arguments(self):
         a = identity(3, fill_value=0., dtype=complex)
         assert_equal(a.fill_value, 0.)
 
+    def test_shape_argument(self):
+        # Test that shape can be provides as an argument
+        # GH issue 6106
+        a = empty(shape=(3, ))
+        assert_equal(a.shape, (3, ))
+
+        a = ones(shape=(3, ), dtype=float)
+        assert_equal(a.shape, (3, ))
+
+        a = zeros(shape=(3, ), dtype=complex)
+        assert_equal(a.shape, (3, ))
+
     def test_fillvalue_in_view(self):
         # Test the behavior of fill_value in view
Repository: numpy/numpy

Issue:
Is `np.empty(..., dtype=object)` guaranteed to fill the array with None?
Currently, `np.empty(..., dtype=object)` fills the array with `None`, which is certainly a very reasonable (though undocumented, afaict) behavior.  Is this guaranteed?  (Note that the other "more obvious" way of creating such an array, `np.fill(..., None)`, does not work, see #6366.)



Discussion:
I guess so? It has to be filled with something, and there's probably code
that depends on it being None, so I don't imagine we ever could or would
want to change it. Want to submit a patch documenting this in empty's
docstring, to nail it down?
On Sep 25, 2015 2:36 PM, "Antony Lee" notifications@github.com wrote:

> Currently, np.empty(..., dtype=object) fills the array with None, which
> is certainly a very reasonable (though undocumented, afaict) behavior. Is
> this guaranteed? (Note that the other "more obvious" way of creating such
> an array, np.fill(..., None), does not work, see #6366
> https://github.com/numpy/numpy/issues/6366.)
> 
> —
> Reply to this email directly or view it on GitHub
> https://github.com/numpy/numpy/issues/6367.


Resolving patch:
diff --git a/numpy/add_newdocs.py b/numpy/add_newdocs.py
--- a/numpy/add_newdocs.py
+++ b/numpy/add_newdocs.py
@@ -752,8 +752,8 @@ def luf(lamdaexpr, *args, **kwargs):
     Returns
     -------
     out : ndarray
-        Array of uninitialized (arbitrary) data with the given
-        shape, dtype, and order.
+        Array of uninitialized (arbitrary) data of the given shape, dtype, and
+        order.  Object arrays will be initialized to None.
 
     See Also
     --------


Test patch:
Repository: numpy/numpy

Issue:
Masked round() doesn't work on zero dimensional vectors (Trac #1648)
_Original ticket http://projects.scipy.org/numpy/ticket/1648 on 2010-10-25 by trac user andylei, assigned to unknown._

> > > import numpy as np
> > > x = np.ma.array(np.array(1.1))
> > > np.round(x)
> > > AttributeError
> > > 
> > > np.ma.round(x)
> > > AttributeError



Discussion:

Resolving patch:
diff --git a/numpy/ma/core.py b/numpy/ma/core.py
--- a/numpy/ma/core.py
+++ b/numpy/ma/core.py
@@ -5107,8 +5107,12 @@ def round(self, decimals=0, out=None):
 
         """
         result = self._data.round(decimals=decimals, out=out).view(type(self))
-        result._mask = self._mask
-        result._update_from(self)
+        if result.ndim > 0:
+            result._mask = self._mask
+            result._update_from(self)
+        elif self._mask:
+            # Return masked when the scalar is masked
+            result = masked
         # No explicit output: we're done
         if out is None:
             return result
@@ -6816,7 +6820,7 @@ def resize(x, new_shape):
     return result
 
 
-def rank(obj): 
+def rank(obj):
     """
     maskedarray version of the numpy function.
 
@@ -6833,7 +6837,7 @@ def rank(obj):
 rank.__doc__ = np.rank.__doc__
 
 
-def ndim(obj): 
+def ndim(obj):
     """
     maskedarray version of the numpy function.
 


Test patch:
diff --git a/numpy/ma/tests/test_core.py b/numpy/ma/tests/test_core.py
--- a/numpy/ma/tests/test_core.py
+++ b/numpy/ma/tests/test_core.py
@@ -3443,6 +3443,31 @@ def test_round_with_output(self):
         result = xm.round(decimals=2, out=output)
         self.assertTrue(result is output)
 
+    def test_round_with_scalar(self):
+        # Testing round with scalar/zero dimension input
+        # GH issue 2244
+        a = array(1.1, mask=[False])
+        assert_equal(a.round(), 1)
+
+        a = array(1.1, mask=[True])
+        assert_(a.round() is masked)
+
+        a = array(1.1, mask=[False])
+        output = np.empty(1, dtype=float)
+        output.fill(-9999)
+        a.round(out=output)
+        assert_equal(output, 1)
+
+        a = array(1.1, mask=[False])
+        output = array(-9999., mask=[True])
+        a.round(out=output)
+        assert_equal(output[()], 1)
+
+        a = array(1.1, mask=[True])
+        output = array(-9999., mask=[False])
+        a.round(out=output)
+        assert_(output[()] is masked)
+
     def test_identity(self):
         a = identity(5)
         self.assertTrue(isinstance(a, MaskedArray))
Repository: numpy/numpy

Issue:
Document numpy.genfromtxt with list of strings
As discovered [with this question/answer](http://stackoverflow.com/a/32217754/327026), `numpy.genfromtxt` can be used to read a list of strings. However, the first argument `fname` is [currently documented](http://docs.scipy.org/doc/numpy/reference/generated/numpy.genfromtxt.html) to take "file or str" types, and the documentation does not mention of this feature.



Discussion:

Resolving patch:
diff --git a/numpy/lib/npyio.py b/numpy/lib/npyio.py
--- a/numpy/lib/npyio.py
+++ b/numpy/lib/npyio.py
@@ -1271,10 +1271,11 @@ def genfromtxt(fname, dtype=float, comments='#', delimiter=None,
 
     Parameters
     ----------
-    fname : file or str
-        File, filename, or generator to read.  If the filename extension is
-        `.gz` or `.bz2`, the file is first decompressed. Note that
-        generators must return byte strings in Python 3k.
+    fname : file, str, list of str, generator
+        File, filename, list, or generator to read.  If the filename
+        extension is `.gz` or `.bz2`, the file is first decompressed. Mote
+        that generators must return byte strings in Python 3k.  The strings
+        in a list or produced by a generator are treated as lines.
     dtype : dtype, optional
         Data type of the resulting array.
         If None, the dtypes will be determined by the contents of each
@@ -1455,8 +1456,8 @@ def genfromtxt(fname, dtype=float, comments='#', delimiter=None,
             fhd = iter(fname)
     except TypeError:
         raise TypeError(
-            "fname must be a string, filehandle, or generator. "
-            "(got %s instead)" % type(fname))
+            "fname must be a string, filehandle, list of strings, "
+            "or generator. Got %s instead." % type(fname))
 
     split_line = LineSplitter(delimiter=delimiter, comments=comments,
                               autostrip=autostrip)._handyman


Test patch:
Repository: numpy/numpy

Issue:
ma.put issue
The following snippet does not behave as expected:

import numpy.ma as ma
z = ma.array([3.0, ma.masked])
data = ma.zeros(10)
ma.put(data, [1,2], z)

print data[3] # will throw an IndexError

If after initializing z, I do
z.mask = ma.getmaskarray(z)
then everything works fine.



Discussion:
For me the expected results are obtained when the the mask of data is expanded using `data.mask = ma.getmaskarray(z)`, indicating this is an issue with the "shrunk" mask of data.  

The issue is that the logic in [lines 4414-4415 of ma/core.py](https://github.com/numpy/numpy/blob/d573c634404da658653b35414053bc82f9a358d3/numpy/ma/core.py#L4414-L4415) assume that the mask of the values can be used to create the mask for the entire array, which is not true.  I believe in this case the mask should be expanded using getmaskarray and then the mask of the values put into this expanded mask.

I will submit a PR to address this bug later today.


Resolving patch:
diff --git a/numpy/ma/core.py b/numpy/ma/core.py
--- a/numpy/ma/core.py
+++ b/numpy/ma/core.py
@@ -4399,7 +4399,6 @@ def put(self, indices, values, mode='raise'):
          [7 -- 30]]
 
         """
-        m = self._mask
         # Hard mask: Get rid of the values/indices that fall on masked data
         if self._hardmask and self._mask is not nomask:
             mask = self._mask[indices]
@@ -4411,16 +4410,19 @@ def put(self, indices, values, mode='raise'):
 
         self._data.put(indices, values, mode=mode)
 
-        if m is nomask:
-            m = getmask(values)
+        # short circut if neither self nor values are masked
+        if self._mask is nomask and getmask(values) is nomask:
+            return
+
+        m = getmaskarray(self).copy()
+
+        if getmask(values) is nomask:
+            m.put(indices, False, mode=mode)
         else:
-            m = m.copy()
-            if getmask(values) is nomask:
-                m.put(indices, False, mode=mode)
-            else:
-                m.put(indices, values._mask, mode=mode)
-            m = make_mask(m, copy=False, shrink=True)
+            m.put(indices, values._mask, mode=mode)
+        m = make_mask(m, copy=False, shrink=True)
         self._mask = m
+        return
 
     def ids(self):
         """


Test patch:
diff --git a/numpy/ma/tests/test_core.py b/numpy/ma/tests/test_core.py
--- a/numpy/ma/tests/test_core.py
+++ b/numpy/ma/tests/test_core.py
@@ -2671,6 +2671,20 @@ def test_put(self):
         assert_array_equal(x, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ])
         assert_equal(x.mask, [1, 0, 0, 0, 1, 1, 0, 0, 0, 0])
 
+    def test_put_nomask(self):
+        # GitHub issue 6425
+        x = zeros(10)
+        z = array([3., -1.], mask=[False, True])
+
+        x.put([1, 2], z)
+        self.assertTrue(x[0] is not masked)
+        assert_equal(x[0], 0)
+        self.assertTrue(x[1] is not masked)
+        assert_equal(x[1], 3)
+        self.assertTrue(x[2] is masked)
+        self.assertTrue(x[3] is not masked)
+        assert_equal(x[3], 0)
+
     def test_put_hardmask(self):
         # Tests put on hardmask
         d = arange(5)
Repository: numpy/numpy

Issue:
f2py - fix - extended common block
I try to include a common f77 block from legacy code.  
There once can continue a common block with a new common statement with the same common block name.  In crackfortran.py there is statement that (wrongly) explicitly catches this case.  That should be removed/reverted.

Example
      common/namecom/ namezone(nzonei+nzonec+nzoneb), names(nsubz)
      common/namecom/ unitzone(nzonei+nzonec+nzoneb)
[...hundreds more such lines...]
doing this all with just line continuation is not an option, there is too many of them hence compilers have overflowed in the past (beyond some 20 lines).

The patch, based on numpy 1.9.2, is

```
~/Python/lib/python3.4/site-packages/numpy/f2py>diff crackfortran.py_old crackfortran.py
1163,1166c1163,1164
<             if c[0] in commonkey:
<                 outmess('analyzeline: previously defined common block encountered. Skipping.\n')
<                 continue
<             commonkey[c[0]]=[]

---
>             if c[0] not in commonkey:
>                 commonkey[c[0]]=[]
```

Can you please include this patch in future versions of f2py?



Discussion:
if you think this enhancement is reasonable (there was explicit code denying this compatibility and I do not know the background for it, but for my code it seemed to work and I did not see any reason why it logically should not work...) I am happy to try compiling a pull request for the fix.


Resolving patch:
diff --git a/numpy/f2py/crackfortran.py b/numpy/f2py/crackfortran.py
--- a/numpy/f2py/crackfortran.py
+++ b/numpy/f2py/crackfortran.py
@@ -1372,11 +1372,8 @@ def analyzeline(m, case, line):
         if 'common' in groupcache[groupcounter]:
             commonkey = groupcache[groupcounter]['common']
         for c in cl:
-            if c[0] in commonkey:
-                outmess(
-                    'analyzeline: previously defined common block encountered. Skipping.\n')
-                continue
-            commonkey[c[0]] = []
+            if c[0] not in commonkey:
+                commonkey[c[0]] = []
             for i in [x.strip() for x in markoutercomma(c[1]).split('@,@')]:
                 if i:
                     commonkey[c[0]].append(i)


Test patch:
Repository: numpy/numpy

Issue:
Updating the shrink keyword functionality in masked_values (Trac #2082)
_Original ticket http://projects.scipy.org/numpy/ticket/2082 on 2012-03-15 by trac user gsever, assigned to @pierregm._

Considering this simple case:

```
x = np.array([1, 1.1, 2, 1.1, 3])

ma.masked_values(x, 1.5)
masked_array(data = [ 1.   1.1  2.   1.1  3. ],
      mask = False,
      fill_value=1.5)

ma.masked_values(x, 1.5, shrink=False)
masked_array(data = [ 1.   1.1  2.   1.1  3. ],
      mask = False,
      fill_value=1.5)
```

Setting the 'shrink' keyword to False should create a mask with False filled array provided the condition is not met. The improved shrink keyword handling should yield the following masked array.

```
ma.masked_values(x, 1.5, shrink=False)
masked_array(data = [1.0 1.1 2.0 1.1 3.0],
             mask = [False False False False False],
       fill_value = 1.5)
```

The documentation about masked_values is at:
http://docs.scipy.org/doc/numpy/reference/generated/numpy.ma.masked_values.html



Discussion:

Resolving patch:
diff --git a/numpy/ma/core.py b/numpy/ma/core.py
--- a/numpy/ma/core.py
+++ b/numpy/ma/core.py
@@ -1544,7 +1544,7 @@ def make_mask(m, copy=False, shrink=True, dtype=MaskType):
           dtype=[('man', '|b1'), ('mouse', '|b1')])
 
     """
-    if m is nomask:
+    if m is nomask and shrink:
         return nomask
     elif isinstance(m, ndarray):
         # We won't return after this point to make sure we can shrink the mask
@@ -2247,7 +2247,7 @@ def masked_values(x, value, rtol=1e-5, atol=1e-8, copy=True, shrink=True):
     else:
         condition = umath.equal(xnew, value)
         mask = nomask
-    mask = mask_or(mask, make_mask(condition, shrink=shrink))
+    mask = mask_or(mask, make_mask(condition, shrink=shrink), shrink=shrink)
     return masked_array(xnew, mask=mask, copy=copy, fill_value=value)
 
 


Test patch:
diff --git a/numpy/ma/tests/test_core.py b/numpy/ma/tests/test_core.py
--- a/numpy/ma/tests/test_core.py
+++ b/numpy/ma/tests/test_core.py
@@ -1145,6 +1145,11 @@ def test_noshrinking(self):
         a /= 1.
         assert_equal(a.mask, [0, 0, 0])
 
+    def test_noshink_on_creation(self):
+        # Check that the mask is not shrunk on array creation when not wanted
+        a = np.ma.masked_values([1., 2.5, 3.1], 1.5, shrink=False)
+        assert_equal(a.mask, [0, 0, 0])
+
     def test_mod(self):
         # Tests mod
         (x, y, a10, m1, m2, xm, ym, z, zm, xf) = self.d
Repository: numpy/numpy

Issue:
Updating the shrink keyword functionality in masked_values (Trac #2082)
_Original ticket http://projects.scipy.org/numpy/ticket/2082 on 2012-03-15 by trac user gsever, assigned to @pierregm._

Considering this simple case:

```
x = np.array([1, 1.1, 2, 1.1, 3])

ma.masked_values(x, 1.5)
masked_array(data = [ 1.   1.1  2.   1.1  3. ],
      mask = False,
      fill_value=1.5)

ma.masked_values(x, 1.5, shrink=False)
masked_array(data = [ 1.   1.1  2.   1.1  3. ],
      mask = False,
      fill_value=1.5)
```

Setting the 'shrink' keyword to False should create a mask with False filled array provided the condition is not met. The improved shrink keyword handling should yield the following masked array.

```
ma.masked_values(x, 1.5, shrink=False)
masked_array(data = [1.0 1.1 2.0 1.1 3.0],
             mask = [False False False False False],
       fill_value = 1.5)
```

The documentation about masked_values is at:
http://docs.scipy.org/doc/numpy/reference/generated/numpy.ma.masked_values.html



Discussion:

Resolving patch:
diff --git a/numpy/ma/core.py b/numpy/ma/core.py
--- a/numpy/ma/core.py
+++ b/numpy/ma/core.py
@@ -1544,7 +1544,7 @@ def make_mask(m, copy=False, shrink=True, dtype=MaskType):
           dtype=[('man', '|b1'), ('mouse', '|b1')])
 
     """
-    if m is nomask:
+    if m is nomask and shrink:
         return nomask
     elif isinstance(m, ndarray):
         # We won't return after this point to make sure we can shrink the mask
@@ -2247,7 +2247,7 @@ def masked_values(x, value, rtol=1e-5, atol=1e-8, copy=True, shrink=True):
     else:
         condition = umath.equal(xnew, value)
         mask = nomask
-    mask = mask_or(mask, make_mask(condition, shrink=shrink))
+    mask = mask_or(mask, make_mask(condition, shrink=shrink), shrink=shrink)
     return masked_array(xnew, mask=mask, copy=copy, fill_value=value)
 
 


Test patch:
diff --git a/numpy/ma/tests/test_core.py b/numpy/ma/tests/test_core.py
--- a/numpy/ma/tests/test_core.py
+++ b/numpy/ma/tests/test_core.py
@@ -1109,6 +1109,11 @@ def test_noshrinking(self):
         a /= 1.
         assert_equal(a.mask, [0, 0, 0])
 
+    def test_noshink_on_creation(self):
+        # Check that the mask is not shrunk on array creation when not wanted
+        a = np.ma.masked_values([1., 2.5, 3.1], 1.5, shrink=False)
+        assert_equal(a.mask, [0, 0, 0])
+
     def test_mod(self):
         # Tests mod
         (x, y, a10, m1, m2, xm, ym, z, zm, xf) = self.d
Repository: numpy/numpy

Issue:
Error in broadcasting stride_tricks array
We hit a new test failure when testing against numpy 1.10.1 : https://github.com/nipy/nibabel/pull/358

The test failure boils down to this:

```
import numpy as np

shape = (2,)
strides = [0]
tricky_scalar = np.lib.stride_tricks.as_strided(np.array(0), shape, strides)
other = np.zeros((1,))
first, second = np.broadcast_arrays(tricky_scalar, other)
```

On Linux (not OSX) I get the following error, for numpy 1.10.1:

```
Traceback (most recent call last):
  File "broadcast_bug.py", line 7, in <module>
    first, second = np.broadcast_arrays(tricky_scalar, other)
  File "/home/mb312/.virtualenvs/test/local/lib/python2.7/site-packages/numpy/lib/stride_tricks.py", line 200, in broadcast_arrays
    for array in args]
  File "/home/mb312/.virtualenvs/test/local/lib/python2.7/site-packages/numpy/lib/stride_tricks.py", line 70, in _broadcast_to
    result.flags.writeable = True
ValueError: cannot set WRITEABLE flag to True of this array
```

There is no error for the same code on numpy 1.9.3.

I think this is the same issue, arising in scipy: https://github.com/scipy/scipy/pull/5374#issuecomment-148775998



Discussion:
Hmm. I wrote the offending line of code, so I can take a look at this. 

@shoyer Any progress?


Resolving patch:
diff --git a/numpy/lib/stride_tricks.py b/numpy/lib/stride_tricks.py
--- a/numpy/lib/stride_tricks.py
+++ b/numpy/lib/stride_tricks.py
@@ -62,11 +62,14 @@ def _broadcast_to(array, shape, subok, readonly):
     if any(size < 0 for size in shape):
         raise ValueError('all elements of broadcast shape must be non-'
                          'negative')
+    needs_writeable = not readonly and array.flags.writeable
+    extras = ['reduce_ok'] if needs_writeable else []
+    op_flag = 'readwrite' if needs_writeable else 'readonly'
     broadcast = np.nditer(
-        (array,), flags=['multi_index', 'refs_ok', 'zerosize_ok'],
-        op_flags=['readonly'], itershape=shape, order='C').itviews[0]
+        (array,), flags=['multi_index', 'refs_ok', 'zerosize_ok'] + extras,
+        op_flags=[op_flag], itershape=shape, order='C').itviews[0]
     result = _maybe_view_as_subclass(array, broadcast)
-    if not readonly and array.flags.writeable:
+    if needs_writeable and not result.flags.writeable:
         result.flags.writeable = True
     return result
 


Test patch:
diff --git a/numpy/lib/tests/test_stride_tricks.py b/numpy/lib/tests/test_stride_tricks.py
--- a/numpy/lib/tests/test_stride_tricks.py
+++ b/numpy/lib/tests/test_stride_tricks.py
@@ -390,6 +390,14 @@ def test_writeable():
     _, result = broadcast_arrays(0, original)
     assert_equal(result.flags.writeable, False)
 
+    # regresssion test for GH6491
+    shape = (2,)
+    strides = [0]
+    tricky_array = as_strided(np.array(0), shape, strides)
+    other = np.zeros((1,))
+    first, second = broadcast_arrays(tricky_array, other)
+    assert_(first.shape == second.shape)
+
 
 def test_reference_types():
     input_array = np.array('a', dtype=object)