Skip to content

Commit

Permalink
remove x-component
Browse files Browse the repository at this point in the history
* can rely on the automatic pixel component and recover everything from the original trace object
  • Loading branch information
kecnry committed Aug 11, 2022
1 parent 4652017 commit 6680612
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 14 deletions.
10 changes: 2 additions & 8 deletions glue_astronomy/translators/tests/test_trace.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import numpy as np
import pytest

from specreduce import tracing
from specreduce.utils.synth_data import make_2dspec_image
Expand All @@ -14,8 +13,8 @@ def test_trace():

data_collection = DataCollection()

data_collection['trace'] = trace
data = data_collection['trace']
data_collection['dc_trace'] = trace
data = data_collection['dc_trace']
assert isinstance(data, Data)
assert np.all(data['trace'] == trace.trace)

Expand All @@ -28,8 +27,3 @@ def test_trace():
trace_from_data = data.get_object()
assert isinstance(trace_from_data, tracing.ArrayTrace)
assert np.all(trace_from_data.trace == new_trace)

# error raised if the x changes
data.update_components({data.get_component('x'): np.ones_like(trace.trace)})
with pytest.raises(ValueError):
trace_from_data = data.get_object()
7 changes: 1 addition & 6 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], trace=obj.trace)
data = Data(trace=obj.trace)
if hasattr(obj, 'meta'):
data.meta.update(obj.meta)
data.meta['Trace'] = obj
Expand All @@ -42,11 +42,6 @@ def to_object(self, data, attribute=None):
raise TypeError("data is not of a valid specreduce Trace object")

trace = data.meta['Trace']
trace_x = np.asarray(trace.image[0])
# NOTE: glue does not allow changing the shape of data components, so we can assume
# 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['trace']):
trace = ArrayTrace(trace.image, data['trace'])

Expand Down

0 comments on commit 6680612

Please sign in to comment.