Skip to content

Commit a12c17a

Browse files
committed
get_skycoord: improve performance by continuing to ignore non-scalar SkyCoord targets when checking for multiple targets
1 parent 09dd586 commit a12c17a

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

astroplan/observer.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -518,10 +518,7 @@ def _preprocess_inputs(self, time, target=None, grid_times_targets=False):
518518
return time, None
519519

520520
# Remember whether target is a single time-dependent target
521-
is_multiple_targets = (
522-
isinstance(target, (list, tuple)) or
523-
(isinstance(target, SkyCoord) and not target.isscalar)
524-
)
521+
is_multiple_targets = isinstance(target, (list, tuple))
525522
is_target_time_dependent = (
526523
callable(getattr(target, "get_skycoord", None)) and not
527524
hasattr(target, "coord")

astroplan/target.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -422,10 +422,9 @@ def _as_coord(obj):
422422
return obj.get_skycoord(times)
423423
return obj
424424

425-
is_multiple_targets = (
426-
isinstance(targets, (list, tuple)) or
427-
(isinstance(targets, SkyCoord) and not targets.isscalar)
428-
)
425+
# Ignore non-scalar SkyCoords targets here
426+
# e.g. from get_body/get_sun, because they represent a single target
427+
is_multiple_targets = isinstance(targets, (list, tuple))
429428
if not is_multiple_targets:
430429
return _as_coord(targets)
431430

0 commit comments

Comments
 (0)