Skip to content

Commit 1b9cc63

Browse files
committed
added tests, fixed code style.
1 parent 08cba00 commit 1b9cc63

File tree

2 files changed

+40
-7
lines changed

2 files changed

+40
-7
lines changed

astroquery/astrometry_net/core.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -214,16 +214,16 @@ def monitor_submission(self, submission_id, *,
214214
verbose : bool, optional
215215
Whether to print out information about the solving.
216216
return_job_id : bool, optional
217-
Whether to return the Submission ID number (called Job ID on Astrometry.net).
217+
Whether to return the Submission ID number (called Job ID on Astrometry.net).
218218
219219
Returns
220220
-------
221221
222222
None or `astropy.io.fits.Header` or (`astropy.io.fits.Header`, str)
223223
The contents of the returned object depend on whether the solve
224224
succeeds or fails. If the solve succeeds the header with
225-
the WCS solution generated by astrometry.net is returned. A tuple
226-
containing WCS solution and Submission ID is return if the
225+
the WCS solution generated by astrometry.net is returned. A tuple
226+
containing WCS solution and Submission ID is return if the
227227
return_job_id parameter is set True. If the solve
228228
fails then an empty dictionary is returned. See below for the outcome
229229
if the solve times out.
@@ -272,7 +272,7 @@ def monitor_submission(self, submission_id, *,
272272
else:
273273
# Try to future-proof a little bit
274274
raise RuntimeError('Unrecognized status {}'.format(status))
275-
if return_job_id == False:
275+
if return_job_id is False:
276276
return wcs
277277
else:
278278
return (wcs, submission_id)
@@ -303,7 +303,7 @@ def solve_from_source_list(self, x, y, image_width, image_height, *,
303303
verbose : bool, optional
304304
Whether to print out information about the solving.
305305
return_job_id : bool, optional
306-
Whether to return the Submission ID number (called Job ID on Astrometry.net).
306+
Whether to return the Submission ID number (called Job ID on Astrometry.net).
307307
308308
For a list of the remaining settings, use the method
309309
`~AstrometryNetClass.show_allowed_settings`.
@@ -380,9 +380,9 @@ def solve_from_image(self, image_file_path, *, force_image_upload=False,
380380
381381
verbose : bool, optional
382382
Whether to print out information about the solving.
383-
383+
384384
return_job_id : bool, optional
385-
Whether to return the Submission ID number (called Job ID on Astrometry.net).
385+
Whether to return the Submission ID number (called Job ID on Astrometry.net).
386386
387387
For a list of the remaining settings, use the method
388388
`~AstrometryNetClass.show_allowed_settings`.

astroquery/astrometry_net/tests/test_astrometry_net_remote.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,3 +152,36 @@ def test_solve_timeout_behavior():
152152
except TypeError:
153153
pass
154154
assert difference == 0
155+
156+
157+
@pytest.mark.skipif(not api_key, reason='API key not set.')
158+
@pytest.mark.remote_data
159+
def test_solve_from_image_default_behaviour():
160+
# Test that solving by uploading an image works
161+
a = AstrometryNet()
162+
a.api_key = api_key
163+
sources = Table.read(os.path.join(DATA_DIR, 'test-source-list.fit'))
164+
# The image_width, image_height and crpix_center below are set to match the
165+
# original solve on astrometry.net.
166+
result = a.solve_from_source_list(sources['X'], sources['Y'],
167+
4109, 4096,
168+
crpix_center=True)
169+
170+
assert isinstance(result, fits.Header)
171+
172+
173+
@pytest.mark.skipif(not api_key, reason='API key not set.')
174+
@pytest.mark.remote_data
175+
def test_solve_from_image_with_return_job_id():
176+
# Test that solving by uploading an image works
177+
a = AstrometryNet()
178+
a.api_key = api_key
179+
sources = Table.read(os.path.join(DATA_DIR, 'test-source-list.fit'))
180+
# The image_width, image_height and crpix_center below are set to match the
181+
# original solve on astrometry.net.
182+
result = a.solve_from_source_list(sources['X'], sources['Y'],
183+
4109, 4096,
184+
crpix_center=True,
185+
return_job_id=True)
186+
187+
assert isinstance(result, tuple)

0 commit comments

Comments
 (0)