Skip to content

Commit

Permalink
improve gmu.return_requested_units() to allow any input units
Browse files Browse the repository at this point in the history
  • Loading branch information
chris-simpson committed Jan 10, 2025
1 parent d673b50 commit 74cce21
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 10 deletions.
11 changes: 8 additions & 3 deletions gemini_instruments/f2/tests/test_f2.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
import gemini_instruments
from gemini_instruments.f2 import AstroDataF2

import numpy as np


FLOAT_TYPES = (float, np.float32, np.float64)

test_files = [
"S20131121S0094.fits",
"S20131126S1111.fits",
Expand All @@ -16,9 +21,9 @@
]

F2_DESCRIPTORS_TYPES = [
('detector_x_offset', float),
('detector_y_offset', float),
('pixel_scale', float),
('detector_x_offset', FLOAT_TYPES),
('detector_y_offset', FLOAT_TYPES),
('pixel_scale', FLOAT_TYPES),
]


Expand Down
9 changes: 7 additions & 2 deletions gemini_instruments/gmos/tests/test_gmos.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,14 @@
import astrodata.testing
import gemini_instruments

import numpy as np


FLOAT_TYPES = (float, np.float32, np.float64)

GMOS_DESCRIPTORS_TYPES = [
('detector_x_offset', float),
('detector_y_offset', float),
('detector_x_offset', FLOAT_TYPES),
('detector_y_offset', FLOAT_TYPES),
('nod_count', tuple),
('nod_offsets', tuple),
('pixel_scale', float),
Expand Down
1 change: 0 additions & 1 deletion gemini_instruments/gmu.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ def gn(instance, asMicrometers=False, asNanometers=False, asAngstroms=False,
# Ensure we return a list, not an array
# nm are the "standard" DRAGONS wavelength unit
retval = fn(instance, **kwargs)
print("RETVAL", retval)
if retval is None:
return retval
if isinstance(retval, list):
Expand Down
11 changes: 8 additions & 3 deletions gemini_instruments/gnirs/tests/test_gnirs.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
import gemini_instruments
from gemini_instruments.gnirs import AstroDataGnirs

import numpy as np


FLOAT_TYPES = (float, np.float32, np.float64)

test_files = [
"N20190206S0279.fits",
"N20190214S0058.fits",
Expand All @@ -15,9 +20,9 @@


GNIRS_DESCRIPTORS_TYPES = [
('detector_x_offset', float),
('detector_y_offset', float),
('pixel_scale', float),
('detector_x_offset', FLOAT_TYPES),
('detector_y_offset', FLOAT_TYPES),
('pixel_scale', FLOAT_TYPES),
]


Expand Down
8 changes: 7 additions & 1 deletion gemini_instruments/test/test_astrodata_descriptors.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,11 @@ def test_descriptor(instr, filename, descriptor, value):
mvalue = method()
if type(value) in FLOAT_TYPES or type(mvalue) in FLOAT_TYPES:
assert abs(mvalue - value) < 0.0001
else:
elif isinstance(value, list):
assert len(value) == len(mvalue)
for v, mv in zip(value, mvalue):
if type(v) in FLOAT_TYPES or type(mv) in FLOAT_TYPES:
assert abs(mv - v) < 0.0001
else:
assert v == mv
assert value == mvalue

0 comments on commit 74cce21

Please sign in to comment.