Skip to content

Instantly share code, notes, and snippets.

@dannygoldstein
Created February 27, 2018 18:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dannygoldstein/e18866ebb9c39a2739f7b9f16440e2f5 to your computer and use it in GitHub Desktop.
Save dannygoldstein/e18866ebb9c39a2739f7b9f16440e2f5 to your computer and use it in GitHub Desktop.
errors from lack of nose
Starting python tests...
============================================================================================================= test session starts =============================================================================================================
platform linux2 -- Python 2.7.14, pytest-3.4.0, py-1.5.2, pluggy-0.6.0
rootdir: /global/scratch/dagoldst/GalSim-1.5.1/tests, inifile:
plugins: xdist-1.22.1, timeout-1.2.1, forked-0.2
timeout: 60.0s method: signal
gw0 I / gw1 I / gw2 I / gw3 I / gw4 I / gw5 I / gw6 I / gw7 I / gw8 I / gw9 I / gw10 I / gw11 I / gw12 I / gw13 I / gw14 I / gw15 I / gw16 I / gw17 I / gw18 I / gw19 I
gw0 [527] / gw1 [527] / gw2 [527] / gw3 [527] / gw4 [527] / gw5 [527] / gw6 [527] / gw7 [527] / gw8 [527] / gw9 [527] / gw10 [527] / gw11 [527] / gw12 [527] / gw13 [527] / gw14 [527] / gw15 [527] / gw16 [527] / gw17 [527] / gw18 [527] / gw19 [527]
scheduling tests via LoadScheduling
......................................................................................................F..............................................F...............F......................................................F.......... [ 43%]
..............................................ss.sssssssss.sssss..................................sss...............................................F........F......................................................................... [ 87%]
...............................F................................. [100%]
================================================================================================================== FAILURES ===================================================================================================================
_______________________________________________________________________________________________________________ test_scattered ________________________________________________________________________________________________________________
[gw5] linux2 -- Python 2.7.14 /global/scratch/dagoldst/miniconda2/bin/python
args = (), kwargs = {}, time = <module 'time' from '/global/scratch/dagoldst/miniconda2/lib/python2.7/lib-dynload/time.so'>, t0 = 1519756685.823128
@functools.wraps(f)
def f2(*args, **kwargs):
import time
t0 = time.time()
> result = f(*args, **kwargs)
galsim_test_helpers.py:555:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
@timer
def test_scattered():
"""Test aspects of building an Scattered image
"""
import copy
# Name some variables to make it easier to be sure they are the same value in the config dict
# as when we build the image manually.
size = 48
stamp_size = 20
scale = 0.45
flux = 17
sigma = 0.7
x1 = 23.1
y1 = 27.3
x2 = 13.4
y2 = 31.9
x3 = 39.8
y3 = 19.7
# This part of the config will be the same for all tests
base_config = {
'gal' : { 'type' : 'Gaussian',
'sigma' : sigma,
'flux' : flux
}
}
# Check that the stamps are centered at the correct location for both odd and even stamp size.
base_config['image'] = {
'type' : 'Scattered',
'size' : size,
'pixel_scale' : scale,
'stamp_size' : stamp_size,
'image_pos' : { 'type' : 'XY', 'x' : x1, 'y' : y1 },
'nobjects' : 1
}
for convention in [ 0, 1 ]:
for test_stamp_size in [ stamp_size, stamp_size + 1 ]:
# Deep copy to make sure we don't have any "current" caches present.
config = copy.deepcopy(base_config)
config['image']['stamp_size'] = test_stamp_size
config['image']['index_convention'] = convention
image = galsim.config.BuildImage(config)
np.testing.assert_equal(image.xmin, convention)
np.testing.assert_equal(image.ymin, convention)
xgrid, ygrid = np.meshgrid(np.arange(size) + image.xmin,
np.arange(size) + image.ymin)
obs_flux = np.sum(image.array, dtype=float)
cenx = np.sum(xgrid * image.array) / flux
ceny = np.sum(ygrid * image.array) / flux
ixx = np.sum((xgrid-cenx)**2 * image.array) / flux
ixy = np.sum((xgrid-cenx)*(ygrid-ceny) * image.array) / flux
iyy = np.sum((ygrid-ceny)**2 * image.array) / flux
np.testing.assert_almost_equal(obs_flux/flux, 1, decimal=3)
np.testing.assert_almost_equal(cenx, x1, decimal=3)
np.testing.assert_almost_equal(ceny, y1, decimal=3)
np.testing.assert_almost_equal(ixx / (sigma/scale)**2, 1, decimal=1)
np.testing.assert_almost_equal(ixy, 0., decimal=3)
np.testing.assert_almost_equal(iyy / (sigma/scale)**2, 1, decimal=1)
# Check that stamp_xsize, stamp_ysize, image_pos use the object count, rather than the
# image count.
config = copy.deepcopy(base_config)
config['image'] = {
'type' : 'Scattered',
'size' : size,
'pixel_scale' : scale,
'stamp_xsize' : { 'type': 'Sequence', 'first' : stamp_size },
'stamp_ysize' : { 'type': 'Sequence', 'first' : stamp_size },
'image_pos' : { 'type' : 'List',
'items' : [ galsim.PositionD(x1,y1),
galsim.PositionD(x2,y2),
galsim.PositionD(x3,y3) ]
},
'nobjects' : 3
}
image = galsim.config.BuildImage(config)
image2 = galsim.ImageF(size,size, scale=scale)
image2.setZero()
gal = galsim.Gaussian(sigma=sigma, flux=flux)
for (i,x,y) in [ (0,x1,y1), (1,x2,y2), (2,x3,y3) ]:
stamp = galsim.ImageF(stamp_size+i,stamp_size+i, scale=scale)
if (stamp_size+i) % 2 == 0:
x += 0.5
y += 0.5
ix = int(np.floor(x+0.5))
iy = int(np.floor(y+0.5))
stamp.setCenter(ix,iy)
dx = x-ix
dy = y-iy
gal.drawImage(stamp, offset=(dx, dy))
b = image2.bounds & stamp.bounds
image2[b] += stamp[b]
np.testing.assert_almost_equal(image.array, image2.array)
try:
# Check error message for missing nobjects
del config['image']['nobjects']
np.testing.assert_raises(AttributeError, galsim.config.BuildImage,config)
# Also if there is an input field that doesn't have nobj capability
config['input'] = { 'dict' : { 'dir' : 'config_input', 'file_name' : 'dict.p' } }
np.testing.assert_raises(AttributeError, galsim.config.BuildImage,config)
except ImportError:
pass
# However, an input field that does have nobj will return something for nobjects.
# This catalog has 3 rows, so equivalent to nobjects = 3
config['input'] = { 'catalog' : { 'dir' : 'config_input', 'file_name' : 'catalog.txt' } }
> del config['input_objs']
E KeyError: 'input_objs'
test_config_image.py:773: KeyError
_______________________________________________________________________________________________________________ test_multifits ________________________________________________________________________________________________________________
[gw17] linux2 -- Python 2.7.14 /global/scratch/dagoldst/miniconda2/bin/python
args = (), kwargs = {}, time = <module 'time' from '/global/scratch/dagoldst/miniconda2/lib/python2.7/lib-dynload/time.so'>, t0 = 1519756687.712698
@functools.wraps(f)
def f2(*args, **kwargs):
import time
t0 = time.time()
> result = f(*args, **kwargs)
galsim_test_helpers.py:555:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
@timer
def test_multifits():
"""Test the output type = MultiFits
"""
config = {
'image' : {
'type' : 'Single',
'random_seed' : 1234,
},
'gal' : {
'type' : 'Gaussian',
'sigma' : { 'type': 'Random', 'min': 1, 'max': 2 },
'flux' : 100,
},
'output' : {
'type' : 'MultiFits',
'nimages' : 6,
'file_name' : 'output/test_multifits.fits'
},
}
im1_list = []
nimages = 6
for k in range(nimages):
ud = galsim.UniformDeviate(1234 + k + 1)
sigma = ud() + 1.
gal = galsim.Gaussian(sigma=sigma, flux=100)
im1 = gal.drawImage(scale=1)
im1_list.append(im1)
print('multifit image shapes = ',[im.array.shape for im in im1_list])
galsim.config.Process(config)
im2_list = galsim.fits.readMulti('output/test_multifits.fits')
for k in range(nimages):
np.testing.assert_array_equal(im2_list[k].array, im1_list[k].array)
# nimages = 1 is allowed
config['output']['nimages'] = 1
galsim.config.Process(config)
im3_list = galsim.fits.readMulti('output/test_multifits.fits')
assert len(im3_list) == 1
np.testing.assert_array_equal(im3_list[0].array, im1_list[0].array)
try:
# Check error message for missing nimages
del config['output']['nimages']
np.testing.assert_raises(AttributeError, galsim.config.BuildFile,config)
# Also if there is an input field that doesn't have nobj capability
config['input'] = { 'dict' : { 'dir' : 'config_input', 'file_name' : 'dict.p' } }
np.testing.assert_raises(AttributeError, galsim.config.BuildFile,config)
except ImportError:
pass
# However, an input field that does have nobj will return something for nobjects.
# This catalog has 3 rows, so equivalent to nobjects = 3
> del config['input_objs']
E KeyError: 'input_objs'
test_config_output.py:201: KeyError
------------------------------------------------------------------------------------------------------------ Captured stdout call -------------------------------------------------------------------------------------------------------------
multifit image shapes = [(20, 20), (22, 22), (20, 20), (20, 20), (22, 22), (16, 16)]
________________________________________________________________________________________________________________ test_datacube ________________________________________________________________________________________________________________
[gw12] linux2 -- Python 2.7.14 /global/scratch/dagoldst/miniconda2/bin/python
args = (), kwargs = {}, time = <module 'time' from '/global/scratch/dagoldst/miniconda2/lib/python2.7/lib-dynload/time.so'>, t0 = 1519756688.206727
@functools.wraps(f)
def f2(*args, **kwargs):
import time
t0 = time.time()
> result = f(*args, **kwargs)
galsim_test_helpers.py:555:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
@timer
def test_datacube():
"""Test the output type = DataCube
"""
config = {
'image' : {
'type' : 'Single',
'random_seed' : 1234,
},
'gal' : {
'type' : 'Gaussian',
'sigma' : { 'type': 'Random', 'min': 1, 'max': 2 },
'flux' : 100,
},
'output' : {
'type' : 'DataCube',
'nimages' : 6,
'file_name' : 'output/test_datacube.fits'
},
}
im1_list = []
nimages = 6
b = None
for k in range(nimages):
ud = galsim.UniformDeviate(1234 + k + 1)
sigma = ud() + 1.
gal = galsim.Gaussian(sigma=sigma, flux=100)
if b is None:
im1 = gal.drawImage(scale=1)
b = im1.bounds
else:
im1 = gal.drawImage(bounds=b, scale=1)
im1_list.append(im1)
print('datacube image shapes = ',[im.array.shape for im in im1_list])
galsim.config.Process(config)
im2_list = galsim.fits.readCube('output/test_datacube.fits')
for k in range(nimages):
np.testing.assert_array_equal(im2_list[k].array, im1_list[k].array)
# nimages = 1 is allowed
config['output']['nimages'] = 1
galsim.config.Process(config)
im3_list = galsim.fits.readCube('output/test_datacube.fits')
assert len(im3_list) == 1
np.testing.assert_array_equal(im3_list[0].array, im1_list[0].array)
try:
# Check error message for missing nimages
del config['output']['nimages']
np.testing.assert_raises(AttributeError, galsim.config.BuildFile,config)
# Also if there is an input field that doesn't have nobj capability
config['input'] = { 'dict' : { 'dir' : 'config_input', 'file_name' : 'dict.p' } }
np.testing.assert_raises(AttributeError, galsim.config.BuildFile,config)
except ImportError:
pass
# However, an input field that does have nobj will return something for nobjects.
# This catalog has 3 rows, so equivalent to nobjects = 3
> del config['input_objs']
E KeyError: 'input_objs'
test_config_output.py:269: KeyError
------------------------------------------------------------------------------------------------------------ Captured stdout call -------------------------------------------------------------------------------------------------------------
datacube image shapes = [(20, 20), (20, 20), (20, 20), (20, 20), (20, 20), (20, 20)]
_______________________________________________________________________________________________________________ test_exceptions _______________________________________________________________________________________________________________
[gw0] linux2 -- Python 2.7.14 /global/scratch/dagoldst/miniconda2/bin/python
args = (), kwargs = {}, time = <module 'time' from '/global/scratch/dagoldst/miniconda2/lib/python2.7/lib-dynload/time.so'>, t0 = 1519756689.209508
@functools.wraps(f)
def f2(*args, **kwargs):
import time
t0 = time.time()
> result = f(*args, **kwargs)
galsim_test_helpers.py:555:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
test_inclined_exponential.py:607: in test_exceptions
np.testing.assert_raises(TypeError, get_prof, mode, inclination = 0.*galsim.degrees)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
def import_nose():
""" Import nose only when needed.
"""
nose_is_good = True
minimum_nose_version = (1, 0, 0)
try:
import nose
except ImportError:
nose_is_good = False
else:
if nose.__versioninfo__ < minimum_nose_version:
nose_is_good = False
if not nose_is_good:
msg = ('Need nose >= %d.%d.%d for tests - see '
'http://nose.readthedocs.io' %
minimum_nose_version)
> raise ImportError(msg)
E ImportError: Need nose >= 1.0.0 for tests - see http://nose.readthedocs.io
../../miniconda2/lib/python2.7/site-packages/numpy/testing/nose_tools/utils.py:71: ImportError
______________________________________________________________________________________________________________ test_shear_value _______________________________________________________________________________________________________________
[gw3] linux2 -- Python 2.7.14 /global/scratch/dagoldst/miniconda2/bin/python
args = (), kwargs = {}, time = <module 'time' from '/global/scratch/dagoldst/miniconda2/lib/python2.7/lib-dynload/time.so'>, t0 = 1519756696.290744
@functools.wraps(f)
def f2(*args, **kwargs):
import time
t0 = time.time()
> result = f(*args, **kwargs)
galsim_test_helpers.py:555:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
test_config_value.py:1162: in test_shear_value
nfw1a = galsim.config.ParseValue(config,'nfw',config, galsim.Shear)[0]
../../miniconda2/lib/python2.7/site-packages/galsim/config/value.py:104: in ParseValue
val_safe = generate_func(param, base, value_type)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
config = {'_gen_fn': <function _GenerateFromNFWHaloShear at 0x2b2c126c85f0>, 'type': 'NFWHaloShear'}
base = {'index_key': 'obj_num', 'input': {'_get': {}, 'nfw_halo': {'_get': {'conc': <type 'float'>, 'mass': <type 'float'>, '...0>, '_get': {'nitems': <type 'int'>}, 'current': (1, False, <type 'int'>, 4, 'obj_num'), 'default': 3, ...}, ...}, ...}
value_type = <class 'galsim.shear.Shear'>
def _GenerateFromNFWHaloShear(config, base, value_type):
"""@brief Return a shear calculated from an NFWHalo object.
"""
nfw_halo = galsim.config.GetInputObj('nfw_halo', config, base, 'NFWHaloShear')
logger = nfw_halo.logger
if 'world_pos' not in base:
> raise ValueError("NFWHaloShear requested, but no position defined.")
E ValueError: NFWHaloShear requested, but no position defined.
../../miniconda2/lib/python2.7/site-packages/galsim/config/input_nfw.py:47: ValueError
______________________________________________________________________________________________________________ test_float_value _______________________________________________________________________________________________________________
[gw3] linux2 -- Python 2.7.14 /global/scratch/dagoldst/miniconda2/bin/python
args = (), kwargs = {}, time = <module 'time' from '/global/scratch/dagoldst/miniconda2/lib/python2.7/lib-dynload/time.so'>, t0 = 15pytest returned error code 1
scons: *** [tests/tests.log] Explicit exit, status 1
scons: building terminated because of errors.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment