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 fe71e4a commit 8ca2673
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
4 changes: 3 additions & 1 deletion gemini_instruments/gmu.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,9 @@ def return_requested_units(input_units='nm'):
"""
Decorator that replaces the repeated code for asMicrometers,
asNanometers, asAngstroms. Should be replaced by a "units='nm'"
parameter, but time is limited. Keeping current coding to avoid
parameter, but time is limited.
Returns as np.float32 values to avoid excessive precision
"""
def inner_decorator(fn):
@wraps(fn)
Expand Down
2 changes: 1 addition & 1 deletion gemini_instruments/test/lut_descriptors.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@
('detector_x_bin', 1),
('detector_y_bin', 1),
('disperser', 'MIRROR'),
('dispersion', [-3.8800000000000006e-10]),
('dispersion', [-3.88e-10]),
('dispersion_axis', [2]),
('effective_wavelength', 1.25e-06),
('elevation', 60.1851833333),
Expand Down
9 changes: 8 additions & 1 deletion gemini_instruments/test/test_astrodata_descriptors.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,19 @@
import gemini_instruments
import os

import numpy as np


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

THIS_DIR = os.path.dirname(__file__)

from .lut_descriptors import fixture_data as descriptors_fixture_data
# Keep separate because GHOST has non-raw files
from .ghost_lut_descriptors import fixture_data as ghost_descriptors_fixture_data

F


@pytest.mark.parametrize("instr,filename,descriptor,value",
([*k]+[*vv] for k, v in (list(descriptors_fixture_data.items()) +
Expand Down Expand Up @@ -40,7 +47,7 @@ def test_descriptor(instr, filename, descriptor, value):
assert method() is None
else:
mvalue = method()
if float in (type(value), type(mvalue)):
if type(value) in FLOAT_TYPES or type(mvalue) in FLOAT_TYPES:
assert abs(mvalue - value) < 0.0001
else:
assert value == mvalue

0 comments on commit 8ca2673

Please sign in to comment.