Skip to content

Modeling/handle more out than in#3250

Merged
embray merged 2 commits into
astropy:masterfrom
embray:modeling/handle-more-out-than-in
Dec 23, 2014
Merged

Modeling/handle more out than in#3250
embray merged 2 commits into
astropy:masterfrom
embray:modeling/handle-more-out-than-in

Conversation

@embray

@embray embray commented Dec 22, 2014

Copy link
Copy Markdown
Member

This PR fixes an issue raised by @nden here, and iterates on a suggested fix at embray#12 so as to explicitly support this case. This still makes certain assumptions about the design of the model evaluation function. The main assumption is that all outputs from the model's evaluate function will have the same shape as would result from performing some Numpy ufuncs involving all inputs and parameters to the model. In other words, the shape of all outputs are assumed to be the same, which is the broadcast shape of all inputs with all parameters.

This still suffices for most cases (particularly where all inputs/parameters are just scalars). This was a known issue, but hadn't been brought up before due to there not being any built in models in Astropy that have this format. However, the compound modeling feature [#3231] makes it easier to make such models, and this fix should is good enough for most cases involving compound models as well.

they have inputs, at least in the most basic cases.  This sort of works
the same as how models with more inputs than they have outputs work,
which is that each input is not necessarily directly tied to each
output; instead all outputs are just assumed to have the same
dimensions, which are determined from the result of broadcasting all
inputs with all parameters.

In the future there may be more ways for individual model
implementations to control this (besides outright overriding
prepare_inputs and/or prepare_outputs).

This provides an alternate to this PR:
#12
@embray

embray commented Dec 22, 2014

Copy link
Copy Markdown
Member Author

I'll add, it would be good if a test were added that tests this against compound models. If this PR is merged before #3231 then that PR can be rebased on this one. If the other way around then I can update this PR to include such a test.

@nden nden mentioned this pull request Dec 23, 2014
7 tasks
@embray

embray commented Dec 23, 2014

Copy link
Copy Markdown
Member Author

Passed--going ahead and merging so I can incorporate this into #3231.

embray added a commit that referenced this pull request Dec 23, 2014
@embray embray merged commit 2714b99 into astropy:master Dec 23, 2014
@embray embray deleted the modeling/handle-more-out-than-in branch December 23, 2014 16:23
embray added a commit that referenced this pull request Dec 31, 2014
Modeling/handle more out than in
Conflicts:
	astropy/modeling/core.py
	astropy/modeling/tests/test_input.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant