Skip to content

Commit

Permalink
rename "y" component to "trace"
Browse files Browse the repository at this point in the history
  • Loading branch information
kecnry committed Aug 10, 2022
1 parent 8b5eca0 commit 4652017
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions glue_astronomy/translators/tests/test_trace.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ def test_trace():
data_collection['trace'] = trace
data = data_collection['trace']
assert isinstance(data, Data)
assert np.all(data['y'] == trace.trace)
assert np.all(data['trace'] == trace.trace)

trace_from_data = data.get_object()
assert isinstance(trace_from_data, tracing.FlatTrace)

# now edit the glue data object, this should now map to an ArrayTrace (instead of a FlatTrace)
new_trace = np.ones_like(trace.trace)
data.update_components({data.get_component('y'): new_trace})
data.update_components({data.get_component('trace'): new_trace})
trace_from_data = data.get_object()
assert isinstance(trace_from_data, tracing.ArrayTrace)
assert np.all(trace_from_data.trace == new_trace)
Expand Down
6 changes: 3 additions & 3 deletions glue_astronomy/translators/trace.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def to_data(self, obj):
obj : `specreduce.tracing.Trace`
The Trace object to convert
"""
data = Data(x=obj.image[0], y=obj.trace)
data = Data(x=obj.image[0], trace=obj.trace)
if hasattr(obj, 'meta'):
data.meta.update(obj.meta)
data.meta['Trace'] = obj
Expand Down Expand Up @@ -47,7 +47,7 @@ def to_object(self, data, attribute=None):
# these arrays are still the appropriate length
if not np.all(trace_x == data['x']):
raise ValueError("x-values have changed")
if not np.all(trace.trace[1] == data['y']):
trace = ArrayTrace(trace.image, data['y'])
if not np.all(trace.trace[1] == data['trace']):
trace = ArrayTrace(trace.image, data['trace'])

return trace

0 comments on commit 4652017

Please sign in to comment.