Skip to content

Commit

Permalink
Add unit test, don't re-raise as ValueError
Browse files Browse the repository at this point in the history
  • Loading branch information
lpsinger committed Aug 21, 2023
1 parent 5cd3a59 commit 48dad7a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
9 changes: 1 addition & 8 deletions astropy/modeling/core.py
Expand Up @@ -1061,14 +1061,7 @@ def _validate_input_shapes(self, inputs, argnames, model_set_axis):
)
)

try:
input_shape = check_broadcast(*all_shapes)
except IncompatibleShapeError as err:
raise ValueError(
"All inputs must have identical shapes or must be scalars."
) from err

return input_shape
return check_broadcast(*all_shapes)

def input_shape(self, inputs):
"""Get input shape for bounding_box evaluation."""
Expand Down
8 changes: 7 additions & 1 deletion astropy/modeling/tests/test_models.py
Expand Up @@ -29,7 +29,7 @@
)
from astropy.modeling.separable import separability_matrix
from astropy.tests.helper import assert_quantity_allclose
from astropy.utils import NumpyRNGContext, minversion
from astropy.utils import IncompatibleShapeError, NumpyRNGContext, minversion
from astropy.utils.compat.optional_deps import HAS_SCIPY

from .example_models import models_1D, models_2D
Expand Down Expand Up @@ -120,6 +120,12 @@ def test_inconsistent_input_shapes():
y.shape = (1, 10)
result = g(x, y)
assert result.shape == (10, 10)
# incompatible shapes do _not_ work
g = Gaussian2D()
x = np.arange(-1.0, 1, 0.2)
y = np.arange(-1.0, 1, 0.1)
with pytest.raises(IncompatibleShapeError):
g(x, y)


def test_custom_model_bounding_box():
Expand Down

0 comments on commit 48dad7a

Please sign in to comment.