Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support case-insensitive query criteria #3087

Merged
merged 3 commits into from
Aug 28, 2024

Conversation

snbianco
Copy link
Contributor

Observations.query_criteria and Catalogs.query_criteria now support case insensitivity for criteria keyword arguments. For example, the argument objtype is treated the same as objType.

@snbianco snbianco requested a review from bsipocz August 26, 2024 02:24
@snbianco
Copy link
Contributor Author

@dr-rodriguez

@snbianco snbianco marked this pull request as ready for review August 26, 2024 02:32
Copy link
Member

@bsipocz bsipocz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I consistently see a new failing remote test with this compared to main, could you please have a look into it?

_________________________________________ TestMast.test_catalogs_query_region __________________________________________

self = <astroquery.mast.tests.test_mast_remote.TestMast object at 0x127c2b920>

    def test_catalogs_query_region(self):
        def check_result(result, row, exp_values):
            assert isinstance(result, Table)
            for k, v in exp_values.items():
                assert result[row][k] == v
    
        in_radius = 0.1 * u.deg
        result = Catalogs.query_region("158.47924 -7.30962",
                                       radius=in_radius,
                                       catalog="Gaia")
        row = np.where(result['source_id'] == '3774902350511581696')
        check_result(result, row, {'solution_id': '1635721458409799680'})
    
        result = Catalogs.query_region("322.49324 12.16683",
                                       radius=0.001*u.deg,
                                       catalog="HSC",
                                       magtype=2)
        row = np.where(result['MatchID'] == '8150896')
    
        with pytest.warns(MaxResultsWarning):
            result = Catalogs.query_region("322.49324 12.16683", catalog="HSC", magtype=2, nr=5)
    
        check_result(result, row, {'NumImages': 14, 'TargetName': 'M15'})
    
        result = Catalogs.query_region("322.49324 12.16683",
                                       radius=0.001*u.deg,
                                       catalog="HSC",
                                       version=2,
                                       magtype=2)
        row = np.where(result['MatchID'] == '82361658')
        check_result(result, row, {'NumImages': 11, 'TargetName': 'NGC7078'})
    
        result = Catalogs.query_region("322.49324 12.16683",
                                       radius=in_radius,
                                       catalog="Gaia",
                                       version=1)
        row = np.where(result['source_id'] == '1745948323734098688')
        check_result(result, row, {'solution_id': '1635378410781933568'})
        result = Catalogs.query_region("322.49324 12.16683",
                                       radius=0.01*u.deg,
                                       catalog="Gaia",
                                       version=2)
    
        row = np.where(result['source_id'] == '1745947739618544000')
        check_result(result, row, {'solution_id': '1635721458409799680'})
    
        result = Catalogs.query_region("322.49324 12.16683",
                                       radius=0.01*u.deg, catalog="panstarrs",
                                       table="mean")
        row = np.where((result['objName'] == 'PSO J322.4622+12.1920') & (result['yFlags'] == 16777496))
        second_id = result[1]['objID']
        assert isinstance(result, Table)
        np.testing.assert_allclose(result[row]['distance'], 0.039381703406789904)
    
        result = Catalogs.query_region("322.49324 12.16683",
                                       radius=0.01*u.deg, catalog="panstarrs",
                                       table="mean",
                                       pagesize=1,
                                       page=2)
        assert isinstance(result, Table)
        assert len(result) == 1
>       assert second_id == result[0]['objID']
E       assert 122603224875385592 == 122583224908139887

astroquery/mast/tests/test_mast_remote.py:700: AssertionError
=============================================== short test summary info ================================================
FAILED astroquery/mast/tests/test_mast_remote.py::TestMast::test_observations_get_cloud_uris_no_duplicates - DeprecationWarning: datetime.datetime.utcnow() is deprecated and scheduled for removal in a future version. Use tim...
FAILED astroquery/mast/tests/test_mast_remote.py::TestMast::test_catalogs_query_region - assert 122603224875385592 == 122583224908139887

@snbianco
Copy link
Contributor Author

Huh, that is weird. As far as I can tell, it seems like the results are being returned in a variable order for Pan-STARRS (at least). I've moved the page/pagesize check into a different query since the TIC doesn't seem to have this issue. I'll make a ticket on our side to look more closely at why the order of results is changing.

Copy link
Member

@ceb8 ceb8 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@bsipocz bsipocz added the mast label Aug 28, 2024
@bsipocz bsipocz added this to the v0.4.8 milestone Aug 28, 2024
Copy link
Member

@bsipocz bsipocz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@bsipocz bsipocz merged commit c043346 into astropy:main Aug 28, 2024
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants