bjodah / chempy

⚗ A package useful for chemistry written in Python
BSD 2-Clause "Simplified" License
552 stars 80 forks source link

Handle PuLP exception on FreeBSD #110

Closed bjodah closed 6 years ago

bjodah commented 6 years ago

@yurivict would you mind testing this branch? (I don't have a FreeBSD install at hand and I'm not that proficient using it).

Fixes gh-109

yurivict commented 6 years ago

With this patch, it still prints some warnings:

============================================================================= warnings summary ==============================================================================
chempy/kinetics/tests/test_ode.py::test_get_ode__Radiolytic__units__multi
  /usr/local/lib/python2.7/site-packages/pyodesys/core.py:519: UserWarning: 'adaptive' mode with SciPy's integrator (vode/lsoda) may overshoot (itask=2)
    warnings.warn("'adaptive' mode with SciPy's integrator (vode/lsoda) may overshoot (itask=2)")
  /usr/local/lib/python2.7/site-packages/pyodesys/core.py:520: UserWarning: 'adaptive' mode with SciPy's integrator is unreliable, consider using e.g. cvode
    warnings.warn("'adaptive' mode with SciPy's integrator is unreliable, consider using e.g. cvode")

chempy/kinetics/tests/test_rates.py::test_RateExpr__subclass_from_callback
  /usr/ports/science/py-chempy/work-py27/chempy-0.7.2/chempy/kinetics/tests/test_rates.py:52: ChemPyDeprecationWarning: subclass_from_callback is deprecated. Use from_callback instead.
    lambda v, a, backend: a[0]*v['H2']*v['Br2']**(3/2) / (v['Br2'] + a[1]*v['HBr'])

chempy/kinetics/tests/test_rates.py::test_MassAction__subclass_from_callback
  /usr/ports/science/py-chempy/work-py27/chempy-0.7.2/chempy/kinetics/tests/test_rates.py:100: ChemPyDeprecationWarning: subclass_from_callback is deprecated. Use MassAction.from_callback instead.
    rate_coeff, cls_attrs=dict(parameter_keys=('temperature',), nargs=2))
  /usr/ports/science/py-chempy/work-py27/chempy-0.7.2/chempy/kinetics/rates.py:180: ChemPyDeprecationWarning: subclass_from_callback is deprecated. Use from_callback instead.
    _RateExpr = super(MassAction, cls).subclass_from_callback(cb, cls_attrs=cls_attrs)

chempy/tests/test__equilibrium.py::test_solve_equilibrium_1
  /usr/ports/science/py-chempy/work-py27/chempy-0.7.2/chempy/chemistry.py:859: RuntimeWarning: divide by zero encountered in double_scalars
    tot *= conc**nr

chempy/tests/test_henry.py::test_Henry__with_units
  /usr/ports/science/py-chempy/work-py27/chempy-0.7.2/chempy/tests/test_henry.py:23: ChemPyDeprecationWarning: get_kH_at_T is deprecated since (not including) 0.3.1, it will be missing in 0.5.0. Use __call__ instead.
    assert allclose(kH_H2.get_kH_at_T(

chempy/tests/test_reactionsystem.py::test_ReactionSystem__html_tables
  /usr/ports/science/py-chempy/work-py27/chempy-0.7.2/chempy/tests/test_reactionsystem.py:101: ChemPyDeprecationWarning: unimolecular_html_table is deprecated since (not including) 0.5.7, it will be missing in 0.8.0. Use chempy.printing.tables.UnimolecularTable instead.
    ut, unc = rs.unimolecular_html_table()
  /usr/ports/science/py-chempy/work-py27/chempy-0.7.2/chempy/tests/test_reactionsystem.py:106: ChemPyDeprecationWarning: bimolecular_html_table is deprecated since (not including) 0.5.7, it will be missing in 0.8.0. Use chempy.printing.tables.BimolecularTable instead.
    bt, bnc = rs.bimolecular_html_table()

chempy/util/tests/test_expr.py::test_mk_Poly
  /usr/ports/science/py-chempy/work-py27/chempy-0.7.2/chempy/util/tests/test_expr.py:165: ChemPyDeprecationWarning: _mk_Poly is deprecated. Use create_Poly instead.
    Poly = mk_Poly('T', reciprocal=True)

chempy/util/tests/test_expr.py::test_PiecewisePoly
  /usr/ports/science/py-chempy/work-py27/chempy-0.7.2/chempy/util/tests/test_expr.py:208: ChemPyDeprecationWarning: _mk_PiecewisePoly is deprecated. Use create_Piecewise instead.
    TPiecewisePoly = mk_PiecewisePoly('temperature')

chempy/util/tests/test_parsing.py::test_formula_to_composition
  /usr/ports/science/py-chempy/work-py27/chempy-0.7.2/chempy/util/tests/test_parsing.py:16: ChemPyDeprecationWarning: / depr. (before 0.5.0): use 'Fe+3' over 'Fe/3+'
    assert formula_to_composition('Fe/3+') == {0: 3, 26: 1}
  /usr/ports/science/py-chempy/work-py27/chempy-0.7.2/chempy/util/tests/test_parsing.py:16: ChemPyDeprecationWarning: 'Fe/3+' deprecated, use e.g. 'Fe+3'
    assert formula_to_composition('Fe/3+') == {0: 3, 26: 1}

chempy/util/tests/test_parsing.py::test_formula_to_latex
  /usr/ports/science/py-chempy/work-py27/chempy-0.7.2/chempy/util/parsing.py:435: ChemPyDeprecationWarning: / depr. (before 0.5.0): use 'Fe+3' over 'Fe/3+'
    formula, prefixes, infixes, **kwargs)
  /usr/ports/science/py-chempy/work-py27/chempy-0.7.2/chempy/util/parsing.py:435: ChemPyDeprecationWarning: 'Fe/3+' deprecated, use e.g. 'Fe+3'
    formula, prefixes, infixes, **kwargs)

chempy/util/tests/test_periodic.py::test_mass_from_composition__formula
  /usr/ports/science/py-chempy/work-py27/chempy-0.7.2/chempy/util/tests/test_periodic.py:44: ChemPyDeprecationWarning: / depr. (before 0.5.0): use 'Fe+3' over 'Fe/3+'
    Fminus = mass_from_composition(formula_to_composition('F/-'))

-- Docs: http://doc.pytest.org/en/latest/warnings.html
=========================================================== 272 passed, 32 skipped, 16 warnings in 11.34 seconds ============================================================
bjodah commented 6 years ago

That's expected, the test suite covers deprecated code as well. To silence deprecation warnings you can set an environment variable, see this line: https://github.com/bjodah/chempy/blob/5bec33521c33cea5a4e32141646a14cbef1ea5e1/scripts/run_tests.sh#L6

If the warning about the scipy ode solver during the test run is annoying, one could silence it in a similar manner. But it would require me to introduce a special warning class in chempy, e.g. ChemPyUserWarning which could be filtered as 'ignore'.

yurivict commented 6 years ago

It is fine, thank you. I only worried about the actual failures.

Thanks for fixing the failures!

bjodah commented 6 years ago

Great thanks, merging this then and tagging a new release. Thank you for the review.

On a side note, pytest offers selective silencing:

but I dont think that will help in source distributions (since setup.cfg is missing). Let me know if there's a better way.

bjodah commented 6 years ago

Just tagged 0.7.3: https://github.com/bjodah/chempy/releases/tag/v0.7.3

and source release on PyPI: https://pypi.org/project/chempy/#files