You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Model evaluation crashes if some inputs are scalars #10170
I originally posted this because I thought it was specific to fix_inputs, but it's more fundamental than that, this is a revised description.
Description
A model can be called with some inputs as scalars and some as arrays/lists, with the scalars being broadcasted to the same shape as the other inputs. After evaluation, the output is rebroadcast by prepare_outputs() but this checks the shapes of the outputs against the shapes of the inputs, and crashes if any of the first n_outputs inputs were scalars.
Expected behavior
I should get identical results from, but the first works and the second crashes.
ValueError: can only convert an array of size 1 to a Python scalar
Steps to Reproduce
>>> from astropy.modeling.models import Gaussian2D
>>> g = Gaussian2D(1, 2, 3, 4, 5)
>>> g([2.5,2.5], 1)
array([0.9159326, 0.9159326])
>>> g(2.5, [1,1]) # should be the same
Traceback (most recent call last):
...
ValueError: can only convert an array of size 1 to a Python scalar
changed the title [-]fix_inputs fails to expand value into array if other inputs are arrays[/-][+]Model evaluation crashes if some inputs are scalars[/+]on Apr 20, 2020
Hi humans 👋 - this issue was labeled as Close? approximately 7 days ago. If you think this issue should not be closed, a maintainer should remove the Close? label - otherwise, I will close this issue in a month.
If you believe I commented on this issue incorrectly, please report this here
Activity
[-]fix_inputs fails to expand value into array if other inputs are arrays[/-][+]Model evaluation crashes if some inputs are scalars[/+]nden commentedon Apr 20, 2020
Thanks for the report. I think this is related to #9953 and the first example works only by accident.
astropy-bot commentedon Apr 28, 2020
Hi humans 👋 - this issue was labeled as Close? approximately 7 days ago. If you think this issue should not be closed, a maintainer should remove the Close? label - otherwise, I will close this issue in a month.
If you believe I commented on this issue incorrectly, please report this here
Potential fix for issue astropy#10170
Added tests to show that issue astropy#10170 is fixed.
Potential fix for issue astropy#10170