astropy / astropy/astroquery

Order of columns in result are not deterministic

Open
#2,313 2 comments 0 reactions 0 assignees View on GitHub
bug mast Upstream
Dominant language
Python
Stars
791
Forks
451
Avg merge
1d 3h
Merged PRs (30d)
4

Description

It would be nice to do something about this before it goes out to a release, I run into it during doctesting.

```
In [1]: >>> from astroquery.mast.missions import MastMissions
...: >>> from astropy.coordinates import SkyCoord
...: >>> missions = MastMissions(mission='hst')
...: >>> regionCoords = SkyCoord(210.80227, 54.34895, unit=('deg', 'deg'))
...: >>> results = missions.query_region(regionCoords, 3, sci_pep_id=12556,
...: ... select_cols=["sci_stop_time", "sci_targname", "sci_start_time", "sci_status"],
...: ... sort_by=['sci_targname'], cache=False)
...: >>> results[:5]
Out[1]:

sci_targname sci_start_time ang_sep sci_status sci_stop_time sci_data_set_name search_pos
str16 str26 str20 str6 str26 str9 str18
---------------- -------------------------- -------------------- ---------- -------------------------- ----------------- ------------------
NUCLEUS+HODGE602 2012-05-24T09:17:38.570000 0.017460048037303017 PUBLIC 2012-05-24T09:20:44.570000 OBQU010H0 210.80227 54.34895
NUCLEUS+HODGE602 2012-05-24T07:51:40.553000 0.017460048037303017 PUBLIC 2012-05-24T07:54:46.553000 OBQU01050 210.80227 54.34895
NUCLEUS+HODGE602 2012-05-24T07:43:20.553000 0.022143836477276503 PUBLIC 2012-05-24T07:46:26.553000 OBQU01030 210.80227 54.34895
NUCLEUS+HODGE602 2012-05-24T09:09:18.570000 0.022143836477276503 PUBLIC 2012-05-24T09:12:24.570000 OBQU010F0 210.80227 54.34895
NUCLEUS+HODGE602 2012-05-24T09:25:58.570000 0.04381046755938432 PUBLIC 2012-05-24T09:29:04.570000 OBQU010J0 210.80227 54.34895

In [2]: >>> from astroquery.mast.missions import MastMissions
...: >>> from astropy.coordinates import SkyCoord
...: >>> missions = MastMissions(mission='hst')
...: >>> regionCoords = SkyCoord(210.80227, 54.34895, unit=('deg', 'deg'))
...: >>> results = missions.query_region(regionCoords, 3, sci_pep_id=12556,
...: ... select_cols=["sci_stop_time", "sci_targname", "sci_start_time", "sci_status"],
...: ... sort_by=['sci_targname'], cache=False)
...: >>> results[:5]
Out[2]:

sci_start_time sci_stop_time sci_data_set_name search_pos sci_status ang_sep sci_targname
str26 str26 str9 str18 str6 str20 str16
-------------------------- -------------------------- ----------------- ------------------ ---------- -------------------- ----------------
2012-05-24T09:17:38.570000 2012-05-24T09:20:44.570000 OBQU010H0 210.80227 54.34895 PUBLIC 0.017460048037303017 NUCLEUS+HODGE602
2012-05-24T07:51:40.553000 2012-05-24T07:54:46.553000 OBQU01050 210.80227 54.34895 PUBLIC 0.017460048037303017 NUCLEUS+HODGE602
2012-05-24T07:43:20.553000 2012-05-24T07:46:26.553000 OBQU01030 210.80227 54.34895 PUBLIC 0.022143836477276503 NUCLEUS+HODGE602
2012-05-24T09:09:18.570000 2012-05-24T09:12:24.570000 OBQU010F0 210.80227 54.34895 PUBLIC 0.022143836477276503 NUCLEUS+HODGE602
2012-05-24T09:25:58.570000 2012-05-24T09:29:04.570000 OBQU010J0 210.80227 54.34895 PUBLIC 0.04381046755938432 NUCLEUS+HODGE602
```

cc @syed-gilani @jaymedina

Contributor guide

Open the contributing guide

Research direction

Start at MastMissions.query_region with the doctest example and inspect how select_cols and the returned table columns are assembled. Reproduce the query twice with the shown inputs; done means the result columns remain in a deterministic order, ideally matching the requested selection order.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.