How to use test_kernel method in autotest

Best Python code snippet using autotest_python

test_convolve_nddata.py

Source:test_convolve_nddata.py Github

copy

Full Screen

1# Licensed under a 3-clause BSD style license - see LICENSE.rst2import pytest3import numpy as np4from astropy.convolution.convolve import convolve, convolve_fft5from astropy.convolution.kernels import Gaussian2DKernel6from astropy.nddata import NDData7def test_basic_nddata():8 arr = np.zeros((11, 11))9 arr[5, 5] = 110 ndd = NDData(arr)11 test_kernel = Gaussian2DKernel(1)12 result = convolve(ndd, test_kernel)13 x, y = np.mgrid[:11, :11]14 expected = result[5, 5] * np.exp(-0.5 * ((x - 5)**2 + (y - 5)**2))15 np.testing.assert_allclose(result, expected, atol=1e-6)16 resultf = convolve_fft(ndd, test_kernel)17 np.testing.assert_allclose(resultf, expected, atol=1e-6)18@pytest.mark.parametrize('convfunc',19 [lambda *args: convolve(*args, nan_treatment='interpolate', normalize_kernel=True),20 lambda *args: convolve_fft(*args, nan_treatment='interpolate', normalize_kernel=True)])21def test_masked_nddata(convfunc):22 arr = np.zeros((11, 11))23 arr[4, 5] = arr[6, 5] = arr[5, 4] = arr[5, 6] = 0.224 arr[5, 5] = 1.525 ndd_base = NDData(arr)26 mask = arr < 0 # this is all False27 mask[5, 5] = True28 ndd_mask = NDData(arr, mask=mask)29 arrnan = arr.copy()30 arrnan[5, 5] = np.nan31 ndd_nan = NDData(arrnan)32 test_kernel = Gaussian2DKernel(1)33 result_base = convfunc(ndd_base, test_kernel)34 result_nan = convfunc(ndd_nan, test_kernel)35 result_mask = convfunc(ndd_mask, test_kernel)36 assert np.allclose(result_nan, result_mask)37 assert not np.allclose(result_base, result_mask)38 assert not np.allclose(result_base, result_nan)39 # check to make sure the mask run doesn't talk back to the initial array...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run autotest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful