<s> from __future__ import print_function , division <EOL> import os <EOL> import shutil <EOL> import tempfile <EOL> from astropy . tests . helper import pytest <EOL> import numpy as np <EOL> from numpy . testing import assert_array_almost_equal_nulp <EOL> from astropy import units as u <EOL> from . . import Model <EOL> from . . image import Image <EOL> from ... util . functions import random_id <EOL> from . test_helpers import get_test_dust , get_highly_reflective_dust <EOL> class TestFilters ( object ) : <EOL> def setup_class ( self ) : <EOL> m = Model ( ) <EOL> m . set_cartesian_grid ( [ - <NUM_LIT:1.> , <NUM_LIT:1.> ] , <EOL> [ - <NUM_LIT:1.> , <NUM_LIT:1.> ] , <EOL> [ - <NUM_LIT:1.> , <NUM_LIT:1.> ] ) <EOL> m . add_density_grid ( np . array ( [ [ [ <NUM_LIT:1.> ] ] ] ) , get_test_dust ( ) ) <EOL> s = m . add_point_source ( ) <EOL> s . name = '<STR_LIT>' <EOL> s . luminosity = <NUM_LIT:1.> <EOL> s . temperature = <NUM_LIT> <EOL> s = m . add_point_source ( ) <EOL> s . name = '<STR_LIT>' <EOL> s . luminosity = <NUM_LIT:1.> <EOL> s . temperature = <NUM_LIT> <EOL> i = m . add_peeled_images ( sed = True , image = True ) <EOL> i . set_viewing_angles ( [ <NUM_LIT:1.> , <NUM_LIT> , <NUM_LIT> ] , [ <NUM_LIT:1.> , <NUM_LIT> , <NUM_LIT> ] ) <EOL> i . set_image_limits ( - <NUM_LIT:1.> , <NUM_LIT:1.> , - <NUM_LIT:1.> , <NUM_LIT:1.> ) <EOL> i . set_image_size ( <NUM_LIT:10> , <NUM_LIT:20> ) <EOL> f1 = i . add_filter ( ) <EOL> f1 . name = '<STR_LIT>' <EOL> f1 . spectral_coord = [ <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] * u . micron <EOL> f1 . transmission = [ <NUM_LIT:0.> , <NUM_LIT> , <NUM_LIT:50> , <NUM_LIT:0.> ] * u . percent <EOL> f1 . detector_type = '<STR_LIT>' <EOL> f1 . alpha = <NUM_LIT:0.> <EOL> f1 . central_spectral_coord = <NUM_LIT> * u . micron <EOL> f2 = i . add_filter ( ) <EOL> f2 . name = '<STR_LIT>' <EOL> f2 . spectral_coord = [ <NUM_LIT:2> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] * u . micron <EOL> f2 . transmission = [ <NUM_LIT:0.> , <NUM_LIT:50> , <NUM_LIT:100> , <NUM_LIT> , <NUM_LIT:0.> ] * u . percent <EOL> f2 . detector_type = '<STR_LIT>' <EOL> f2 . alpha = <NUM_LIT:1.> <EOL> f2 . central_spectral_coord = <NUM_LIT> * u . micron <EOL> m . set_n_initial_iterations ( <NUM_LIT:0> ) <EOL> m . set_n_photons ( imaging = <NUM_LIT:1000> ) <EOL> self . tmpdir = tempfile . mkdtemp ( ) <EOL> m . write ( os . path . join ( self . tmpdir , random_id ( ) ) ) <EOL> self . m = m . run ( ) <EOL> def teardown_class ( self ) : <EOL> shutil . rmtree ( self . tmpdir ) <EOL> def test_image_wav ( self ) : <EOL> image = self . m . get_image ( ) <EOL> np . testing . assert_allclose ( image . nu , [ <NUM_LIT> , <NUM_LIT> ] ) <EOL> np . testing . assert_allclose ( image . wav , [ <NUM_LIT> , <NUM_LIT> ] ) <EOL> def test_sed_wav ( self ) : <EOL> sed = self . m . get_sed ( ) <EOL> np . testing . assert_allclose ( sed . nu , [ <NUM_LIT> , <NUM_LIT> ] ) <EOL> np . testing . assert_allclose ( sed . wav , [ <NUM_LIT> , <NUM_LIT> ] ) <EOL> def test_image_shape ( self ) : <EOL> image = self . m . get_image ( ) <EOL> assert image . val . shape == ( <NUM_LIT:3> , <NUM_LIT:20> , <NUM_LIT:10> , <NUM_LIT:2> ) <EOL> def test_sed_shape ( self ) : <EOL> sed = self . m . get_sed ( ) <EOL> assert sed . val . shape == ( <NUM_LIT:3> , <NUM_LIT:1> , <NUM_LIT:2> ) <EOL> def test_image_values ( self ) : <EOL> image = self . m . get_image ( units = '<STR_LIT>' , distance = <NUM_LIT:1> ) <EOL> np . testing . assert_allclose ( np . sum ( image . val [ : , : , : , <NUM_LIT:0> ] ) , <NUM_LIT> , rtol = <NUM_LIT:0.1> ) <EOL> np . testing . assert_allclose ( np . sum ( image . val [ : , : , : , <NUM_LIT:1> ] ) , <NUM_LIT> , rtol = <NUM_LIT:0.1> ) </s>
