How is the signal module in scipy package getting called without calling it?

Viewed 33

I was trying to call signal inside scipy package without importing it

conv_reference_m2 = scipy.signal.convolve2d(image_data_reference[1500:2500,1500:2500], Kernel, mode = 'same')

so expectedly it throws up following error message:

AttributeError: module 'scipy' has no attribute 'signal'

But when I import an another package called astroalign and not scipy.signal explicitly and re run the previous code line, it runs without any error. Like this:

import astroalign
conv_reference_m2 = scipy.signal.convolve2d(image_data_reference[1500:2500,1500:2500], Kernel, mode = 'same')

Above line throws no errors and gives expected results. So it's not really a problem but I wonder how am I able to access signal module without calling it.

1 Answers

When using jupyter notebook, you may have already imported scipy.signal previously and is stored in the kernel. So when you re run the previous code line, scipy.signal is already imported. You can try running your code again after clearing the output, and see if there's any difference. Kernel -> Restart and clear output

Related