Skip to content

Commit

Permalink
TST: Also run slow test in non-dev env, fix Catalog Search bug (#3101)
Browse files Browse the repository at this point in the history
* TST: Also run slow test in non-dev env

* BUG: Fix table I/O in Catalog Search

* ID as string always

* Force ID to be always str even from file
  • Loading branch information
pllim authored Jul 24, 2024
1 parent 143cd8d commit 6fb47ab
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci_workflows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
os: ubuntu-latest
python: '3.11'
toxenv: py311-test-alldeps-cov
toxposargs: --remote-data
toxposargs: --remote-data --run-slow
allow_failure: false

- name: OS X - Python 3.12
Expand Down
2 changes: 1 addition & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Cubeviz
Imviz
^^^^^

- Added a table with catalog search results. [#2915]
- Added a table with catalog search results. [#2915, #3101]

Mosviz
^^^^^^
Expand Down
7 changes: 6 additions & 1 deletion docs/imviz/plugins.rst
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,12 @@ catalog dropdown menu.
and works best when you only have a single image loaded in a viewer.

To load a catalog from a supported `JWST ECSV catalog file <https://jwst-pipeline.readthedocs.io/en/latest/jwst/source_catalog/main.html#output-products>`_, choose "From File...".
The file must be able to be parsed by `astropy.table.Table.read` and contain a column labeled 'sky_centroid'.
The file must be able to be parsed by `astropy.table.Table.read` and contains the following columns:

* ``'sky_centroid'``: Column with `~astropy.coordinates.SkyCoord` sky coordinates of the sources.
* ``'label'``: Column with string identifiers of the sources. If you have numerical identifiers,
they will be recast as string.

Clicking :guilabel:`SEARCH` will show markers for any entry within the filtered zoom window.

If you have multiple viewers open, you will see another dropdown menu to select the active
Expand Down
14 changes: 8 additions & 6 deletions jdaviz/configs/imviz/plugins/catalogs/catalogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,12 @@ def search(self, error_on_fail=False):
unit='deg')

# adding in coords + Id's into table
# NOTE: If performance becomes a problem, see
# https://docs.astropy.org/en/stable/table/index.html#performance-tips
for row in self.app._catalog_source_table:
row_info = {'Right Ascension (degrees)': row['ra'],
'Declination (degrees)': row['dec'],
'Object ID': row['objid']}
'Object ID': row['objid'].astype(str)}
self.table.add_item(row_info)

elif self.catalog_selected == 'From File...':
Expand All @@ -174,12 +176,12 @@ def search(self, error_on_fail=False):
self.app._catalog_source_table = table
skycoord_table = table['sky_centroid']

# NOTE: If performance becomes a problem, see
# https://docs.astropy.org/en/stable/table/index.html#performance-tips
for row in self.app._catalog_source_table:
# find new to add in a way to append the source id to the table
# 'Object ID': row['label']} ; 'label' is failing tests
row_info = {'Right Ascension (degrees)': row['sky_centroid'].ra,
'Declination (degrees)': row['sky_centroid'].dec,
'Object ID': row.get('label', '')}
row_info = {'Right Ascension (degrees)': row['sky_centroid'].ra.deg,
'Declination (degrees)': row['sky_centroid'].dec.deg,
'Object ID': str(row.get('label', 'N/A'))}
self.table.add_item(row_info)

else:
Expand Down
6 changes: 3 additions & 3 deletions jdaviz/configs/imviz/tests/test_catalogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,15 @@ def test_plugin_image_with_result(self, imviz_helper, tmp_path):

# test loading from file
table = imviz_helper.app._catalog_source_table
skycoord_table = SkyCoord(table['ra'], table['dec'], unit='deg')
qtable = QTable({'sky_centroid': skycoord_table})
qtable = QTable({'sky_centroid': SkyCoord(table['ra'], table['dec'], unit='deg'),
'label': table['objid']})
tmp_file = tmp_path / 'test.ecsv'
qtable.write(tmp_file, overwrite=True)

catalogs_plugin.from_file = str(tmp_file)
# setting filename from API will automatically set catalog to 'From File...'
assert catalogs_plugin.catalog.selected == 'From File...'
catalogs_plugin.vue_do_search()
catalogs_plugin.search(error_on_fail=True)
assert catalogs_plugin.results_available
assert catalogs_plugin.number_of_results == prev_results

Expand Down

0 comments on commit 6fb47ab

Please sign in to comment.