Skip to content

Commit

Permalink
Merge pull request #478 from bsipocz/ENH_nonTable_reprs
Browse files Browse the repository at this point in the history
ENH: customising reps for nonTable classes
  • Loading branch information
bsipocz authored Sep 11, 2023
2 parents 012e583 + 6094999 commit 75bcb73
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 10 deletions.
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@

- Adding python version to User-Agent. [#452]

- Output of ``repr`` for DALResults instance now clearly shows it is a
DALResultsTable and not a generic astropy Table. [#478]


1.4.3 (unreleased)
==================
Expand Down
2 changes: 1 addition & 1 deletion docs/dal/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ mean G-band magnitude between 19 - 20:
... """
>>> result = tap_service.search(ex_query)
>>> print(result)
<Table length=5>
<DALResultsTable length=5>
source_id ra dec phot_g_mean_mag
deg deg mag
int64 float64 float64 float32
Expand Down
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ specific to the service type. In this example, a database query is enough:

>>> resultset = service.search("SELECT TOP 1 * FROM ivoa.obscore")
>>> resultset
<Table length=1>
<DALResultsTable length=1>
dataproduct_type dataproduct_subtype ... source_table
...
object object ... object
Expand Down
12 changes: 6 additions & 6 deletions docs/registry/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,10 @@ thus say:

.. doctest-remote-data::

>>> resources["II/283"].get_service("conesearch").search(pos=(120, 73), sr=1) # doctest: +IGNORE_OUTPUT
<Table length=1>
>>> resources["II/283"].get_service("conesearch").search(pos=(120, 73), sr=1)
<DALResultsTable length=1>
_RAJ2000 _DEJ2000 _r recno ... NED RAJ2000 DEJ2000
deg deg deg ... "h:m:s" "d:m:s"
deg deg ...
float64 float64 float64 int32 ... str3 str12 str12
------------ ------------ -------- ----- ... ---- ------------ ------------
117.98645833 73.00961111 0.588592 986 ... NED 07 51 56.750 +73 00 34.60
Expand All @@ -199,7 +199,7 @@ To run a TAP query based on this metadata, do something like:

>>> resources["II/283"].get_service("tap#aux").run_sync(
... 'SELECT sn, z FROM "J/A+A/437/789/table2" WHERE z>0.04')
<Table length=4>
<DALResultsTable length=4>
SN z
object float64
------ -------
Expand Down Expand Up @@ -405,7 +405,7 @@ there is no telling what kind of service you will get back.

>>> nvss = colls["NVSS"].service # converts record to service object
>>> nvss.search(pos=(350.85, 58.815),size=0.25,format="image/fits")
<Table length=1>
<DALResultsTable length=1>
Survey Ra ... LogicalName
object float64 ... object
------ ------- ... -----------
Expand Down Expand Up @@ -443,7 +443,7 @@ registry.

>>> nvss = vo.registry.search(ivoid='ivo://nasa.heasarc/skyview/nvss')[0].get_service('sia')
>>> nvss.search(pos=(350.85, 58.815),size=0.25,format="image/fits")
<Table length=1>
<DALResultsTable length=1>
Survey Ra ... LogicalName
object float64 ... object
------ ------- ... -----------
Expand Down
2 changes: 1 addition & 1 deletion pyvo/dal/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ def _findinfos(self, votable):
return infos

def __repr__(self):
return repr(self.to_table())
return f"<DALResults{repr(self.to_table())[1:]}"

@property
def queryurl(self):
Expand Down
2 changes: 1 addition & 1 deletion pyvo/dal/tests/test_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ def test_repr(self):
dalresults = DALResults.from_result_url(
'http://example.com/query/basic')

assert repr(dalresults) == repr(dalresults.to_table())
assert repr(dalresults)[0:26] == "<DALResultsTable length=3>"

def test_iter(self):
dalresults = DALResults.from_result_url(
Expand Down

0 comments on commit 75bcb73

Please sign in to comment.