From: Brigitta Sipocz <bsipocz@gmail.com>
Date: Wed, 21 Dec 2016 19:47:42 +0100
Subject: pull/274: Stop recognizing scalar SkyCoord objects as vectors

SkyCoords recently (new in astropy 1.3, from astropy/astropy#5254) got
an iter attribute inherited from ShapedLikeNDArray, so it's not enough
any more to check for the existence of that attribute to distinguish
vectors from scalars.

This PR should fix the issue while also gets rid of 19 test failures
against astropy dev.

URL: https://github.com/astropy/astroplan/pull/274
---
 astroplan/observer.py | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/astroplan/observer.py b/astroplan/observer.py
index 25eb1d4..873a609 100644
--- a/astroplan/observer.py
+++ b/astroplan/observer.py
@@ -13,6 +13,7 @@ from astropy.coordinates import (EarthLocation, SkyCoord, AltAz, get_sun,
 from astropy.extern.six import string_types
 import astropy.units as u
 from astropy.time import Time
+from astropy.utils import isiterable
 import numpy as np
 import pytz
 
@@ -66,13 +67,6 @@ def _generate_24hr_grid(t0, start, end, N, for_deriv=False):
     return t0 + time_grid
 
 
-def _target_is_vector(target):
-    if hasattr(target, '__iter__'):
-        return True
-    else:
-        return False
-
-
 class Observer(object):
 
     """
@@ -458,7 +452,7 @@ class Observer(object):
             return altaz_frame
         else:
             # If target is a list of targets:
-            if _target_is_vector(target):
+            if isiterable(target) and not isinstance(target, SkyCoord):
                 get_coord = lambda x: x.coord if hasattr(x, 'coord') else x
                 transformed_coords = self._transform_target_list_to_altaz(time,
                                                                           list(map(get_coord, target)))
@@ -505,7 +499,7 @@ class Observer(object):
         if not isinstance(time, Time):
             time = Time(time)
 
-        if _target_is_vector(target):
+        if isiterable(target):
             get_coord = lambda x: x.coord if hasattr(x, 'coord') else x
             coordinate = SkyCoord(list(map(get_coord, target)))
         else:
@@ -704,7 +698,7 @@ class Observer(object):
         if not isinstance(time, Time):
             time = Time(time)
 
-        target_is_vector = _target_is_vector(target)
+        target_is_vector = isiterable(target)
 
         if prev_next == 'next':
             times = _generate_24hr_grid(time, 0, 1, N)
@@ -766,7 +760,7 @@ class Observer(object):
         if not isinstance(time, Time):
             time = Time(time)
 
-        target_is_vector = _target_is_vector(target)
+        target_is_vector = isiterable(target)
 
         if prev_next == 'next':
             times = _generate_24hr_grid(time, 0, 1, N, for_deriv=True)
@@ -837,7 +831,7 @@ class Observer(object):
                 return previous_event
 
         if which == 'nearest':
-            if _target_is_vector(target):
+            if isiterable(target):
                 return_times = []
                 for next_e, prev_e in zip(next_event, previous_event):
                     if abs(time - prev_e) < abs(time - next_e):
@@ -1547,7 +1541,7 @@ class Observer(object):
             time = Time(time)
 
         altaz = self.altaz(time, target)
-        if _target_is_vector(target):
+        if isiterable(target):
             observable = [bool(alt > horizon) for alt in altaz.alt]
         else:
             observable = bool(altaz.alt > horizon)
@@ -1658,7 +1652,7 @@ class Observer(object):
         if not isinstance(time, Time):
             time = Time(time)
 
-        if _target_is_vector(target):
+        if isiterable(target):
             coords = [t.coord if hasattr(t, 'coord') else t
                       for t in target]
 
