Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def remove_defaults(self):
"""
Remove any values in the tree that are the same as the default
values in the schema
"""
tree = yamlutil.custom_tree_to_tagged_tree(self._tree, self)
schema.remove_defaults(tree, self)
self._tree = yamlutil.tagged_tree_to_custom_tree(tree, self)
block = ctx.blocks.find_or_create_block_for_array(data, ctx)
result = {}
result['shape'] = list(shape)
if block.array_storage == 'streamed':
result['shape'][0] = '*'
dtype, byteorder = numpy_dtype_to_asdf_datatype(
dtype, include_byteorder=(block.array_storage != 'inline'))
byteorder = block.override_byteorder(byteorder)
if block.array_storage == 'inline':
listdata = numpy_array_to_list(data)
result['data'] = yamlutil.custom_tree_to_tagged_tree(
listdata, ctx)
result['datatype'] = dtype
else:
result['shape'] = list(shape)
if block.array_storage == 'streamed':
result['shape'][0] = '*'
result['source'] = ctx.blocks.get_source(block)
result['datatype'] = dtype
result['byteorder'] = byteorder
if offset > 0:
result['offset'] = offset
if strides is not None:
result['strides'] = list(strides)
def to_tree(cls, obj, ctx):
"""
Converts Spectrum1D object into tree used for YAML representation
"""
node = {}
node['flux'] = custom_tree_to_tagged_tree(obj.flux, ctx)
node['spectral_axis'] = custom_tree_to_tagged_tree(obj.spectral_axis,
ctx)
if obj.uncertainty is not None:
node['uncertainty'] = {}
node['uncertainty'][
'uncertainty_type'] = obj.uncertainty.uncertainty_type
data = custom_tree_to_tagged_tree(obj.uncertainty.array, ctx)
node['uncertainty']['data'] = data
return node
def to_tree_transform(cls, model, ctx):
node = {}
node["fill_value"] = model.fill_value
node["lookup_table"] = model.lookup_table
node["points"] = [p for p in model.points]
node["method"] = str(model.method)
node["bounds_error"] = model.bounds_error
node["name"] = model.name
return yamlutil.custom_tree_to_tagged_tree(node, ctx)
return frame_name
return frame
frames = gwcs.available_frames
steps = []
for i in range(len(frames) - 1):
frame_name = frames[i]
frame = get_frame(frame_name)
transform = gwcs.get_transform(frames[i], frames[i + 1])
steps.append(StepType({'frame': frame, 'transform': transform}))
frame_name = frames[-1]
frame = get_frame(frame_name)
steps.append(StepType({'frame': frame}))
return {'name': gwcs.name,
'steps': yamlutil.custom_tree_to_tagged_tree(steps, ctx)}
def to_tree(cls, obj, ctx):
"""
Converts Spectrum1D object into tree used for YAML representation
"""
node = {}
node['flux'] = custom_tree_to_tagged_tree(obj.flux, ctx)
node['spectral_axis'] = custom_tree_to_tagged_tree(obj.spectral_axis,
ctx)
if obj.uncertainty is not None:
node['uncertainty'] = {}
node['uncertainty'][
'uncertainty_type'] = obj.uncertainty.uncertainty_type
data = custom_tree_to_tagged_tree(obj.uncertainty.array, ctx)
node['uncertainty']['data'] = data
return node