Repository: astropy/astropy

Issue:
TST: New failures in "numpy-dev" job?
I don't see how these are related to the `einsum` thingy that is known. Example: https://travis-ci.org/astropy/astropy/jobs/342443502

```
_________________________________ test__str__ __________________________________
        # non-scalar array angles
        arrangle = Angle(['10.2345d', '-20d'])
>       strarrangle = arrangle.__str__()
astropy/coordinates/tests/test_angles.py:861: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
x = 10.2345
>   return np.array2string(self, formatter={'all': lambda x: x.to_string()})
E   AttributeError: 'numpy.float64' object has no attribute 'to_string'
astropy/coordinates/angles.py:433: AttributeError
```

```
_______________________________ test_repr_latex ________________________________
        # and array angles
        arrangle = Angle([1, 2.1], u.deg)
>       rlarrangle = arrangle._repr_latex_()
astropy/coordinates/tests/test_angles.py:880: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
x = 1.0
>   return np.array2string(self, formatter={'all': lambda x: x.to_string(format='latex')})
E   AttributeError: 'numpy.float64' object has no attribute 'to_string'
astropy/coordinates/angles.py:441: AttributeError
```

```
______________________ TestTableFunctions.test_mask_array ______________________
        expect = r"\[\('NGC1002',\s+12.3[0-9]*\) \(\'NGC1003\',\s+15.[0-9]+\)\]"
>       assert re.match(expect, str(hdu.data))
E       assert None
E        +  where None = <function match at 0x7f9c2068fe18>("\\[\\('NGC1002',\\s+12.3[0-9]*\\) \\(\\'NGC1003\\',\\s+15.[0-9]+\\)\\]", "[(b'NGC1002', 12.3) (b'NGC1003', 15.2)]")
E        +    where <function match at 0x7f9c2068fe18> = re.match
E        +    and   "[(b'NGC1002', 12.3) (b'NGC1003', 15.2)]" = str(FITS_rec([(b'NGC1002', 12.3), (b'NGC1003', 15.2)],\n         dtype=(numpy.record, [('target', 'S20'), ('V_mag', '>f4')])))
E        +      where FITS_rec([(b'NGC1002', 12.3), (b'NGC1003', 15.2)],\n         dtype=(numpy.record, [('target', 'S20'), ('V_mag', '>f4')])) = <astropy.io.fits.hdu.table.BinTableHDU object at 0x7f9bb7bf6438>.data
astropy/io/fits/tests/test_table.py:860: AssertionError
```

```
_____________________ [doctest] docs/coordinates/index.rst _____________________
248 :func:`astropy.coordinates.EarthLocation.get_site_names`.
249 
250 For arbitrary Earth addresses (e.g., not observatory sites), use the
251 `~astropy.coordinates.EarthLocation.of_address` classmethod. Any address passed
252 to this function uses Google maps to retrieve the latitude and longitude and can
253 also (optionally) query Google maps to get the height of the location. As with
254 Google maps, this works with fully specified addresses, location names, city
255 names, and etc.::
256 
257     >>> EarthLocation.of_address('1002 Holy Grail Court, St. Louis, MO')  # doctest: +REMOTE_DATA +FLOAT_CMP
Expected:
    <EarthLocation (-26726.98216371, -4997009.8604809, 3950271.16507911) m>
Got:
    <EarthLocation (-26724.93406367, -4997006.87829221, 3950274.92599205) m>
/tmp/astropy-test-eem6lc45/lib/python3.6/site-packages/docs/coordinates/index.rst:257: DocTestFailure
```

```
_________________ [doctest] docs/io/fits/usage/unfamiliar.rst __________________
020 same, i.e. the data is in the ``.data`` attribute and the ``field()`` method
021 is used to refer to the columns and returns a numpy array. When reading the
022 table, Astropy will automatically detect what kind of table it is.
023 
024 ::
025 
026     >>> from astropy.io import fits
027     >>> filename = fits.util.get_testdata_filepath('ascii.fits')
028     >>> hdul = fits.open(filename)
029     >>> hdul[1].data[:1]  # doctest: +FLOAT_CMP
Expected:
    FITS_rec([(10.123, 37)],
             dtype=(numpy.record, {'names':['a','b'], 'formats':['S10','S5'], 'offsets':[0,11], 'itemsize':16}))
Got:
    FITS_rec([(b'.10123E+02', b'   37')],
             dtype=(numpy.record, {'names':['a','b'], 'formats':['S10','S5'], 'offsets':[0,11], 'itemsize':16}))
/tmp/astropy-test-eem6lc45/lib/python3.6/site-packages/docs/io/fits/usage/unfamiliar.rst:29: DocTestFailure
```

Discussion:
astropy-bot[bot]: Hi there @mhvk :wave: - thanks for the pull request! I'm just a friendly :robot: that checks for issues related to the changelog and making sure that this pull request is milestoned and labeled correctly. This is mainly intended for the maintainers, so if you are not a maintainer you can ignore this, and a maintainer will let you know if any action is required on your part :smiley:.

I noticed the following issue with this pull request:

* Changelog entry section (v3.1) inconsistent with milestone (v2.0.5)

Would it be possible to fix this? Thanks!

*If there are any issues with this message, please report them [here](https://github.com/astropy/astropy-bot/issues).*
astrofrog: The Travis failure is due to a bug in Cython that we've worked around in https://github.com/astropy/astropy/pull/7232
astrofrog: @mhvk - can you rebase now that I've merged https://github.com/astropy/astropy/pull/7232?

Patch:
diff --git a/CHANGES.rst b/CHANGES.rst
index e37aea279f..73afe9f636 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -276,8 +276,6 @@ astropy.io.registry
 astropy.io.votable
 ^^^^^^^^^^^^^^^^^^
 
-- Fix lookup fields by ID. [#7208]
-
 astropy.modeling
 ^^^^^^^^^^^^^^^^
 
@@ -788,6 +786,8 @@ astropy.coordinates
 
 - Add a workaround for a bug in the einsum function in Numpy 1.14.0. [#7187]
 
+- Fix problems with printing ``Angle`` instances under numpy 1.14.1. [#7234]
+
 astropy.cosmology
 ^^^^^^^^^^^^^^^^^
 
diff --git a/astropy/coordinates/angles.py b/astropy/coordinates/angles.py
index 00bf06838b..1c1a883291 100644
--- a/astropy/coordinates/angles.py
+++ b/astropy/coordinates/angles.py
@@ -14,6 +14,7 @@ import numpy as np
 from . import angle_utilities as util
 from .. import units as u
 from ..utils import isiterable
+from ..utils.compat import NUMPY_LT_1_14_1
 
 __all__ = ['Angle', 'Latitude', 'Longitude']
 
@@ -426,19 +427,26 @@ class Angle(u.SpecificTypeQuantity):
             ok &= np.all(self < Angle(upper))
         return bool(ok)
 
-    def __str__(self):
+    def _str_helper(self, format=None):
         if self.isscalar:
-            return str(self.to_string())
+            return self.to_string(format=format)
+
+        if NUMPY_LT_1_14_1:
+            def formatter(x):
+                return x.to_string(format=format)
         else:
-            return np.array2string(self, formatter={'all': lambda x: x.to_string()})
+            # In numpy 1.14.1, array2print formatters get passed plain numpy scalars instead
+            # of subclass array scalars, so we need to recreate an array scalar.
+            def formatter(x):
+                return self._new_view(x).to_string(format=format)
+
+        return np.array2string(self, formatter={'all': formatter})
+
+    def __str__(self):
+        return self._str_helper()
 
     def _repr_latex_(self):
-        if self.isscalar:
-            return self.to_string(format='latex')
-        else:
-            # Need to do a magic incantation to convert to str.  Regular str
-            # or array2string causes all backslashes to get doubled.
-            return np.array2string(self, formatter={'all': lambda x: x.to_string(format='latex')})
+        return self._str_helper(format='latex')
 
 
 def _no_angle_subclass(obj):
diff --git a/astropy/io/votable/tree.py b/astropy/io/votable/tree.py
index d9bf228d65..5cb7bba6c6 100644
--- a/astropy/io/votable/tree.py
+++ b/astropy/io/votable/tree.py
@@ -2860,11 +2860,14 @@ class Table(Element, _IDProperty, _NameProperty, _UcdProperty,
                     new_name = '{0}{1}'.format(name, i)
                     i += 1
                 unique_names.append(new_name)
+            array = self.array.copy()
+            array.dtype.names = unique_names
             names = unique_names
         else:
+            array = self.array
             names = [field.ID for field in self.fields]
 
-        table = Table(self.array, names=names, meta=meta)
+        table = Table(self.array, meta=meta)
 
         for name, field in zip(names, self.fields):
             column = table[name]
diff --git a/astropy/utils/compat/numpycompat.py b/astropy/utils/compat/numpycompat.py
index d887203c50..4f8ddf703d 100644
--- a/astropy/utils/compat/numpycompat.py
+++ b/astropy/utils/compat/numpycompat.py
@@ -7,7 +7,8 @@ from ...utils import minversion
 
 
 __all__ = ['NUMPY_LT_1_10_4', 'NUMPY_LT_1_11', 'NUMPY_LT_1_11_2',
-           'NUMPY_LT_1_12', 'NUMPY_LT_1_13', 'NUMPY_LT_1_14']
+           'NUMPY_LT_1_12', 'NUMPY_LT_1_13', 'NUMPY_LT_1_14',
+           'NUMPY_LT_1_14_1']
 
 # TODO: It might also be nice to have aliases to these named for specific
 # features/bugs we're checking for (ex:
@@ -17,4 +18,5 @@ NUMPY_LT_1_11 = not minversion('numpy', '1.11.0')
 NUMPY_LT_1_11_2 = not minversion('numpy', '1.11.2')
 NUMPY_LT_1_12 = not minversion('numpy', '1.12')
 NUMPY_LT_1_13 = not minversion('numpy', '1.13')
-NUMPY_LT_1_14 = not minversion('numpy', '1.14dev')
+NUMPY_LT_1_14 = not minversion('numpy', '1.14')
+NUMPY_LT_1_14_1 = not minversion('numpy', '1.14.1')
diff --git a/docs/io/fits/usage/unfamiliar.rst b/docs/io/fits/usage/unfamiliar.rst
index e7990c3777..a89621cc6a 100644
--- a/docs/io/fits/usage/unfamiliar.rst
+++ b/docs/io/fits/usage/unfamiliar.rst
@@ -26,6 +26,13 @@ table, Astropy will automatically detect what kind of table it is.
     >>> from astropy.io import fits
     >>> filename = fits.util.get_testdata_filepath('ascii.fits')
     >>> hdul = fits.open(filename)
+
+..
+    This needs to be skipped for numpy-1.14.1. It should be removed when 1.14.2
+    is available. See https://github.com/astropy/astropy/issues/7214.
+
+.. doctest-skip::
+
     >>> hdul[1].data[:1]  # doctest: +FLOAT_CMP
     FITS_rec([(10.123, 37)],
              dtype=(numpy.record, {'names':['a','b'], 'formats':['S10','S5'], 'offsets':[0,11], 'itemsize':16}))
@@ -92,6 +99,13 @@ The other difference is the need to specify the table type when using the
     ...                    bzero=0.6, ascii=True)
     >>> col3 = fits.Column(name='t1', format='I', array=[91, 92, 93], ascii=True)
     >>> hdu = fits.TableHDU.from_columns([col1, col2, col3])
+
+..
+    This needs to be skipped for numpy-1.14.1. It should be removed when 1.14.2
+    is available. See https://github.com/astropy/astropy/issues/7214.
+
+.. doctest-skip::
+
     >>> hdu.data
     FITS_rec([('abc', 11.0, 91), ('def', 12.0, 92), ('', 0.0, 93)],
              dtype=(numpy.record, [('abc', 'S3'), ('def', 'S15'), ('t1', 'S10')]))


Test patch:
diff --git a/astropy/io/fits/tests/test_table.py b/astropy/io/fits/tests/test_table.py
index 906f19364d..09df99c823 100644
--- a/astropy/io/fits/tests/test_table.py
+++ b/astropy/io/fits/tests/test_table.py
@@ -18,6 +18,7 @@ except ImportError:
 
 from ....io import fits
 from ....tests.helper import catch_warnings, ignore_warnings
+from ....utils.compat import NUMPY_LT_1_14_1
 from ....utils.exceptions import AstropyDeprecationWarning
 
 from ..column import Delayed, NUMPY2FITS
@@ -844,6 +845,8 @@ class TestTableFunctions(FitsTestCase):
             assert header['TNULL2'] == 'b'
             assert header['TNULL3'] == 2.3
 
+    @pytest.mark.xfail(not NUMPY_LT_1_14_1,
+        reason="See https://github.com/astropy/astropy/issues/7214")
     def test_mask_array(self):
         t = fits.open(self.data('table.fits'))
         tbdata = t[1].data
diff --git a/astropy/io/votable/tests/table_test.py b/astropy/io/votable/tests/table_test.py
index d5ec8714de..a4feba473a 100644
--- a/astropy/io/votable/tests/table_test.py
+++ b/astropy/io/votable/tests/table_test.py
@@ -107,17 +107,6 @@ def test_names_over_ids():
         'Emag', '24mag', 'f_Name']
 
 
-def test_explicit_ids():
-    with get_pkg_data_fileobj('data/names.xml', encoding='binary') as fd:
-        votable = parse(fd)
-
-    table = votable.get_first_table().to_table(use_names_over_ids=False)
-
-    assert table.colnames == [
-        'col1', 'col2', 'col3', 'col4', 'col5', 'col6', 'col7', 'col8', 'col9',
-        'col10', 'col11', 'col12', 'col13', 'col14', 'col15', 'col16', 'col17']
-
-
 def test_table_read_with_unnamed_tables():
     """
     Issue #927