Skip to content

fix bug with compound model inverse serialization#9522

Merged
nden merged 1 commit into
astropy:masterfrom
nden:inverse-compound
Nov 5, 2019
Merged

fix bug with compound model inverse serialization#9522
nden merged 1 commit into
astropy:masterfrom
nden:inverse-compound

Conversation

@nden
Copy link
Copy Markdown
Contributor

@nden nden commented Nov 2, 2019

Description

This pull request is to address a problem with serialization of compound models when only one of them has a custom inverse. In this case the inverse was not written to file.

m1 = Polynomial1D(1) & Polynomial1D(1)
m2 = Polynomial1D(1) & Polynomial1D(1)
m1.inverse = m2
m = Shift(1) & Shift(2) | m1
fa = AsdfFile()
fa.tree['model'] = m
fa.write_to('model.asdf')
f = asdf.open('model.asdf').tree['model'].inverse
>           raise NotImplementedError("Inverse function not provided")
E           NotImplementedError: Inverse function not provided

@astropy-bot astropy-bot Bot added io.misc zzz 💤 io.misc.asdf archived: Go to asdf-astropy repo modeling labels Nov 2, 2019
@nden nden added this to the v4.0 milestone Nov 2, 2019
@pllim pllim added the Affects-dev PRs and issues that do not impact an existing Astropy release label Nov 2, 2019
@pllim
Copy link
Copy Markdown
Member

pllim commented Nov 2, 2019

PEP 8:

astropy/io/misc/asdf/tags/transform/tests/test_transform.py:31:1: W293 blank line contains whitespace
astropy/io/misc/asdf/tags/transform/tests/test_transform.py:54:1: W293 blank line contains whitespace

@pllim
Copy link
Copy Markdown
Member

pllim commented Nov 4, 2019

cc @jdavies-st

Copy link
Copy Markdown
Contributor

@jdavies-st jdavies-st left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good.

My only nit is that the test should use the tmpdir fixture so that it doesn't leave around a test file in the cwd:

def test_custom_and_analytical(tmpdir)
    ...
    filename = tmpdir.join('custom_and_analytical_inverse.asdf')
    fa.write_to(filename)
    f = asdf.open(filename)
    ...

But I don't think that this is a show-stopper. Getting fixed quickly is higher priority.

@nden nden changed the title fix bug with compound model inverse serialization [WIP] fix bug with compound model inverse serialization Nov 5, 2019
@nden
Copy link
Copy Markdown
Contributor Author

nden commented Nov 5, 2019

I am still looking into related issues - should not be merged yet.

@bsipocz bsipocz added the Bug label Nov 5, 2019
@bsipocz bsipocz changed the title [WIP] fix bug with compound model inverse serialization fix bug with compound model inverse serialization Nov 5, 2019
@hbushouse
Copy link
Copy Markdown

This is a high-priority fix that's needed to support JWST DMS B7.4. Currently there are some WCS objects that contain compound models that are not serializing properly, with inverse transforms being absent in the serialized file. This obviously causes problems downstream when those corrupt data files are used as input to routines that need all the WCS transforms.

@jdavies-st
Copy link
Copy Markdown
Contributor

I did some further testing of the asdf serialization with this branch, and it resolves all the issues we've been seeing. 👍

Copy link
Copy Markdown
Member

@pllim pllim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please squash the commits? Thanks!

@nden nden force-pushed the inverse-compound branch from 3d18bde to 2502f25 Compare November 5, 2019 22:59
@nden
Copy link
Copy Markdown
Contributor Author

nden commented Nov 5, 2019

Squashed commits and cancelled the jobs I can cancel. Merging. Thanks all!

Copy link
Copy Markdown
Member

@perrygreenfield perrygreenfield left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

@nden nden deleted the inverse-compound branch January 22, 2026 10:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Affects-dev PRs and issues that do not impact an existing Astropy release Bug io.misc modeling zzz 💤 io.misc.asdf archived: Go to asdf-astropy repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants