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

Updated SIA up-casing behavior #545

Merged
merged 5 commits into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@ Enhancements and Fixes
them. [#517]

- Introducing the new MIVOT module, enabling processed VOTable data mapped to
any model serialized in VO-DML. This package dynamically generates python objects
any model serialized in VO-DML. This package dynamically generates python objects
whose structure corresponds to the classes of the mapped models. [#497]


Deprecations and Removals
-------------------------

Expand All @@ -39,6 +40,8 @@ Bug Fixes
- Avoid Astropy Time error for SIAResult.dateobs when
VOX:Image_MJDateObs or ssa:DataID.Date is nan. [#550]

- More robust handling of SIA1 FORMAT [#545]


1.5.1 (2024-02-21)
==================
Expand Down
16 changes: 12 additions & 4 deletions pyvo/dal/sia.py
Original file line number Diff line number Diff line change
Expand Up @@ -506,10 +506,18 @@ def format(self):
def format(self, format_):
setattr(self, "_format", format_)

if isinstance(format_, (str, bytes)):
format_ = [format_]

self["FORMAT"] = ",".join(_.upper() for _ in format_)
if not isinstance(format_, list):
format_ = format_.split(',')
normalized_formats = []
for user_input in format_:
if user_input.upper() in ['ALL', 'METADATA', 'GRAPHIC', 'GRAPHIC-ALL']:
normalized_formats.append(user_input.upper())
elif user_input.split('-')[0].upper() == 'GRAPHIC':
normalized_formats.append(user_input.split('-')[0].upper()+"-"+user_input.split('-')[1])
else:
normalized_formats.append(user_input)

self["FORMAT"] = ",".join(normalized_formats)

@format.deleter
def format(self):
Expand Down
23 changes: 20 additions & 3 deletions pyvo/dal/tests/test_sia.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import pytest

from pyvo.dal.sia import search, SIAService
from pyvo.dal.sia import search, SIAService, SIAQuery

from astropy.io.fits import HDUList
from astropy.coordinates import SkyCoord
Expand Down Expand Up @@ -47,8 +47,9 @@ def _test_result(result):
@pytest.mark.usefixtures('register_mocks')
@pytest.mark.filterwarnings("ignore::astropy.io.votable.exceptions.W06")
@pytest.mark.parametrize("position", ((288, 15), SkyCoord(288, 15, unit="deg")))
def test_search(position):
results = search('http://example.com/sia', pos=position)
@pytest.mark.parametrize("format", ("IMAGE/JPEG", "all"))
def test_search(position, format):
results = search('http://example.com/sia', pos=position, format=format)
result = results[0]

_test_result(result)
Expand All @@ -73,3 +74,19 @@ def test_search(self):
_test_result(result)

assert results[1].dateobs is None

@pytest.mark.usefixtures('sia')
@pytest.mark.usefixtures('register_mocks')
@pytest.mark.filterwarnings("ignore::astropy.io.votable.exceptions.W06")
@pytest.mark.filterwarnings("ignore::astropy.io.votable.exceptions.W42")
@pytest.mark.filterwarnings("ignore::astropy.io.votable.exceptions.W49")
def test_formatter(self):
service = SIAQuery('http://example.com/sia')
service.format = "image"
assert service["FORMAT"] == "image"
service.format = "all"
assert service["FORMAT"] == "ALL"
service.format = "Graphic-png"
assert service["FORMAT"] == "GRAPHIC-png"
service.format = "Unsupported"
assert service["FORMAT"] == "Unsupported"
Loading