Skip to content
This repository has been archived by the owner on Oct 16, 2023. It is now read-only.

drive tests with run-tests. #18

Merged
merged 15 commits into from
Feb 5, 2018
Merged

Conversation

rainwoodman
Copy link
Contributor

This is a demonstration.

Unfortunately I couldn't test this because pip install healpy failed
on my box with anaconda-5.0 cross compilation tools chain -- It couldn't link with cfitsio.

We need a good binary package of healpy.

#17

Unfortunately I couldn't test this because pip install healpy failed
on my box with anaconda-5.0 cross compilation tools chain.

It couldn't find cfitsio.

We need a good binary package of healpy on conda.
@rainwoodman
Copy link
Contributor Author

The data files needs to be moved too for the tests to run due to the rename into pysm.test.

I am not sure about the best way of doing this.

(base) [yfeng1@waterfall PySM_public]$ python run-mpitests.py 
Purging /home/yfeng1/source/PySM_public/build/testenv ...
Purging /home/yfeng1/source/PySM_public/build/test ...
Building, see build.log...
Build OK
============================= test session starts ==============================
platform linux -- Python 3.6.3, pytest-3.3.0, py-1.5.2, pluggy-0.6.0
rootdir: /home/yfeng1/source/PySM_public, inifile:
plugins: hypothesis-3.38.5
collected 24 items

../testenv/lib/python3.6/site-packages/pysm/test/test_components.py .    [  4%]
../testenv/lib/python3.6/site-packages/pysm/test/test_common.py .        [  8%]
../testenv/lib/python3.6/site-packages/pysm/test/test_components.py .    [ 12%]
../testenv/lib/python3.6/site-packages/pysm/test/test_common.py .        [ 16%]
../testenv/lib/python3.6/site-packages/pysm/test/test_components.py F

=================================== FAILURES ===================================
__________________________ test_AME.test_AME_model_1 ___________________________

self = <pysm.test.test_components.test_AME testMethod=test_AME_model_1>

    def setUp(self):
        data_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'pysm', 'template'))
        test_data_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), 'test_data', 'benchmark'))
    
        a1_config = models("a1", 64)
        AME1 = components.AME(a1_config[0])
        AME2 = components.AME(a1_config[1])
    
        signal = lambda nu: AME1.signal()(nu) + AME2.signal()(nu)
    
>       ame_1_30GHz = read_map(os.path.join(test_data_dir, 'check3spinn_30p0_64.fits'), 64, field = (0, 1, 2))

../testenv/lib/python3.6/site-packages/pysm/test/test_components.py:148: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
../testenv/lib/python3.6/site-packages/pysm/common.py:83: in read_map
    output_map = hp.ud_grade(hp.read_map(fname, field = field, verbose = verbose), nside_out = nside)
../../../../anaconda3/install/lib/python3.6/site-packages/healpy/fitsfunc.py:283: in read_map
    fits_hdu = _get_hdu(filename, hdu=hdu, memmap=memmap)
../../../../anaconda3/install/lib/python3.6/site-packages/healpy/fitsfunc.py:547: in _get_hdu
    hdulist = pf.open(input_data, memmap=memmap)
../../../../anaconda3/install/lib/python3.6/site-packages/astropy/io/fits/hdu/hdulist.py:160: in fitsopen
    lazy_load_hdus, **kwargs)
../../../../anaconda3/install/lib/python3.6/site-packages/astropy/io/fits/hdu/hdulist.py:413: in fromfile
    lazy_load_hdus=lazy_load_hdus, **kwargs)
../../../../anaconda3/install/lib/python3.6/site-packages/astropy/io/fits/hdu/hdulist.py:998: in _readfrom
    fileobj = _File(fileobj, mode=mode, memmap=memmap, cache=cache)
../../../../anaconda3/install/lib/python3.6/site-packages/astropy/utils/decorators.py:507: in wrapper
    return function(*args, **kwargs)
../../../../anaconda3/install/lib/python3.6/site-packages/astropy/io/fits/file.py:150: in __init__
    self._open_filename(fileobj, mode, overwrite)
../../../../anaconda3/install/lib/python3.6/site-packages/astropy/io/fits/file.py:506: in _open_filename
    self._file = fileobj_open(self.name, IO_FITS_MODES[mode])
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

filename = '/home/yfeng1/source/PySM_public/build/testenv/lib/python3.6/site-packages/pysm/test/test_data/benchmark/check3spinn_30p0_64.fits'
mode = 'rb'

    def fileobj_open(filename, mode):
        """
            A wrapper around the `open()` builtin.
    
            This exists because in Python 3, `open()` returns an
            `io.BufferedReader` by default.  This is bad, because
            `io.BufferedReader` doesn't support random access, which we need in
            some cases.  In the Python 3 case (implemented in the py3compat module)
            we must call open with buffering=0 to get a raw random-access file
            reader.
            """
    
>       return open(filename, mode, buffering=0)
E       FileNotFoundError: [Errno 2] No such file or directory: '/home/yfeng1/source/PySM_public/build/testenv/lib/python3.6/site-packages/pysm/test/test_data/benchmark/check3spinn_30p0_64.fits'

../../../../anaconda3/install/lib/python3.6/site-packages/astropy/io/fits/util.py:409: FileNotFoundError
=============================== warnings summary ===============================
build/testenv/lib/python3.6/site-packages/pysm/test/test_components.py::ComponentsTests::testBlack_Body
  /home/yfeng1/source/PySM_public/build/testenv/lib/python3.6/site-packages/pysm/test/test_components.py:20: AstropyDeprecationWarning: The blackbody_nu function is deprecated and may be removed in a future version.
          Use astropy.modeling.blackbody.blackbody_nu instead.
    astropy = blackbody_nu(90.e9, 100.) / blackbody_nu(30.e9, 100.)

-- Docs: http://doc.pytest.org/en/latest/warnings.html

@zonca
Copy link
Collaborator

zonca commented Jan 19, 2018

the healpy conda package doesn't work?

@rainwoodman
Copy link
Contributor Author

You mean the one from conda-forge? Yes -- that's the one I tried, and it worked! Though it pulled in replacements a few unrelated packages (that's what I mean 'not clean').

I can fix the file not found error -- but it does seem the package contains some relatively big data files -- are they for testing only or are they necessary for the application to function? If they are for testing only perhaps a smaller version of file is preferred.

templates looked like an asset of PYSM, so the path shall be calculated in the root package.
For in-tree testing, PYSM_TESTDATA_DIR is not set, so we guess a relpath to the test
data
for out-tree testing (run-tests.py), PYSM_TESTDATA_DIR is set to the in-tree position.

This is to avoid installing the 64 MB and growing size of the test data set.
It appears that trimming it down requires subsential work that's beyond my judgement.
The test case appears to be broken -- no one produce the file
(but it is removed after test)

It's likely better to use a temporary file (but must be aware that
if MPI is used the filename needs to be broadcasted).
Since the intention is not to distribute them with the package.
This avoids '/', which was also avoided in the old code.
@zonca
Copy link
Collaborator

zonca commented Jan 23, 2018

you can probably install mpi on travis with apt

@zonca
Copy link
Collaborator

zonca commented Jan 23, 2018

with sudo apt-get install -y -q openmpi-bin libopenmpi-dev

@rainwoodman
Copy link
Contributor Author

rainwoodman commented Jan 24, 2018 via email

@zonca
Copy link
Collaborator

zonca commented Jan 26, 2018

also everything from anaconda would be fine

@zonca
Copy link
Collaborator

zonca commented Jan 26, 2018

anyway it looks like it is working fine now

@zonca
Copy link
Collaborator

zonca commented Jan 31, 2018

@rainwoodman do you think this Pull Request is ready for @bthorne93 to review and merge?

@zonca
Copy link
Collaborator

zonca commented Jan 31, 2018

I can then refactor #15 to use runtests as well

@rainwoodman
Copy link
Contributor Author

Yes, please. Travis is finally green!

@b-thorne b-thorne merged commit 1918c0d into b-thorne:master Feb 5, 2018
@zonca zonca mentioned this pull request Feb 6, 2018
@rainwoodman rainwoodman deleted the runtests branch February 11, 2018 00:22
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants