Skip to content

Convolution kernel multiplication behaviour with numpy float scalars #2174

@cdeil

Description

@cdeil

Multiplying kernels with Python floats results in scaled kernel objects.
But multiplication of kernels with a scalar numpy floats results in an ndarray objects.

>>> import numpy as np
>>> from astropy.convolution import Gaussian2DKernel
>>> psf = np.float64(42) * Gaussian2DKernel(3)
>>> print(type(psf))
<type 'numpy.ndarray'>
>>> psf = 42 * Gaussian2DKernel(3)
>>> print(type(psf))
<class 'astropy.convolution.kernels.Gaussian2DKernel'>

I think this behaviour is confusing (took me 15 minutes to pin down and understand in my script) and should be changed so that numpy scalar float times kernel is again a kernel.

cc @astrofrog @adonath Do you agree? Can you fix this?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions