Skip to content

Modeling issues with input shape validation #9953

Closed

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 

Activity

  1. added this to the v4.0.1 milestone on Feb 24, 2020
  2. modified the milestones: v4.0.1, v4.1 on Mar 11, 2020
  3. removed this from the v4.1 milestone on May 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions