Skip to content

Commit

Permalink
Minor editorial changes, mainly to documentation.
Browse files Browse the repository at this point in the history
Also, adding a __repr__ method to regtap.Interface that returns a
constructor call literal.

This is in response to
astropy#289 (review)
  • Loading branch information
msdemlei committed Jan 26, 2022
1 parent b111e8b commit 69fc231
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
3 changes: 2 additions & 1 deletion docs/registry/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ keyword arguments. The following constraints are available:
freetext words, mached in the title, description or subject of the
resource.
* :py:class:`pyvo.registry.Servicetype` (``servicetype``): constrain to
one of tap, ssa, sia, conesearch. This is the constraint you want
one of tap, ssa, sia, conesearch (or full ivoids for other service
types). This is the constraint you want
to use for service discovery.
* :py:class:`pyvo.registry.UCD` (``ucd``): constrain by one or more UCD
patterns; resources match when they serve columns having a matching
Expand Down
4 changes: 4 additions & 0 deletions pyvo/registry/regtap.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,10 @@ def __init__(self, access_url, standard_id, intf_type, intf_role):
self.role = intf_role or None
self.is_standard = self.role=="std"

def __repr__(self):
return (f"Interface({self.access_url!r}, {self.standard_id!r},"
f" {self.type!r}, {self.role!r})")

def to_service(self):
if self.type=="vr:webbrowser":
return _BrowserService(self.access_url)
Expand Down
8 changes: 6 additions & 2 deletions pyvo/registry/rtcons.py
Original file line number Diff line number Diff line change
Expand Up @@ -494,16 +494,19 @@ class Spatial(Constraint):
>>> registry.Spatial([23, -40, 26, -39, 25, -43])
To find resources claiming to cover a MOC, pass an ASCII MOC::
To find resources claiming to cover a MOC_, pass an ASCII MOC::
>>> registry.Spatial("0/1-3 3/")
.. _MOC: https://www.ivoa.net/documents/MOC/
When you already have an astropy SkyCoord::
>>> from astropy.coordinates import SkyCoord
>>> registry.Spatial(SkyCoord("23d +3d"))
SkyCoords also work as circle centers::
SkyCoords also work as circle centers (plain floats for the radius
are interpreted in degrees)::
>>> registry.Spatial((SkyCoord("23d +3d"), 3))
"""
Expand Down Expand Up @@ -609,6 +612,7 @@ def __init__(self, spec):
a frequency, or an energy, or a pair of such quantities,
in which case the argument is interpreted as an interval.
All resources *overlapping* the interval are returned.
Plain floats are interpreted as messenger energy in Joule.
"""
if isinstance(spec, tuple):
self._fillers = {
Expand Down
10 changes: 10 additions & 0 deletions pyvo/registry/tests/test_regtap.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,16 @@ def test_basic(self):
assert intf.is_standard == False
assert not intf.is_vosi

def test_repr(self):
intf = regtap.Interface("http://example.org", "ivo://gavo/std/a",
"vs:paramhttp", "std")
assert (repr(intf) == "Interface('http://example.org',"
" 'ivo://gavo/std/a', 'vs:paramhttp', 'std')")
intf = regtap.Interface("http://example.org", "ivo://gavo/std/a",
None, None)
assert repr(intf) == ("Interface('http://example.org',"
" 'ivo://gavo/std/a', None, None)")

def test_unknown_standard(self):
intf = regtap.Interface("http://example.org", "ivo://gavo/std/a",
"vs:paramhttp", "std")
Expand Down

0 comments on commit 69fc231

Please sign in to comment.