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

Issue:
Misleading error for duplicate key in argsort(order=...)
```python
>>> arr = np.empty(10, [('a', int), ('b', int)])
>>> arr.argsort(order=('a', 'a'))
ValueError: unknown field name: a
```


Discussion:

Resolving patch:
diff --git a/numpy/core/_internal.py b/numpy/core/_internal.py
--- a/numpy/core/_internal.py
+++ b/numpy/core/_internal.py
@@ -281,20 +281,26 @@ def get_as_parameter(self):
     _as_parameter_ = property(get_as_parameter, None, doc="_as parameter_")
 
 
-# Given a datatype and an order object
-#  return a new names tuple
-#  with the order indicated
 def _newnames(datatype, order):
+    """
+    Given a datatype and an order object, return a new names tuple, with the
+    order indicated
+    """
     oldnames = datatype.names
     nameslist = list(oldnames)
     if isinstance(order, str):
         order = [order]
+    seen = set()
     if isinstance(order, (list, tuple)):
         for name in order:
             try:
                 nameslist.remove(name)
             except ValueError:
-                raise ValueError("unknown field name: %s" % (name,))
+                if name in seen:
+                    raise ValueError("duplicate field name: %s" % (name,))
+                else:
+                    raise ValueError("unknown field name: %s" % (name,))
+            seen.add(name)
         return tuple(list(order) + nameslist)
     raise ValueError("unsupported order value: %s" % (order,))
 


Test patch:
diff --git a/numpy/core/tests/test_multiarray.py b/numpy/core/tests/test_multiarray.py
--- a/numpy/core/tests/test_multiarray.py
+++ b/numpy/core/tests/test_multiarray.py
@@ -30,7 +30,7 @@
     )
 from numpy.testing import (
     TestCase, run_module_suite, assert_, assert_raises, assert_warns,
-    assert_equal, assert_almost_equal, assert_array_equal,
+    assert_equal, assert_almost_equal, assert_array_equal, assert_raises_regex,
     assert_array_almost_equal, assert_allclose, IS_PYPY, HAS_REFCOUNT,
     assert_array_less, runstring, dec, SkipTest, temppath, suppress_warnings
     )
@@ -1538,6 +1538,9 @@ def test_sort_order(self):
         assert_equal(r.word, np.array(['my', 'first', 'name']))
         assert_equal(r.number, np.array([3.1, 4.5, 6.2]))
 
+        assert_raises_regex(ValueError, 'duplicate',
+            lambda: r.sort(order=['id', 'id']))
+
         if sys.byteorder == 'little':
             strtype = '>i2'
         else:
Repository: numpy/numpy

Issue:
byteswap does not accept keyword arguments
The `np.ndarray.byteswap` function only accepts positional arguments. Would it make sense to accept the `inplace` parameter as keyword argument as well?


Discussion:
Sounds sensible to me - want to put together a PR?

Resolving patch:
diff --git a/numpy/add_newdocs.py b/numpy/add_newdocs.py
--- a/numpy/add_newdocs.py
+++ b/numpy/add_newdocs.py
@@ -3292,7 +3292,7 @@ def luf(lamdaexpr, *args, **kwargs):
 
 add_newdoc('numpy.core.multiarray', 'ndarray', ('byteswap',
     """
-    a.byteswap(inplace)
+    a.byteswap(inplace=False)
 
     Swap the bytes of the array elements
 
@@ -3315,7 +3315,7 @@ def luf(lamdaexpr, *args, **kwargs):
     >>> A = np.array([1, 256, 8755], dtype=np.int16)
     >>> map(hex, A)
     ['0x1', '0x100', '0x2233']
-    >>> A.byteswap(True)
+    >>> A.byteswap(inplace=True)
     array([  256,     1, 13090], dtype=int16)
     >>> map(hex, A)
     ['0x100', '0x1', '0x3322']


Test patch:
Repository: numpy/numpy

Issue:
test_warning_calls "invalid escape sequence \s" on Python 3.6 daily wheel builds.
New errors today (13 August), for Linux and OSX:

```
======================================================================
ERROR: numpy.tests.test_warnings.test_warning_calls
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/venv/lib/python3.6/site-packages/nose/case.py", line 198, in runTest
    self.test(*self.arg)
  File "/venv/lib/python3.6/site-packages/numpy/tests/test_warnings.py", line 79, in test_warning_calls
    tree = ast.parse(file.read())
  File "/usr/lib/python3.6/ast.py", line 35, in parse
    return compile(source, filename, mode, PyCF_ONLY_AST)
  File "<unknown>", line 184
SyntaxError: invalid escape sequence \s
```

https://travis-ci.org/MacPython/numpy-wheels/jobs/264023630
https://travis-ci.org/MacPython/numpy-wheels/jobs/264023631
https://travis-ci.org/MacPython/numpy-wheels/jobs/264023635


Discussion:
Was worried about that, the problem is
```
file:  numpy/doc/basics.py
line:  184 :  invalid escape sequence \s
```
Came from documentation fixes. Probably need a raw string, although I would prefer making the files genuine rst.
I should add that check to the tests...

Resolving patch:
diff --git a/numpy/doc/basics.py b/numpy/doc/basics.py
--- a/numpy/doc/basics.py
+++ b/numpy/doc/basics.py
@@ -158,8 +158,8 @@
 numpy provides with ``np.finfo(np.longdouble)``.
 
 NumPy does not provide a dtype with more precision than C
-``long double``\s; in particular, the 128-bit IEEE quad precision
-data type (FORTRAN's ``REAL*16``\) is not available.
+``long double``\\s; in particular, the 128-bit IEEE quad precision
+data type (FORTRAN's ``REAL*16``\\) is not available.
 
 For efficient memory alignment, ``np.longdouble`` is usually stored
 padded with zero bits, either to 96 or 128 bits. Which is more efficient


Test patch:
Repository: numpy/numpy

Issue:
typo in nonzero docstring
Not to forget, there is a typo in `np.nonzero` [docstring](https://github.com/numpy/numpy/blob/663094532de48e131793faaa0ba06eb7c051ab47/numpy/core/fromnumeric.py#L1534):

```
    >>> x = np.array([[1,0,0], [0,2,0], [1,1,0]])
    ...
    ...
    >>> x[np.nonzero(x)]
    array([ 1.,  1.,  1.])
```
numpy (1.13.1)


Discussion:

Resolving patch:
diff --git a/numpy/core/fromnumeric.py b/numpy/core/fromnumeric.py
--- a/numpy/core/fromnumeric.py
+++ b/numpy/core/fromnumeric.py
@@ -1529,14 +1529,15 @@ def nonzero(a):
            [0, 2, 0],
            [1, 1, 0]])
     >>> np.nonzero(x)
-    (array([0, 1, 2, 2], dtype=int64), array([0, 1, 0, 1], dtype=int64))
+    (array([0, 1, 2, 2]), array([0, 1, 0, 1]))
 
     >>> x[np.nonzero(x)]
-    array([ 1.,  1.,  1.])
+    array([1, 2, 1, 1])
     >>> np.transpose(np.nonzero(x))
     array([[0, 0],
            [1, 1],
-           [2, 2]])
+           [2, 0],
+           [2, 1])
 
     A common use for ``nonzero`` is to find the indices of an array, where
     a condition is True.  Given an array `a`, the condition `a` > 3 is a


Test patch:
Repository: numpy/numpy

Issue:
DOC: ndarray.max missing keepdims in docstring
Seems that `ndarray.max` can take a `keepdims` argument, but that [doesn't appear in the docs]( https://docs.scipy.org/doc/numpy-1.13.0/reference/generated/numpy.ndarray.max.html ).


Discussion:

Resolving patch:
diff --git a/numpy/add_newdocs.py b/numpy/add_newdocs.py
--- a/numpy/add_newdocs.py
+++ b/numpy/add_newdocs.py
@@ -3765,7 +3765,7 @@ def luf(lamdaexpr, *args, **kwargs):
 
 add_newdoc('numpy.core.multiarray', 'ndarray', ('max',
     """
-    a.max(axis=None, out=None)
+    a.max(axis=None, out=None, keepdims=False)
 
     Return the maximum along a given axis.
 


Test patch:
Repository: numpy/numpy

Issue:
Deprecate truth-testing on empty arrays
I tested the waters with this [on the numpy-discussion](https://mail.python.org/pipermail/numpy-discussion/2017-August/077136.html) newsgroup ~earlier this week~ yesterday, and the general response seemed to be that this is actionable, so I am making an issue for further discussion.

The long and short is that truth-testing on empty arrays is **dangerous, misleading, and not in any way useful,** and should be deprecated.

The next post will explain the rationale for deprecation more in-depth.


Discussion:

Resolving patch:
diff --git a/numpy/core/numeric.py b/numpy/core/numeric.py
--- a/numpy/core/numeric.py
+++ b/numpy/core/numeric.py
@@ -406,7 +406,7 @@ def count_nonzero(a, axis=None):
     array([2, 3])
 
     """
-    if axis is None or axis == ():
+    if axis is None or (isinstance(axis, tuple) and axis == ()):
         return multiarray.count_nonzero(a)
 
     a = asanyarray(a)


Test patch:
diff --git a/numpy/core/tests/test_deprecations.py b/numpy/core/tests/test_deprecations.py
--- a/numpy/core/tests/test_deprecations.py
+++ b/numpy/core/tests/test_deprecations.py
@@ -450,5 +450,18 @@ def test_3_tuple(self):
             self.assert_deprecated(cls, args=(1, ('ms', 2, 1, 63)))
 
 
+class TestTruthTestingEmptyArrays(_DeprecationTestCase):
+    # 2017-09-25, 1.14.0
+    message = '.*truth value of an empty array is ambiguous.*'
+
+    def test_1d(self):
+        self.assert_deprecated(bool, args=(np.array([]),))
+
+    def test_2d(self):
+        self.assert_deprecated(bool, args=(np.zeros((1, 0)),))
+        self.assert_deprecated(bool, args=(np.zeros((0, 1)),))
+        self.assert_deprecated(bool, args=(np.zeros((0, 0)),))
+
+
 if __name__ == "__main__":
     run_module_suite()
Repository: numpy/numpy

Issue:
BUG: str of long arrays has stray comma
```
a = np.arange(5000)
print(a)
[   0    1    2 ..., 4997 4998 4999]
```


Discussion:

Resolving patch:
diff --git a/numpy/core/arrayprint.py b/numpy/core/arrayprint.py
--- a/numpy/core/arrayprint.py
+++ b/numpy/core/arrayprint.py
@@ -373,7 +373,7 @@ def wrapper(self, *args, **kwargs):
 @_recursive_guard()
 def _array2string(a, options, separator=' ', prefix=""):
     if a.size > options['threshold']:
-        summary_insert = "..., "
+        summary_insert = "..."
         data = _leading_trailing(a)
     else:
         summary_insert = ""
@@ -545,7 +545,7 @@ def _formatArray(a, format_function, rank, max_line_len,
     if summary_insert and 2*edge_items < len(a):
         leading_items = edge_items
         trailing_items = edge_items
-        summary_insert1 = summary_insert
+        summary_insert1 = summary_insert + separator
     else:
         leading_items = 0
         trailing_items = len(a)


Test patch:
diff --git a/numpy/core/tests/test_multiarray.py b/numpy/core/tests/test_multiarray.py
--- a/numpy/core/tests/test_multiarray.py
+++ b/numpy/core/tests/test_multiarray.py
@@ -5624,7 +5624,7 @@ def test_3d_tensor(self):
 class TestSummarization(object):
     def test_1d(self):
         A = np.arange(1001)
-        strA = '[   0    1    2 ...,  998  999 1000]'
+        strA = '[   0    1    2 ...  998  999 1000]'
         assert_(str(A) == strA)
 
         reprA = 'array([   0,    1,    2, ...,  998,  999, 1000])'
@@ -5632,8 +5632,8 @@ def test_1d(self):
 
     def test_2d(self):
         A = np.arange(1002).reshape(2, 501)
-        strA = '[[   0    1    2 ...,  498  499  500]\n' \
-               ' [ 501  502  503 ...,  999 1000 1001]]'
+        strA = '[[   0    1    2 ...  498  499  500]\n' \
+               ' [ 501  502  503 ...  999 1000 1001]]'
         assert_(str(A) == strA)
 
         reprA = 'array([[   0,    1,    2, ...,  498,  499,  500],\n' \
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
@@ -495,8 +495,8 @@ def test_str_repr(self):
         a[1:50] = np.ma.masked
         assert_equal(
             repr(a),
-            'masked_array(data = [0 -- -- ..., 1997 1998 1999],\n'
-            '             mask = [False  True  True ..., False False False],\n'
+            'masked_array(data = [0 -- -- ... 1997 1998 1999],\n'
+            '             mask = [False  True  True ... False False False],\n'
             '       fill_value = 999999)\n'
         )
Repository: numpy/numpy

Issue:
BUG: Casting `np.ma.masked` to long is legal
This is wrong:
```
>>> int(np.ma.masked)
MaskError: Cannot convert masked element to a Python int.
>>> long(np.ma.masked)
0L
```



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
@@ -4230,6 +4230,18 @@ def __int__(self):
         elif self._mask:
             raise MaskError('Cannot convert masked element to a Python int.')
         return int(self.item())
+    
+    def __long__(self):
+        """
+        Convert to long.
+        """
+        if self.size > 1:
+            raise TypeError("Only length-1 arrays can be conveted "
+                            "to Python scalars")
+        elif self._mask:
+            raise MaskError('Cannot convert masked element to a Python long.')
+        return long(self.item())
+      
 
     def get_imag(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
@@ -4858,10 +4858,14 @@ def test_immutable(self):
         assert_raises(ValueError, operator.setitem, view.data, (), 1)
         assert_raises(ValueError, operator.setitem, view.mask, (), False)
 
-    @dec.knownfailureif(sys.version_info.major == 2, "See gh-9751")
     def test_coercion_int(self):
         a_i = np.zeros((), int)
         assert_raises(MaskError, operator.setitem, a_i, (), np.ma.masked)
+        assert_raises(MaskError, int, np.ma.masked)
+
+    @dec.skipif(sys.version_info.major == 3, "long doesn't exist in Python 3")
+    def test_coercion_long(self):
+        assert_raises(MaskError, long, np.ma.masked)
 
     def test_coercion_float(self):
         a_f = np.zeros((), float)
Repository: numpy/numpy

Issue:
Importing numpy alters the execution environment
In `core/__init__.py` two environment variables, `'OPENBLAS_MAIN_FREE'` and `'GOTOBLAS_MAIN_FREE'`, are temporary set for importing the multiarray numpy extension module. But if the importing is failed the environment is not restored.

This affects CPython tests (https://bugs.python.org/issue31792).

Moving the code that restores the environment into the `finally` block would fix this issue.



Discussion:

Resolving patch:
diff --git a/numpy/core/__init__.py b/numpy/core/__init__.py
--- a/numpy/core/__init__.py
+++ b/numpy/core/__init__.py
@@ -24,9 +24,9 @@
 Original error was: %s
 """ % (exc,)
     raise ImportError(msg)
-
-for envkey in env_added:
-    del os.environ[envkey]
+finally:
+    for envkey in env_added:
+        del os.environ[envkey]
 del envkey
 del env_added
 del os


Test patch:
Repository: numpy/numpy

Issue:
BUG: count_nonzero(axis=()) is inconsistent
A reasonable mental model for `count_nonzero` is `(x != 0).sum(...)`. But if fails in this case:

```
>>> x = np.arange(3)
>>> (x != 0).sum(axis=())
array([0, 1, 1])
>>> np.count_nonzero(x != 0, axis=())
2
```

`axis == ()` should mean `(x == 0).astype(int)`


Discussion:

Resolving patch:
diff --git a/numpy/core/numeric.py b/numpy/core/numeric.py
--- a/numpy/core/numeric.py
+++ b/numpy/core/numeric.py
@@ -406,7 +406,7 @@ def count_nonzero(a, axis=None):
     array([2, 3])
 
     """
-    if axis is None or (isinstance(axis, tuple) and axis == ()):
+    if axis is None:
         return multiarray.count_nonzero(a)
 
     a = asanyarray(a)


Test patch:
diff --git a/numpy/core/tests/test_numeric.py b/numpy/core/tests/test_numeric.py
--- a/numpy/core/tests/test_numeric.py
+++ b/numpy/core/tests/test_numeric.py
@@ -1126,6 +1126,10 @@ def test_count_nonzero_axis_consistent(self):
                         np.count_nonzero(n, axis=perm),
                         err_msg=msg % (perm,))
 
+    def test_countnonzero_axis_empty(self):
+        a = np.array([[0, 0, 1], [1, 0, 1]])
+        assert_equal(np.count_nonzero(a, axis=()), a.astype(bool))
+
     def test_array_method(self):
         # Tests that the array method
         # call to nonzero works
Repository: numpy/numpy

Issue:
Comments not ignored in genfromtxt when names=True
The following example runs into an error

```
import numpy as np
from io import StringIO

s = StringIO(u'''# This comment should be ignored
field_name_0 field_name_1
0 1
2 3''')
data = np.genfromtxt(s, names=True)
```

The first line, minus the comment delimiter is being taken as the names for the dtype, causing the following error.

> ValueError: Some errors were detected !
>     Line #2 (got 2 columns instead of 5)
>     Line #3 (got 2 columns instead of 5)
>     Line #4 (got 2 columns instead of 5)

This seems inconsistent with the fact that the following is fine, and that the documentation for the names and comments fields does not suggest this behavior.

```
import numpy as np
from io import StringIO

s = StringIO(u'''field_name_0 field_name_1
# This comment should be ignored
0 1
2 3''')
data = np.genfromtxt(s, names=True)
```

Was this behavior intended?  If so I would like to update the documentation on the names field.  If not, I'd change the names=True to ignore lines that are entirely comments.


Discussion:
Sure its intended, names are typically comments, so that you can read it in without names as well.

Resolving patch:
diff --git a/numpy/lib/npyio.py b/numpy/lib/npyio.py
--- a/numpy/lib/npyio.py
+++ b/numpy/lib/npyio.py
@@ -1418,11 +1418,12 @@ def genfromtxt(fname, dtype=float, comments='#', delimiter=None,
         Which columns to read, with 0 being the first.  For example,
         ``usecols = (1, 4, 5)`` will extract the 2nd, 5th and 6th columns.
     names : {None, True, str, sequence}, optional
-        If `names` is True, the field names are read from the first valid line
-        after the first `skip_header` lines.
-        If `names` is a sequence or a single-string of comma-separated names,
-        the names will be used to define the field names in a structured dtype.
-        If `names` is None, the names of the dtype fields will be used, if any.
+        If `names` is True, the field names are read from the first line after
+        the first `skip_header` lines.  This line can optionally be proceeded
+        by a comment delimeter. If `names` is a sequence or a single-string of
+        comma-separated names, the names will be used to define the field names
+        in a structured dtype. If `names` is None, the names of the dtype
+        fields will be used, if any.
     excludelist : sequence, optional
         A list of names to exclude. This list is appended to the default list
         ['return','file','print']. Excluded names are appended an underscore:


Test patch:
Repository: numpy/numpy

Issue:
discussion: updating the released wheels to VS2017
Although MSVC 2015 and MSVC 2017 are ABI compatible, numpy generated a library with link-time code generation (LTCG) enabled, which is not compatible. This means that downstream projects cannot be built against the released numpy, but they need to compile from source, and then build against that (note that a project compiled against a numpy that's build from source would still work with DLLs compiled with VS2015).

The question is: should numpy compile wheels for Python 3.5 and Python 3.6 with VS2017? Note that Python 3.6 has made VS2017 the default. And how can we coordinate this in a somewhat reasonable way?




Discussion:

Resolving patch:
diff --git a/numpy/core/setup.py b/numpy/core/setup.py
--- a/numpy/core/setup.py
+++ b/numpy/core/setup.py
@@ -688,7 +688,10 @@ def get_mathlib_info(*args):
     config.add_installed_library('npymath',
             sources=npymath_sources + [get_mathlib_info],
             install_dir='lib',
-            build_info={'include_dirs' : []})  # empty list required for creating npy_math_internal.h
+            build_info={
+                'include_dirs' : [],
+                'extra_compiler_args' : (['/GL-'] if sys.platform == 'win32' else []),
+            })  # empty list required for creating npy_math_internal.h
     config.add_npy_pkg_config("npymath.ini.in", "lib/npy-pkg-config",
             subst_dict)
     config.add_npy_pkg_config("mlib.ini.in", "lib/npy-pkg-config",


Test patch:
Repository: numpy/numpy

Issue:
Bump NPY_API_VERSION for 1.14
I attempted this in my own PR but failed. The version needs to be increased to use WRITEBACKIFCOPY.


Discussion:
@seberg Any way that you take care of this now? SciPy has test failures because of this issue.
Take a look at `doc/HOWTO_RELEASE.rst.txt` around line 218 to see how to update it.

Resolving patch:
diff --git a/numpy/core/setup_common.py b/numpy/core/setup_common.py
--- a/numpy/core/setup_common.py
+++ b/numpy/core/setup_common.py
@@ -39,8 +39,8 @@
 # 0x0000000a - 1.11.x
 # 0x0000000a - 1.12.x
 # 0x0000000b - 1.13.x
-# 0x0000000b - 1.14.x
-C_API_VERSION = 0x0000000b
+# 0x0000000c - 1.14.x
+C_API_VERSION = 0x0000000c
 
 class MismatchCAPIWarning(Warning):
     pass


Test patch:
Repository: numpy/numpy

Issue:
DOC: Outdated Numpy Download URL in PyPI record
Numpy's PyPI entry:
https://pypi.python.org/pypi/numpy
contains an outdated Download URL information:
Download URL: http://sourceforge.net/projects/numpy/files/NumPy/



Discussion:

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -352,7 +352,7 @@ def setup_package():
         long_description = "\n".join(DOCLINES[2:]),
         url = "http://www.numpy.org",
         author = "Travis E. Oliphant et al.",
-        download_url = "http://sourceforge.net/projects/numpy/files/NumPy/",
+        download_url = "https://pypi.python.org/pypi/numpy",
         license = 'BSD',
         classifiers=[_f for _f in CLASSIFIERS.split('\n') if _f],
         platforms = ["Windows", "Linux", "Solaris", "Mac OS-X", "Unix"],


Test patch:
Repository: numpy/numpy

Issue:
BUG: bizarre repr of empty dtype
I doubt anyone is using this, but multiple parts of this repr are bizarre:
```
>>> np.zeros(10, np.dtype([]))
array([), ), ), ), ), ), ), ), ), )], dtype='[]')
```

Thankfully not a 1.14 regression - was there in 1.13 too


Discussion:

Resolving patch:
diff --git a/numpy/core/arrayprint.py b/numpy/core/arrayprint.py
--- a/numpy/core/arrayprint.py
+++ b/numpy/core/arrayprint.py
@@ -1167,7 +1167,6 @@ def __call__(self, arr):
 class StructureFormat(object):
     def __init__(self, format_functions):
         self.format_functions = format_functions
-        self.num_fields = len(format_functions)
 
     @classmethod
     def from_data(cls, data, **options):
@@ -1184,11 +1183,14 @@ def from_data(cls, data, **options):
         return cls(format_functions)
 
     def __call__(self, x):
-        s = "("
-        for field, format_function in zip(x, self.format_functions):
-            s += format_function(field) + ", "
-        return (s[:-2] if 1 < self.num_fields else s[:-1]) + ")"
-
+        str_fields = [
+            format_function(field)
+            for field, format_function in zip(x, self.format_functions)
+        ]
+        if len(str_fields) == 1:
+            return "({},)".format(str_fields[0])
+        else:
+            return "({})".format(", ".join(str_fields))
 
 def _void_scalar_repr(x):
     """
@@ -1248,7 +1250,7 @@ def dtype_short_repr(dtype):
     """
     # handle these separately so they don't give garbage like str256
     if issubclass(dtype.type, flexible):
-        if dtype.names:
+        if dtype.names is not None:
             return "%s" % str(dtype)
         else:
             return "'%s'" % str(dtype)


Test patch:
diff --git a/numpy/core/tests/test_arrayprint.py b/numpy/core/tests/test_arrayprint.py
--- a/numpy/core/tests/test_arrayprint.py
+++ b/numpy/core/tests/test_arrayprint.py
@@ -64,6 +64,12 @@ def test_void_scalar_recursion(self):
         # gh-9345
         repr(np.void(b'test'))  # RecursionError ?
 
+    def test_fieldless_structured(self):
+        # gh-10366
+        no_fields = np.dtype([])
+        arr_no_fields = np.empty(4, dtype=no_fields)
+        assert_equal(repr(arr_no_fields), 'array([(), (), (), ()], dtype=[])')
+
 
 class TestComplexArray(object):
     def test_str(self):