Skip to content

Commit

Permalink
drop use of json_id in walk_and_modify callbacks (#244)
Browse files Browse the repository at this point in the history
  • Loading branch information
braingram authored Jan 9, 2024
1 parent 44a5691 commit ee53eab
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
3 changes: 2 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ Bug Fixes
Changes to API
--------------

-
- Remove ``json_id`` argument use for callbacks passed
to ``asdf.treeutil.walk_and_modify`` [#244]

Other
-----
Expand Down
8 changes: 4 additions & 4 deletions src/stdatamodels/fits_support.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ def _get_validators(hdulist):


def _save_from_schema(hdulist, tree, schema):
def datetime_callback(node, json_id):
def datetime_callback(node):
if isinstance(node, datetime.datetime):
node = time.Time(node)

Expand All @@ -378,7 +378,7 @@ def datetime_callback(node, json_id):

# Now link extensions to items in the tree

def callback(node, json_id):
def callback(node):
if id(node) in context.extension_array_links:
hdu = context.extension_array_links[id(node)]()
return _create_tagged_dict_for_fits_array(hdu, hdulist.index(hdu))
Expand Down Expand Up @@ -432,7 +432,7 @@ def _normalize_arrays(tree):
don't want the asdf library to notice the change in memory
layout and duplicate the array in the embedded ASDF.
"""
def normalize_array(node, json_id):
def normalize_array(node):
if isinstance(node, np.ndarray):
# We can't use np.ascontiguousarray because it converts FITS_rec
# to vanilla np.ndarray, which results in misinterpretation of
Expand Down Expand Up @@ -746,7 +746,7 @@ def from_fits_asdf(hdulist,


def _map_hdulist_to_arrays(hdulist, af):
def callback(node, json_id):
def callback(node):
if (
isinstance(node, NDArrayType) and
isinstance(node._source, str) and
Expand Down
5 changes: 2 additions & 3 deletions src/stdatamodels/jwst/datamodels/schema_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,9 +394,8 @@ def resolve_references(self, url):
"""
Resolve urls in the schema
"""
def resolve_refs(node, json_id):
if json_id is None:
json_id = url
def resolve_refs(node):
json_id = url
if isinstance(node, dict) and '$ref' in node:
suburl = generic_io.resolve_uri(json_id, node['$ref'])
parts = urlparse(suburl)
Expand Down

0 comments on commit ee53eab

Please sign in to comment.