Skip to content

Instantly share code, notes, and snippets.

@joleroi
Created February 20, 2017 13:06
Show Gist options
  • Save joleroi/dc6023d58c993518400d0be3eaa2078d to your computer and use it in GitHub Desktop.
Save joleroi/dc6023d58c993518400d0be3eaa2078d to your computer and use it in GitHub Desktop.
running test
running build
running build_py
copying gammapy/_compiler.c -> build/lib.linux-x86_64-2.7/gammapy
running build_ext
building 'gammapy._compiler' extension
gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/kingj/Software/miniconda3/envs/headversions/include/python2.7 -c gammapy/_compiler.c -o build/temp.linux-x86_64-2.7/gammapy/_compiler.o
gcc -pthread -shared -L/home/kingj/Software/miniconda3/envs/headversions/lib -Wl,-rpath=/home/kingj/Software/miniconda3/envs/headversions/lib,--no-as-needed build/temp.linux-x86_64-2.7/gammapy/_compiler.o -L/home/kingj/Software/miniconda3/envs/headversions/lib -lpython2.7 -o build/lib.linux-x86_64-2.7/gammapy/_compiler.so
skipping 'gammapy/detect/_test_statistics_cython.c' Cython extension (up-to-date)
Gammapy test data availability:
gammapy-extra ... yes
hess ............ yes
Gammapy environment variables:
GAMMAPY_EXTRA = /home/kingj/Software/gammapy-extra
Setting matplotlib backend to "agg" for the tests.
============================= test session starts ==============================
platform linux2 -- Python 2.7.12, pytest-2.8.3, py-1.4.30, pluggy-0.3.1
Running tests with gammapy version 0.6.dev4176.
Running tests in gammapy/spectrum/tests/test_fit.py.
Date: 2017-02-20T14:04:26
Platform: Linux-3.13.0-58-generic-x86_64-with-debian-jessie-sid
Executable: /home/kingj/Software/miniconda3/envs/headversions/bin/python
Full Python Version:
2.7.12 |Continuum Analytics, Inc.| (default, Jul 2 2016, 17:42:40)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)]
encodings: sys: ascii, locale: UTF-8, filesystem: UTF-8, unicode bits: 20
byteorder: little
float info: dig: 15, mant_dig: 15
Numpy: 1.11.2
Scipy: 0.18.0
Matplotlib: 1.5.3
h5py: 2.5.0
Pandas: 0.18.1
cython: 0.23.2
skimage: 0.11.3
sklearn: 0.16.1
uncertainties: 2.4.8.1
iminuit: not available
astropy: 1.3
sherpa: ciao4.9+1.g1ebebb7
gammapy: 0.6.dev4176
naima: 0.6.1
reproject: 0.3.1
photutils: 0.1
aplpy: 1.0
regions: 0.2.dev234
astroplan: not available
Using Astropy options: remote_data.
rootdir: /tmp/gammapy-test-uNerBH, inifile: setup.cfg
plugins: nbval-0.3.2
collected 17 items
gammapy/spectrum/tests/test_fit.py ......FF.x.xFFF.F
=================================== FAILURES ===================================
______________________ TestSpectralFit.test_basic_results ______________________
self = <gammapy.spectrum.tests.test_fit.TestSpectralFit instance at 0x7fa4f3e64b48>
def test_basic_results(self):
self.fit.fit()
result = self.fit.result[0]
assert self.fit.method == 'sherpa'
> assert_allclose(result.statval, 33.05275834445061)
E AssertionError:
E Not equal to tolerance rtol=1e-07, atol=0
E
E (mismatch 100.0%)
E x: array(33.561371979379274)
E y: array(33.05275834445061)
gammapy/spectrum/tests/test_fit.py:195: AssertionError
______________________ TestSpectralFit.test_basic_errors _______________________
self = <gammapy.spectrum.tests.test_fit.TestSpectralFit instance at 0x7fa4fdd0d7a0>
def test_basic_errors(self):
self.fit.fit()
self.fit.est_errors()
result = self.fit.result[0]
par_errors = result.model_with_uncertainties.parameters
> assert_allclose(par_errors['index'].value.s, 0.09773507974970663)
E AssertionError:
E Not equal to tolerance rtol=1e-07, atol=0
E
E (mismatch 100.0%)
E x: array(0.09755965386088612)
E y: array(0.09773507974970663)
gammapy/spectrum/tests/test_fit.py:211: AssertionError
________________________ TestSpectralFit.test_ecpl_fit _________________________
self = <gammapy.spectrum.tests.test_fit.TestSpectralFit instance at 0x7fa4f3e61ab8>
def test_ecpl_fit(self):
fit = SpectrumFit(self.obs_list[0], self.ecpl)
fit.fit()
assert_quantity_allclose(fit.result[0].model.parameters['lambda_'].quantity,
> 0.03517869599246622 / u.TeV)
gammapy/spectrum/tests/test_fit.py:267:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
actual = <Quantity 0.03892024886986037 1 / TeV>
desired = <Quantity 0.03517869599246622 1 / TeV>, rtol = 1e-07, atol = None
kwargs = {}
np = <module 'numpy' from '/home/kingj/Software/miniconda3/envs/headversions/lib/python2.7/site-packages/numpy/__init__.pyc'>
def assert_quantity_allclose(actual, desired, rtol=1.e-7, atol=None,
**kwargs):
"""
Raise an assertion if two objects are not equal up to desired tolerance.
This is a :class:`~astropy.units.Quantity`-aware version of
:func:`numpy.testing.assert_allclose`.
"""
import numpy as np
np.testing.assert_allclose(*_unquantify_allclose_arguments(actual, desired,
rtol, atol),
> **kwargs)
E AssertionError:
E Not equal to tolerance rtol=1e-07, atol=0
E
E (mismatch 100.0%)
E x: array(0.03892024886986037)
E y: array(0.03517869599246622)
/home/kingj/Software/miniconda3/envs/headversions/lib/python2.7/site-packages/astropy-1.3-py2.7-linux-x86_64.egg/astropy/tests/helper.py:482: AssertionError
________________________ TestSpectralFit.test_joint_fit ________________________
self = <gammapy.spectrum.tests.test_fit.TestSpectralFit instance at 0x7fa4f4767488>
def test_joint_fit(self):
fit = SpectrumFit(self.obs_list, self.pwl)
fit.fit()
assert_quantity_allclose(fit.model.parameters['index'].quantity,
> 2.2116730966862543)
gammapy/spectrum/tests/test_fit.py:273:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
actual = <Quantity 2.1781756015659552>, desired = 2.2116730966862543
rtol = 1e-07, atol = None, kwargs = {}
np = <module 'numpy' from '/home/kingj/Software/miniconda3/envs/headversions/lib/python2.7/site-packages/numpy/__init__.pyc'>
def assert_quantity_allclose(actual, desired, rtol=1.e-7, atol=None,
**kwargs):
"""
Raise an assertion if two objects are not equal up to desired tolerance.
This is a :class:`~astropy.units.Quantity`-aware version of
:func:`numpy.testing.assert_allclose`.
"""
import numpy as np
np.testing.assert_allclose(*_unquantify_allclose_arguments(actual, desired,
rtol, atol),
> **kwargs)
E AssertionError:
E Not equal to tolerance rtol=1e-07, atol=0
E
E (mismatch 100.0%)
E x: array(2.1781756015659552)
E y: array(2.2116730966862543)
/home/kingj/Software/miniconda3/envs/headversions/lib/python2.7/site-packages/astropy-1.3-py2.7-linux-x86_64.egg/astropy/tests/helper.py:482: AssertionError
_______________________ TestSpectralFit.test_stacked_fit _______________________
self = <gammapy.spectrum.tests.test_fit.TestSpectralFit instance at 0x7fa4f3e20950>
def test_stacked_fit(self):
stacked_obs = self.obs_list.stack()
obs_list = SpectrumObservationList([stacked_obs])
fit = SpectrumFit(obs_list, self.pwl)
fit.fit()
pars = fit.model.parameters
> assert_quantity_allclose(pars['index'].value, 2.244456667160672)
gammapy/spectrum/tests/test_fit.py:299:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
actual = 2.2170060918297474, desired = 2.244456667160672, rtol = 1e-07
atol = None, kwargs = {}
np = <module 'numpy' from '/home/kingj/Software/miniconda3/envs/headversions/lib/python2.7/site-packages/numpy/__init__.pyc'>
def assert_quantity_allclose(actual, desired, rtol=1.e-7, atol=None,
**kwargs):
"""
Raise an assertion if two objects are not equal up to desired tolerance.
This is a :class:`~astropy.units.Quantity`-aware version of
:func:`numpy.testing.assert_allclose`.
"""
import numpy as np
np.testing.assert_allclose(*_unquantify_allclose_arguments(actual, desired,
rtol, atol),
> **kwargs)
E AssertionError:
E Not equal to tolerance rtol=1e-07, atol=0
E
E (mismatch 100.0%)
E x: array(2.2170060918297474)
E y: array(2.244456667160672)
/home/kingj/Software/miniconda3/envs/headversions/lib/python2.7/site-packages/astropy-1.3-py2.7-linux-x86_64.egg/astropy/tests/helper.py:482: AssertionError
_______________________________ test_sherpa_fit ________________________________
tmpdir = local('/tmp/pytest-of-kingj/pytest-2/test_sherpa_fit0')
@requires_dependency('sherpa')
@requires_data('gammapy-extra')
def test_sherpa_fit(tmpdir):
# this is to make sure that the written PHA files work with sherpa
pha1 = gammapy_extra.filename("datasets/hess-crab4_pha/pha_obs23592.fits")
import sherpa.astro.ui as sau
from sherpa.models import PowLaw1D
sau.load_pha(pha1)
sau.set_stat('wstat')
model = PowLaw1D('powlaw1d.default')
model.ref = 1e9
model.ampl = 1
model.gamma = 2
sau.set_model(model * 1e-20)
sau.fit()
> assert_allclose(model.pars[0].val, 2.0281484215403616, atol=1e-4)
E AssertionError:
E Not equal to tolerance rtol=1e-07, atol=0.0001
E
E (mismatch 100.0%)
E x: array(1.9514093392067255)
E y: array(2.0281484215403616)
gammapy/spectrum/tests/test_fit.py:324: AssertionError
----------------------------- Captured stdout call -----------------------------
WARNING: imaging routines will not be available,
failed to import sherpa.image.ds9_backend due to
'RuntimeErr: DS9Win unusable: Could not find ds9 on your PATH'
WARNING: failed to import sherpa.astro.xspec; XSPEC models will not be available
read ARF file /home/kingj/Software/gammapy-extra/datasets/hess-crab4_pha/arf_obs23592.fits
read RMF file /home/kingj/Software/gammapy-extra/datasets/hess-crab4_pha/rmf_obs23592.fits
read background file /home/kingj/Software/gammapy-extra/datasets/hess-crab4_pha/bkg_obs23592.fits
Dataset = 1
Method = levmar
Statistic = wstat
Initial fit statistic = 157.662
Final fit statistic = 77.2689 at function evaluation 22
Data points = 72
Degrees of freedom = 70
Probability [Q-value] = 0.257787
Reduced statistic = 1.10384
Change in statistic = 80.3928
powlaw1d.default.gamma 1.95141
powlaw1d.default.ampl 2.23028
================ 6 failed, 9 passed, 2 xfailed in 28.02 seconds ================
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment