Skip to content

Modeling issues with input shape validation #9953

Description

@nden

Description

These are all related issues:

  • Model.standard_broadcasting is not documented.
  • _validate_input_shapes does not use argument validate_broadcasting which I believe is the Model.standard_broadcasting flag and should turn off validation if True.
  • _validate_input_shapes claims it checks if inputs are broadcastable. In reality it checks that the shapes of the inputs are the same. This prevents some valid use cases from running, e.g. multiply when input shapes are (10, 1) and (24,)

Expected behavior

  • When Model.standard_broadcasting=False inputs with non-broadcastable shapes should be accepted (and handled by the model.

  • This example should work

from astropy.modeling.models import math as astmath
t=np.array([np.linspace(0,1,10)]).T 
astmath.MultiplyUfunc()(t, np.arange(4))

Actual behavior

astmath.MultiplyUfunc()(t, np.arange(4))
...
~/dev/astropy/astropy/modeling/core.py in _validate_input_shapes(inputs, argnames, n_models, model_set_axis, validate_broadcasting)
   3708     if input_shape is None:
   3709         raise ValueError(
-> 3710             "All inputs must have identical shapes or must be scalars.")
   3711 

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions