Repository: astropy/astropy

Issue:
TST: np.alen is deprecated, use len instead
How to best fix this one? Is deleting the test sufficient, @mhvk ?

```
________________________ TestShapeInformation.test_alen ________________________

self = <astropy.units.tests.test_quantity_non_ufuncs.TestShapeInformation object at 0x7fc9a7f16c50>

    def test_alen(self):

>       assert np.alen(self.q) == 3

astropy/units/tests/test_quantity_non_ufuncs.py:76: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

<__array_function__ internals>:6: in alen

    ???

astropy/units/quantity.py:1502: in __array_function__

    return super().__array_function__(function, types, args, kwargs)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

a = <Quantity [[0.  , 0.25, 0.5 ],

           [0.75, 1.  , 1.25],

           [1.5 , 1.75, 2.  ]] m>

    @array_function_dispatch(_alen_dispathcer)

    def alen(a):

        """

        Return the length of the first dimension of the input array.

    

        Parameters

        ----------

        a : array_like

           Input array.

    

        Returns

        -------

        alen : int

           Length of the first dimension of `a`.

    

        See Also

        --------

        shape, size

    

        Examples

        --------

        >>> a = np.zeros((7,4,5))

        >>> a.shape[0]

        7

        >>> np.alen(a)

        7

    

        """

        # NumPy 1.18.0, 2019-08-02

        warnings.warn(

            "`np.alen` is deprecated, use `len` instead",

>           DeprecationWarning, stacklevel=2)

E       DeprecationWarning: `np.alen` is deprecated, use `len` instead
```

Discussion:
bsipocz: Note that LTS is not python2 only, but we don't need to backport as np 1.18 will be out after EOS of that branch. 
And in fact we also removed numpy dev testing for 3.2.x with the same reasoning.
pllim: > we also removed numpy dev testing for 3.2.x with the same reasoning

Oh... should I move the milestone to 4.0 then, @bsipocz ?
pllim: Thanks for the review!

p.s. I don't know why CircleCI is not running.
bsipocz: @pllim - I've tried to restart it but it's stubborn. Given that this really is for numpy-dev and shouldn't affect the rest, I suggest to go ahead and merge once travis is happy with this (it has enough coverage for other versions, too to be safe enough).
bsipocz: There are still related looking failures.

Patch:
diff --git a/astropy/units/quantity_helper/function_helpers.py b/astropy/units/quantity_helper/function_helpers.py
index 69b48c96f8..b9d363abf1 100644
--- a/astropy/units/quantity_helper/function_helpers.py
+++ b/astropy/units/quantity_helper/function_helpers.py
@@ -67,7 +67,7 @@ UNSUPPORTED_FUNCTIONS = set()
 """Functions that cannot sensibly be used with quantities."""
 
 SUBCLASS_SAFE_FUNCTIONS |= {
-    np.alen, np.shape, np.size, np.ndim,
+    np.shape, np.size, np.ndim,
     np.reshape, np.ravel, np.moveaxis, np.rollaxis, np.swapaxes,
     np.transpose, np.atleast_1d, np.atleast_2d, np.atleast_3d,
     np.expand_dims, np.squeeze, np.broadcast_to, np.broadcast_arrays,
@@ -99,7 +99,8 @@ SUBCLASS_SAFE_FUNCTIONS |= {
 
 if not NUMPY_LT_1_15:
     SUBCLASS_SAFE_FUNCTIONS |= {np.take_along_axis, np.put_along_axis}
-
+if NUMPY_LT_1_18:
+    SUBCLASS_SAFE_FUNCTIONS |= {np.alen}
 
 # Implemented as methods on Quantity:
 # np.ediff1d is from setops, but we support it anyway; the others
@@ -140,6 +141,8 @@ IGNORED_FUNCTIONS = {
     np.pv, np.rate}
 if NUMPY_LT_1_18:
     IGNORED_FUNCTIONS |= {np.rank}
+else:
+    IGNORED_FUNCTIONS |= {np.alen}
 UNSUPPORTED_FUNCTIONS |= IGNORED_FUNCTIONS
 
 


Test patch:
diff --git a/astropy/units/tests/test_quantity_non_ufuncs.py b/astropy/units/tests/test_quantity_non_ufuncs.py
index b3c0a3603a..e05e520998 100644
--- a/astropy/units/tests/test_quantity_non_ufuncs.py
+++ b/astropy/units/tests/test_quantity_non_ufuncs.py
@@ -72,8 +72,10 @@ class NoUnitTestSetup(BasicTestSetup):
 
 
 class TestShapeInformation(BasicTestSetup):
-    def test_alen(self):
-        assert np.alen(self.q) == 3
+    # alen is deprecated in Numpy 1.8
+    if NUMPY_LT_1_18:
+        def test_alen(self):
+            assert np.alen(self.q) == 3
 
     def test_shape(self):
         assert np.shape(self.q) == (3, 3)
@@ -1761,8 +1763,10 @@ deprecated_functions = {
     }
 if NUMPY_LT_1_18:
     deprecated_functions |= {np.rank}
-untested_functions |= deprecated_functions
+else:
+    deprecated_functions |= {np.alen}
 
+untested_functions |= deprecated_functions
 io_functions = {np.save, np.savez, np.savetxt, np.savez_compressed}
 untested_functions |= io_functions