66
77from asdf import yamlutil
88
9- from astropy import modeling
9+ from ...... import modeling
10+ from ...... import units as u
1011from .basic import TransformType
11-
12+ from ...... tests . helper import assert_quantity_allclose
1213
1314__all__ = ['TabularType' ]
1415
@@ -24,26 +25,25 @@ class TabularType(TransformType):
2425 def from_tree_transform (cls , node , ctx ):
2526 lookup_table = node .pop ("lookup_table" )
2627 dim = lookup_table .ndim
27- name = node .get ('name' , None )
2828 fill_value = node .pop ("fill_value" , None )
2929 if dim == 1 :
3030 # The copy is necessary because the array is memory mapped.
3131 points = (node ['points' ][0 ][:],)
3232 model = modeling .models .Tabular1D (points = points , lookup_table = lookup_table ,
3333 method = node ['method' ], bounds_error = node ['bounds_error' ],
34- fill_value = fill_value , name = name )
34+ fill_value = fill_value )
3535 elif dim == 2 :
3636 points = tuple ([p [:] for p in node ['points' ]])
3737 model = modeling .models .Tabular2D (points = points , lookup_table = lookup_table ,
3838 method = node ['method' ], bounds_error = node ['bounds_error' ],
39- fill_value = fill_value , name = name )
39+ fill_value = fill_value )
4040
4141 else :
4242 tabular_class = modeling .models .tabular_model (dim , name )
4343 points = tuple ([p [:] for p in node ['points' ]])
4444 model = tabular_class (points = points , lookup_table = lookup_table ,
4545 method = node ['method' ], bounds_error = node ['bounds_error' ],
46- fill_value = fill_value , name = name )
46+ fill_value = fill_value )
4747
4848 return model
4949
@@ -60,8 +60,15 @@ def to_tree_transform(cls, model, ctx):
6060
6161 @classmethod
6262 def assert_equal (cls , a , b ):
63- assert_array_equal (a .lookup_table , b .lookup_table )
64- assert_array_equal (a .points , b .points )
63+ if isinstance (a .lookup_table , u .Quantity ):
64+ assert_quantity_allclose (a .lookup_table , b .lookup_table )
65+ assert_quantity_allclose (a .points , b .points )
66+ for i in range (len (a .bounding_box )):
67+ assert_quantity_allclose (a .bounding_box [i ], b .bounding_box [i ])
68+ else :
69+ assert_array_equal (a .lookup_table , b .lookup_table )
70+ assert_array_equal (a .points , b .points )
71+ assert_array_equal (a .bounding_box , b .bounding_box )
6572 assert (a .method == b .method )
6673 if a .fill_value is None :
6774 assert b .fill_value is None
0 commit comments