Skip to content

Commit 3e1f3c1

Browse files
committed
fix tabular in the presence of units
1 parent 21777ea commit 3e1f3c1

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

astropy/modeling/tabular.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -244,11 +244,11 @@ def evaluate(self, *inputs):
244244
bounds_error=self.bounds_error,
245245
fill_value=self.fill_value,
246246
)
247-
247+
248248
# return_units not respected when points has no units
249249
if isinstance(self.lookup_table, u.Quantity) and not isinstance(
250-
self.points[0], u.Quantity
251-
):
250+
result, u.Quantity
251+
):
252252
result = result * self.lookup_table.unit
253253

254254
if self.n_outputs == 1:

astropy/modeling/tests/test_models.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -729,6 +729,12 @@ def test_tabular_interp_1d():
729729
assert_quantity_allclose(model(xnew.to(u.nm)), ans1)
730730
assert model.bounding_box == (0 * u.nm, 4 * u.nm)
731731

732+
# Test with no units on points.
733+
model = LookupTable(points=points, lookup_table=values * u.nJy)
734+
assert_quantity_allclose(model(xnew), ans1)
735+
assert_quantity_allclose(model(xnew.to(u.nm)), ans1)
736+
assert model.bounding_box == (0 * u.nm, 4 * u.nm)
737+
732738
# Test fill value unit conversion and unitless input on table with unit
733739
model = LookupTable(
734740
[1, 2, 3],

0 commit comments

Comments
 (0)