timothydmorton / isochrones

Pythonic stellar model grid access; easy MCMC fitting of stellar properties
http://isochrones.readthedocs.org
MIT License
117 stars 63 forks source link

nosetests isochrones errors #95

Open pmaxted opened 5 years ago

pmaxted commented 5 years ago

conda version 4.6.14 running on CentOS ... Python 3.7.3 [GCC 7.3.0] :: Anaconda, Inc. on linux

====================================================================== FAIL: isochrones.tests.test_likelihood.test_compare_spec

Traceback (most recent call last): File "/indus/pflm/anaconda3/envs/isochrones/lib/python3.7/site-packages/nose/case.py", line 197, in runTest self.test(*self.arg) File "/indus/pflm/anaconda3/envs/isochrones/lib/python3.7/site-packages/isochrones/tests/test_likelihood.py", line 55, in test_compare_spec test_compare_starmodels(props_spec) File "/indus/pflm/anaconda3/envs/isochrones/lib/python3.7/site-packages/isochrones/tests/test_likelihood.py", line 25, in test_compare_starmodels assert np.isclose(m1.lnlike(pars), m2.lnlike(pars)) AssertionError: -------------------- >> begin captured logging << -------------------- root: DEBUG: Building ObservationTree... --------------------- >> end captured logging << ---------------------

====================================================================== FAIL: isochrones.tests.test_likelihood.test_compare_phot

Traceback (most recent call last): File "/indus/pflm/anaconda3/envs/isochrones/lib/python3.7/site-packages/nose/case.py", line 197, in runTest self.test(*self.arg) File "/indus/pflm/anaconda3/envs/isochrones/lib/python3.7/site-packages/isochrones/tests/test_likelihood.py", line 59, in test_compare_phot test_compare_starmodels(props_phot) File "/indus/pflm/anaconda3/envs/isochrones/lib/python3.7/site-packages/isochrones/tests/test_likelihood.py", line 25, in test_compare_starmodels assert np.isclose(m1.lnlike(pars), m2.lnlike(pars)) AssertionError: -------------------- >> begin captured logging << -------------------- root: DEBUG: Building ObservationTree... root: DEBUG: Adding (3.58, 0.05) @(0.0, 0.0) (-J) root: DEBUG: Adding (3.22, 0.05) @(0.0, 0.0) (-K) --------------------- >> end captured logging << ---------------------

timothydmorton commented 5 years ago

Interesting; try going into the tests directory and running pytest test_likelihood.py, which should give more information in the output. This is a test comparing the new way of constructing a StarModel with the old way, and the idea was that they should be the same. So I'm curious to see where the difference is.

shridharanbaskaran commented 4 years ago

conda 4.7.12 on Ubuntu 18.04 Python 3.7.4 I am getting the same AssertionError as the original post:

====================================================================== FAIL: isochrones.tests.test_likelihood.test_compare_spec

Traceback (most recent call last): File "/home/researchlab/anaconda3/envs/isochrones/lib/python3.7/site-packages/nose/case.py", line 197, in runTest self.test(*self.arg) File "/home/researchlab/anaconda3/envs/isochrones/lib/python3.7/site-packages/isochrones/tests/test_likelihood.py", line 55, in test_compare_spec test_compare_starmodels(props_spec) File "/home/researchlab/anaconda3/envs/isochrones/lib/python3.7/site-packages/isochrones/tests/test_likelihood.py", line 25, in test_compare_starmodels assert np.isclose(m1.lnlike(pars), m2.lnlike(pars)) AssertionError: -------------------- >> begin captured logging << -------------------- root: DEBUG: Building ObservationTree... numba.typeinfer: DEBUG: captured error Traceback (most recent call last): File "/home/researchlab/anaconda3/envs/isochrones/lib/python3.7/site-packages/numba/typeinfer.py", line 147, in propagate constraint(typeinfer) File "/home/researchlab/anaconda3/envs/isochrones/lib/python3.7/site-packages/numba/typeinfer.py", line 639, in call self._refine_target_type(typeinfer, targetty, idxty, valty, sig) File "/home/researchlab/anaconda3/envs/isochrones/lib/python3.7/site-packages/numba/typeinfer.py", line 606, in _refine_target_type typeinfer.add_type(self.target.name, sig.args[0], loc=self.loc) File "/home/researchlab/anaconda3/envs/isochrones/lib/python3.7/site-packages/numba/typeinfer.py", line 939, in add_type self.propagate_refined_type(var, unified) File "/home/researchlab/anaconda3/envs/isochrones/lib/python3.7/site-packages/numba/typeinfer.py", line 955, in propagate_refined_type source_constraint.refine(self, updated_type) File "/home/researchlab/anaconda3/envs/isochrones/lib/python3.7/site-packages/numba/typeinfer.py", line 546, in refine raise TypingError(m.format(self.func, updated_type)) numba.errors.TypingError: no type refinement implemented for function empty_func.213 updating to array(float64, 1d, C) [1] During: typing of setitem at /home/researchlab/anaconda3/envs/isochrones/lib/python3.7/site-packages/isochrones/interp.py (296) numba.typeinfer: DEBUG: captured error Traceback (most recent call last): File "/home/researchlab/anaconda3/envs/isochrones/lib/python3.7/site-packages/numba/typeinfer.py", line 147, in propagate constraint(typeinfer) File "/home/researchlab/anaconda3/envs/isochrones/lib/python3.7/site-packages/numba/typeinfer.py", line 639, in call self._refine_target_type(typeinfer, targetty, idxty, valty, sig) File "/home/researchlab/anaconda3/envs/isochrones/lib/python3.7/site-packages/numba/typeinfer.py", line 606, in _refine_target_type typeinfer.add_type(self.target.name, sig.args[0], loc=self.loc) File "/home/researchlab/anaconda3/envs/isochrones/lib/python3.7/site-packages/numba/typeinfer.py", line 939, in add_type self.propagate_refined_type(var, unified) File "/home/researchlab/anaconda3/envs/isochrones/lib/python3.7/site-packages/numba/typeinfer.py", line 955, in propagate_refined_type source_constraint.refine(self, updated_type) File "/home/researchlab/anaconda3/envs/isochrones/lib/python3.7/site-packages/numba/typeinfer.py", line 546, in refine raise TypingError(m.format(self.func, updated_type)) numba.errors.TypingError: no type refinement implemented for function empty_func.205 updating to array(float64, 1d, C) [1] During: typing of setitem at /home/researchlab/anaconda3/envs/isochrones/lib/python3.7/site-packages/isochrones/interp.py (302) --------------------- >> end captured logging << ---------------------

====================================================================== FAIL: isochrones.tests.test_likelihood.test_compare_phot

Traceback (most recent call last): File "/home/researchlab/anaconda3/envs/isochrones/lib/python3.7/site-packages/nose/case.py", line 197, in runTest self.test(*self.arg) File "/home/researchlab/anaconda3/envs/isochrones/lib/python3.7/site-packages/isochrones/tests/test_likelihood.py", line 59, in test_compare_phot test_compare_starmodels(props_phot) File "/home/researchlab/anaconda3/envs/isochrones/lib/python3.7/site-packages/isochrones/tests/test_likelihood.py", line 25, in test_compare_starmodels assert np.isclose(m1.lnlike(pars), m2.lnlike(pars)) AssertionError: -------------------- >> begin captured logging << -------------------- root: DEBUG: Building ObservationTree... root: DEBUG: Adding (3.58, 0.05) @(0.0, 0.0) (-J) root: DEBUG: Adding (3.22, 0.05) @(0.0, 0.0) (-K) --------------------- >> end captured logging << ---------------------


Ran 22 tests in 183.527s

FAILED (errors=7, failures=2)

As you have suggested above, this is the result for pytest test_likelihood.py: ======================================= test session starts ======================================== platform linux -- Python 3.7.4, pytest-5.2.0, py-1.8.0, pluggy-0.13.0 rootdir: /home/researchlab/anaconda3/envs/isochrones/lib/python3.7/site-packages/isochrones/tests collected 3 items

test_likelihood.py FFF [100%]

============================================= FAILURES ============================================== __ test_compare_starmodels __

self = Index(['eep', 'age', 'feh', 'mass', 'initial_mass', 'radius', 'density', 'logTeff', 'Teff', 'logg', 'logL', 'Mbol', 'delta_nu', 'nu_max', 'phase', 'dm_deep'], dtype='object') key = -4.0, method = None, tolerance = None

@Appender(_index_shared_docs["get_loc"])
def get_loc(self, key, method=None, tolerance=None):
    if method is None:
        if tolerance is not None:
            raise ValueError(
                "tolerance argument only valid if using pad, "
                "backfill or nearest lookups"
            )
        try:
          return self._engine.get_loc(key)

../../pandas/core/indexes/base.py:2897:


???

pandas/_libs/index.pyx:107:


???

pandas/_libs/index.pyx:131:


???

pandas/_libs/hashtable_class_helper.pxi:1607:


??? E KeyError: -4.0

pandas/_libs/hashtable_class_helper.pxi:1614: KeyError

During handling of the above exception, another exception occurred:

props = {'J': (3.58, 0.05), 'K': (3.22, 0.05), 'Teff': (5800, 100), 'logg': (4.5, 0.1), ...}

def test_compare_starmodels(props=props):
    m1 = StarModel(mist, **props)
    m2 = BasicStarModel(mist, **props)

    # Ensure priors are identical
    for k in ['mass', 'feh', 'age', 'distance', 'AV', 'eep']:
        m2.set_prior(**{k: m1._priors[k]})

    pars = [300, 9.8, 0.01, 100, 0.1]
  assert np.isclose(m1.lnlike(pars), m2.lnlike(pars))

test_likelihood.py:25:


../starmodel.py:516: in lnlike Teff, logg, feh, mags = self.ic.interp_mag(pars, self.bands) ../models.py:390: in interp_mag self.model_grid.interp.grid, ../grid.py:135: in interp self._interp = DFInterpolator(self.df, filename=filename, is_full=self.is_full) ../models.py:137: in df self._df['dm_deep'] = self.get_dm_deep() ../models.py:124: in get_dm_deep subdf = df.loc[f, a] ../../pandas/core/indexing.py:1418: in getitem return self._getitem_tuple(key) ../../pandas/core/indexing.py:805: in _getitem_tuple return self._getitem_lowerdim(tup) ../../pandas/core/indexing.py:961: in _getitem_lowerdim return getattr(section, self.name)[new_key] ../../pandas/core/indexing.py:1418: in getitem return self._getitem_tuple(key) ../../pandas/core/indexing.py:805: in _getitem_tuple return self._getitem_lowerdim(tup) ../../pandas/core/indexing.py:910: in _getitem_lowerdim return self._getitem_nested_tuple(tup) ../../pandas/core/indexing.py:993: in _getitem_nested_tuple obj = getattr(obj, self.name)._getitem_axis(key, axis=axis) ../../pandas/core/indexing.py:1850: in _getitem_axis return self._get_label(key, axis=axis) ../../pandas/core/indexing.py:160: in _get_label return self.obj._xs(label, axis=axis) ../../pandas/core/generic.py:3729: in xs return self[key] ../../pandas/core/frame.py:2980: in getitem indexer = self.columns.get_loc(key) ../../pandas/core/indexes/base.py:2899: in get_loc return self._engine.get_loc(self._maybe_cast_indexer(key)) pandas/_libs/index.pyx:107: in pandas._libs.index.IndexEngine.get_loc ??? pandas/_libs/index.pyx:131: in pandas._libs.index.IndexEngine.get_loc ??? pandas/_libs/hashtable_class_helper.pxi:1607: in pandas._libs.hashtable.PyObjectHashTable.get_item ???


??? E KeyError: -4

pandas/_libs/hashtable_classhelper.pxi:1614: KeyError ____ test_comparespec ____

def test_compare_spec():
  test_compare_starmodels(props_spec)

test_likelihood.py:55:


props = {'Teff': (5800, 100), 'logg': (4.5, 0.1), 'parallax': (100, 0.1)}

def test_compare_starmodels(props=props):
    m1 = StarModel(mist, **props)
    m2 = BasicStarModel(mist, **props)

    # Ensure priors are identical
    for k in ['mass', 'feh', 'age', 'distance', 'AV', 'eep']:
        m2.set_prior(**{k: m1._priors[k]})

    pars = [300, 9.8, 0.01, 100, 0.1]
  assert np.isclose(m1.lnlike(pars), m2.lnlike(pars))

E assert False E + where False = <function isclose at 0x7ff5b3636d40>(-inf, nan) E + where <function isclose at 0x7ff5b3636d40> = np.isclose E + and -inf = <bound method StarModel.lnlike of <isochrones.starmodel.StarModel object at 0x7ff581bd7c90>>([300, 9.8, 0.01, 100, 0.1]) E + where <bound method StarModel.lnlike of <isochrones.starmodel.StarModel object at 0x7ff581bd7c90>> = <isochrones.starmodel.StarModel object at 0x7ff581bd7c90>.lnlike E + and nan = <bound method BasicStarModel.lnlike of <isochrones.starmodel.BasicStarModel object at 0x7ff581bd7890>>([300, 9.8, 0.01, 100, 0.1]) E + where <bound method BasicStarModel.lnlike of <isochrones.starmodel.BasicStarModel object at 0x7ff581bd7890>> = <isochrones.starmodel.BasicStarModel object at 0x7ff581bd7890>.lnlike

testlikelihood.py:25: AssertionError ____ test_comparephot ____

def test_compare_phot():
  test_compare_starmodels(props_phot)

test_likelihood.py:59:


props = {'J': (3.58, 0.05), 'K': (3.22, 0.05), 'parallax': (100, 0.1)}

def test_compare_starmodels(props=props):
    m1 = StarModel(mist, **props)
    m2 = BasicStarModel(mist, **props)

    # Ensure priors are identical
    for k in ['mass', 'feh', 'age', 'distance', 'AV', 'eep']:
        m2.set_prior(**{k: m1._priors[k]})

    pars = [300, 9.8, 0.01, 100, 0.1]
  assert np.isclose(m1.lnlike(pars), m2.lnlike(pars))

E assert False E + where False = <function isclose at 0x7ff5b3636d40>(-inf, nan) E + where <function isclose at 0x7ff5b3636d40> = np.isclose E + and -inf = <bound method StarModel.lnlike of <isochrones.starmodel.StarModel object at 0x7ff57b7f61d0>>([300, 9.8, 0.01, 100, 0.1]) E + where <bound method StarModel.lnlike of <isochrones.starmodel.StarModel object at 0x7ff57b7f61d0>> = <isochrones.starmodel.StarModel object at 0x7ff57b7f61d0>.lnlike E + and nan = <bound method BasicStarModel.lnlike of <isochrones.starmodel.BasicStarModel object at 0x7ff57b7f6c10>>([300, 9.8, 0.01, 100, 0.1]) E + where <bound method BasicStarModel.lnlike of <isochrones.starmodel.BasicStarModel object at 0x7ff57b7f6c10>> = <isochrones.starmodel.BasicStarModel object at 0x7ff57b7f6c10>.lnlike

test_likelihood.py:25: AssertionError ========================================= warnings summary ========================================== test_likelihood.py::test_compare_starmodels /home/researchlab/anaconda3/envs/isochrones/lib/python3.7/importlib/_bootstrap.py:219: RuntimeWarning: numpy.ufunc size changed, may indicate binary incompatibility. Expected 192 from C header, got 216 from PyObject return f(*args, **kwds)

test_likelihood.py::test_compare_starmodels /home/researchlab/anaconda3/envs/isochrones/lib/python3.7/site-packages/pandas/core/series.py:853: RuntimeWarning: divide by zero encountered in log10 result = getattr(ufunc, method)(*inputs, **kwargs)

test_likelihood.py::test_compare_starmodels /home/researchlab/anaconda3/envs/isochrones/lib/python3.7/site-packages/pandas/core/indexing.py:494: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy self.obj[item] = s

test_likelihood.py::test_compare_spec test_likelihood.py::test_compare_phot /home/researchlab/anaconda3/envs/isochrones/lib/python3.7/site-packages/numba/ir_utils.py:1959: NumbaPendingDeprecationWarning: Encountered the use of a type that is scheduled for deprecation: type 'reflected list' found for argument 'index_order' of function 'interp_mag'.

For more information visit http://numba.pydata.org/numba-doc/latest/reference/deprecation.html#deprecation-of-reflection-for-list-and-set-types

File "../mags.py", line 9: @nb.jit(nopython=True) def interp_mag(pars, index_order, model_grid, ^

warnings.warn(NumbaPendingDeprecationWarning(msg, loc=loc))

test_likelihood.py::test_compare_spec test_likelihood.py::test_compare_phot /home/researchlab/anaconda3/envs/isochrones/lib/python3.7/site-packages/isochrones/likelihood.py:44: NumbaPendingDeprecationWarning: Encountered the use of a type that is scheduled for deprecation: type 'reflected list' found for argument 'index_order' of function 'interp_mag'.

For more information visit http://numba.pydata.org/numba-doc/latest/reference/deprecation.html#deprecation-of-reflection-for-list-and-set-types

File "../mags.py", line 9: @nb.jit(nopython=True) def interp_mag(pars, index_order, model_grid, ^

bc_ii0, bc_ii1, bc_ii2, bc_ii3)

test_likelihood.py::test_compare_spec test_likelihood.py::test_compare_phot /home/researchlab/anaconda3/envs/isochrones/lib/python3.7/site-packages/numba/ir_utils.py:1959: NumbaPendingDeprecationWarning: Encountered the use of a type that is scheduled for deprecation: type 'reflected list' found for argument 'index_order' of function 'star_lnlike'.

For more information visit http://numba.pydata.org/numba-doc/latest/reference/deprecation.html#deprecation-of-reflection-for-list-and-set-types

File "../likelihood.py", line 17: @nb.jit(nopython=True) def star_lnlike(pars, index_order, ^

warnings.warn(NumbaPendingDeprecationWarning(msg, loc=loc))

test_likelihood.py::test_compare_phot /home/researchlab/anaconda3/envs/isochrones/lib/python3.7/site-packages/isochrones/mags.py:32: NumbaPendingDeprecationWarning: Encountered the use of a type that is scheduled for deprecation: type 'reflected list' found for argument 'icols' of function 'interp_value_4d'.

For more information visit http://numba.pydata.org/numba-doc/latest/reference/deprecation.html#deprecation-of-reflection-for-list-and-set-types

File "../interp.py", line 292: @nb.jit(nopython=True) def interp_value_4d(x0, x1, x2, x3, ^

bc_ii0, bc_ii1, bc_ii2, bc_ii3)

test_likelihood.py::test_compare_phot /home/researchlab/anaconda3/envs/isochrones/lib/python3.7/site-packages/numba/ir_utils.py:1959: NumbaPendingDeprecationWarning: Encountered the use of a type that is scheduled for deprecation: type 'reflected list' found for argument 'bc_cols' of function 'interp_mag'.

For more information visit http://numba.pydata.org/numba-doc/latest/reference/deprecation.html#deprecation-of-reflection-for-list-and-set-types

File "../mags.py", line 9: @nb.jit(nopython=True) def interp_mag(pars, index_order, model_grid, ^

warnings.warn(NumbaPendingDeprecationWarning(msg, loc=loc))

test_likelihood.py::test_compare_phot /home/researchlab/anaconda3/envs/isochrones/lib/python3.7/site-packages/isochrones/likelihood.py:44: NumbaPendingDeprecationWarning: Encountered the use of a type that is scheduled for deprecation: type 'reflected list' found for argument 'bc_cols' of function 'interp_mag'.

For more information visit http://numba.pydata.org/numba-doc/latest/reference/deprecation.html#deprecation-of-reflection-for-list-and-set-types

File "../mags.py", line 9: @nb.jit(nopython=True) def interp_mag(pars, index_order, model_grid, ^

bc_ii0, bc_ii1, bc_ii2, bc_ii3)

test_likelihood.py::test_compare_phot /home/researchlab/anaconda3/envs/isochrones/lib/python3.7/site-packages/numba/ir_utils.py:1959: NumbaPendingDeprecationWarning: Encountered the use of a type that is scheduled for deprecation: type 'reflected list' found for argument 'i_mags' of function 'star_lnlike'.

For more information visit http://numba.pydata.org/numba-doc/latest/reference/deprecation.html#deprecation-of-reflection-for-list-and-set-types

File "../likelihood.py", line 17: @nb.jit(nopython=True) def star_lnlike(pars, index_order, ^

warnings.warn(NumbaPendingDeprecationWarning(msg, loc=loc))

-- Docs: https://docs.pytest.org/en/latest/warnings.html ================================== 3 failed, 13 warnings in 32.74s ==================================

timothydmorton commented 4 years ago

I haven't been able to reproduce this. What version of numba do you have? Only thing I can suggest is to start with a fresh environment and reproduce the installation steps that travis does and see if that works:

conda install -c conda-forge numpy=1.15 numba cython nose pytables pandas
conda install -c conda-forge multinest pymultinest

The numpy=1.15 requirement is because there seems to be some weird bug that shows up in recent versions of numpy that prevents tests from running.

gully commented 4 years ago

A colleague was seeing a similar error that we diagnosed as the absence of the file dm_deep_v1.2_vvcrit0.4_full_isos.h5 . When I send this file to the colleague and it is placed in ~/.isochrones/mist/ we see the code work. Why was this file programmatically generated in one case, and not the other?

xhRhapsody commented 3 years ago

A colleague was seeing a similar error that we diagnosed as the absence of the file dm_deep_v1.2_vvcrit0.4_full_isos.h5 . When I send this file to the colleague and it is placed in ~/.isochrones/mist/ we see the code work. Why was this file programmatically generated in one case, and not the other?

I have the same question as your colleague.

timothydmorton commented 3 years ago

Can you give me some details on how you can reproduce this issue? This file should be programmatically created.