Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove all hints of roman_datamodels units #172

Merged
merged 2 commits into from
May 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

- Bugfix for the ``amp33`` shape in ``mk_ramp``. [#166]

- Remove the deprecated ``roman_datamodels.units`` module. [#172]


0.14.2 (2023-03-31)
===================
Expand Down
4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ dependencies = [
'psutil >=5.7.2',
'numpy >=1.20',
'astropy >=5.0.4',
'rad >=0.14.2',
# 'rad >=0.14.2',
# Use dev version of `rad` until 0.14.2+ is released
'rad @ git+https://github.com/spacetelescope/rad.git@main',
'asdf-standard >=1.0.3',
]
dynamic = ['version']
Expand Down
1 change: 0 additions & 1 deletion src/roman_datamodels/conftest.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
collect_ignore = ["units.py"]
3 changes: 1 addition & 2 deletions src/roman_datamodels/extensions.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
from asdf.extension import ManifestExtension

from .stnode import TaggedListNodeConverter, TaggedObjectNodeConverter, TaggedScalarNodeConverter, UnitConverter
from .stnode import TaggedListNodeConverter, TaggedObjectNodeConverter, TaggedScalarNodeConverter

DATAMODEL_CONVERTERS = [
TaggedObjectNodeConverter(),
TaggedListNodeConverter(),
TaggedScalarNodeConverter(),
UnitConverter(),
]

DATAMODEL_EXTENSIONS = [
Expand Down
20 changes: 0 additions & 20 deletions src/roman_datamodels/stnode.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,6 @@
strict_validation = True


_UNIT_NODE_TAGS = ["asdf://stsci.edu/datamodels/roman/tags/unit-1.0.0"]


def set_validate(value):
global validate
validate = bool(value)
Expand Down Expand Up @@ -491,21 +488,6 @@ def from_yaml_tree(self, node, tag, ctx):
return _SCALAR_NODE_CLASSES_BY_TAG[tag](node)


class UnitConverter(Converter):
tags = _UNIT_NODE_TAGS
types = []

def to_yaml_tree(self, obj, tag, ctx):
msg = "Converting to rad unit tags is no longer suppoerted. Support is now native to asdf-astropy."
raise NotImplementedError(msg)

def from_yaml_tree(self, node, tag, ctx):
from asdf_astropy.converters.unit import UnitConverter as AstropyUnitConverter

# rad unit tags are being replaced by the non-vounit tags in asdf-astropy
return AstropyUnitConverter().from_yaml_tree(node, "tag:astropy.org:astropy/units/unit-1.0.0", ctx)


_DATAMODELS_MANIFEST_PATH = importlib_resources.files(rad.resources) / "manifests" / "datamodels-1.0.yaml"
_DATAMODELS_MANIFEST = yaml.safe_load(_DATAMODELS_MANIFEST_PATH.read_bytes())

Expand Down Expand Up @@ -551,8 +533,6 @@ def _class_from_tag(tag, docstring):
_LIST_NODE_CLASSES_BY_TAG[tag["tag_uri"]].__doc__ = docstring
elif tag["tag_uri"] in _SCALAR_NODE_CLASSES_BY_TAG:
_SCALAR_NODE_CLASSES_BY_TAG[tag["tag_uri"]].__doc__ = docstring
elif tag["tag_uri"] in _UNIT_NODE_TAGS:
pass
else:
_class_from_tag(tag, docstring)

Expand Down
13 changes: 0 additions & 13 deletions src/roman_datamodels/units.py

This file was deleted.

13 changes: 6 additions & 7 deletions tests/test_stnode.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,12 @@ def test_generated_node_classes(manifest):
class_name = stnode._class_name_from_tag_uri(tag["tag_uri"])
node_class = getattr(stnode, class_name)

assert issubclass(node_class, (stnode.TaggedObjectNode, stnode.TaggedListNode, stnode.TaggedScalarNode, stnode.Unit))
if not issubclass(node_class, stnode.Unit):
assert node_class._tag == tag["tag_uri"]
assert tag["description"] in node_class.__doc__
assert tag["tag_uri"] in node_class.__doc__
assert node_class.__module__ == stnode.__name__
assert node_class.__name__ in stnode.__all__
assert issubclass(node_class, (stnode.TaggedObjectNode, stnode.TaggedListNode, stnode.TaggedScalarNode))
assert node_class._tag == tag["tag_uri"]
assert tag["description"] in node_class.__doc__
assert tag["tag_uri"] in node_class.__doc__
assert node_class.__module__ == stnode.__name__
assert node_class.__name__ in stnode.__all__


def test_wfi_mode():
Expand Down
53 changes: 0 additions & 53 deletions tests/test_units.py

This file was deleted.