Skip to content

Commit 91606f9

Browse files
Possible fixes for issue astropy#11360. More investigation is necessary.
1 parent 5bcdac3 commit 91606f9

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

‎astropy/modeling/core.py‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3917,16 +3917,18 @@ def _prepare_outputs_single_model(outputs, format_info):
39173917
outputs = list(outputs)
39183918
for idx, output in enumerate(outputs):
39193919
try:
3920-
broadcast_shape = check_broadcast(*format_info[idx])
3921-
except (IndexError, TypeError):
3920+
broadcast_shape = check_broadcast(*format_info[0])
3921+
except (IndexError, TypeError) as e:
39223922
broadcast_shape = format_info[0][idx]
39233923

39243924
if broadcast_shape is not None:
39253925
if not broadcast_shape:
3926-
# Shape is (), i.e. a scalar should be returned
39273926
outputs[idx] = output.item()
39283927
else:
3929-
outputs[idx] = output.reshape(broadcast_shape)
3928+
try:
3929+
outputs[idx] = output.reshape(broadcast_shape)
3930+
except ValueError:
3931+
outputs[idx] = output.item()
39303932

39313933
return tuple(outputs)
39323934

0 commit comments

Comments
 (0)