Skip to content

backward compatible EnsureType #4637

@wyli

Description

@wyli

Is your feature request related to a problem? Please describe.
the current EnsureType removes any metadata

output_type = torch.Tensor if self.data_type == "tensor" else np.ndarray

given it's extensively used in the existing tutorials, would be great to enable metatensor output support and remove the inverse to preserve metadata when inverting the transform.

# FIXME: currently, only convert tensor data to numpy array or scalar number,
# need to also invert numpy array but it's not easy to determine the previous data type
d[key] = convert_to_numpy(d[key])
# Remove the applied transform
self.pop_transform(d, key)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions