NASA-Planetary-Science / sbpy

A Python package for small bodies research
https://sbpy.org/
Other
68 stars 34 forks source link

Tests: 2 errors during collection: astropy.units.core.UnitConversionError: '' (dimensionless) and 'Angstrom' (length) are not convertible #397

Closed Hellseher closed 3 months ago

Hellseher commented 3 months ago

High-level problem description While packaging sbpy for Guix I've got issue to pass tests.

What did you do? I prepared package for Guix.

What did you expect? Tests passed.

What did really happen? Tests failed during collection phase. Trace:

sing pytest
============================= test session starts ==============================
platform linux -- Python 3.10.7, pytest-7.1.3, pluggy-1.0.0 -- /gnu/store/jh59fh48mcffyz5wmsjj0p96xkkflbz0-python-wrapper-3.10.7/bin/python
cachedir: .pytest_cache
hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('/tmp/guix-build-python-sbpy-0.4.0.drv-0/sbpy-0.4.0/.hypothesis/examples')
rootdir: /tmp/guix-build-python-sbpy-0.4.0.drv-0/sbpy-0.4.0, configfile: tox.ini
plugins: hypothesis-6.54.5, astropy-0.11.0, doctestplus-1.2.0, remotedata-0.4.1, xdist-2.5.0, openfiles-0.6.0, filter-subpackage-0.2.0, cov-3.0.0, astropy-header-0.2.2, arraydiff-0.6.1, forked-1.6.0, asdf-3.2.0
collecting ... collected 626 items / 2 errors

==================================== ERRORS ====================================
__________ ERROR collecting sbpy/spectroscopy/tests/test_specgrad.py ___________
/gnu/store/5426ln4wv4pxriyp5bw8dg4wssrbr3ji-python-astropy-6.1.1/lib/python3.10/site-packages/astropy/units/quantity.py:987: in to_value
    scale = self.unit._to(unit)
/gnu/store/5426ln4wv4pxriyp5bw8dg4wssrbr3ji-python-astropy-6.1.1/lib/python3.10/site-packages/astropy/units/core.py:1191: in _to
    raise UnitConversionError(f"'{self!r}' is not a scaled version of '{other!r}'")
E   astropy.units.core.UnitConversionError: 'Unit(dimensionless)' is not a scaled version of 'Unit("Angstrom")'

During handling of the above exception, another exception occurred:
sbpy/spectroscopy/tests/test_specgrad.py:9: in <module>
    class TestSpectralGradient():
sbpy/spectroscopy/tests/test_specgrad.py:25: in TestSpectralGradient
    ((bandpass('SDSS g'), bandpass('SDSS r')),
sbpy/photometry/bandpass.py:161: in bandpass
    bp = synphot.SpectralElement.from_file(
/gnu/store/f8i8c159v8p15z2kmg1h8lf8krsa7sys-python-synphot-1.4.0/lib/python3.10/site-packages/synphot/spectrum.py:1951: in from_file
    return cls(Empirical1D, points=wavelengths, lookup_table=throughput,
/gnu/store/f8i8c159v8p15z2kmg1h8lf8krsa7sys-python-synphot-1.4.0/lib/python3.10/site-packages/synphot/spectrum.py:166: in __init__
    pval_wav = self._process_wave_param(kwargs.pop(pname_wav))
/gnu/store/f8i8c159v8p15z2kmg1h8lf8krsa7sys-python-synphot-1.4.0/lib/python3.10/site-packages/synphot/spectrum.py:258: in _process_wave_param
    return self._process_generic_param(
/gnu/store/f8i8c159v8p15z2kmg1h8lf8krsa7sys-python-synphot-1.4.0/lib/python3.10/site-packages/synphot/spectrum.py:251: in _process_generic_param
    outval = pval.to_value(def_unit, equivalencies)
/gnu/store/5426ln4wv4pxriyp5bw8dg4wssrbr3ji-python-astropy-6.1.1/lib/python3.10/site-packages/astropy/units/quantity.py:990: in to_value
    value = self._to_value(unit, equivalencies)
/gnu/store/5426ln4wv4pxriyp5bw8dg4wssrbr3ji-python-astropy-6.1.1/lib/python3.10/site-packages/astropy/units/quantity.py:896: in _to_value
    return self.unit.to(
/gnu/store/5426ln4wv4pxriyp5bw8dg4wssrbr3ji-python-astropy-6.1.1/lib/python3.10/site-packages/astropy/units/core.py:1227: in to
    return self.get_converter(Unit(other), equivalencies)(value)
/gnu/store/5426ln4wv4pxriyp5bw8dg4wssrbr3ji-python-astropy-6.1.1/lib/python3.10/site-packages/astropy/units/core.py:1156: in get_converter
    raise exc
/gnu/store/5426ln4wv4pxriyp5bw8dg4wssrbr3ji-python-astropy-6.1.1/lib/python3.10/site-packages/astropy/units/core.py:1139: in get_converter
    return self._apply_equivalencies(
/gnu/store/5426ln4wv4pxriyp5bw8dg4wssrbr3ji-python-astropy-6.1.1/lib/python3.10/site-packages/astropy/units/core.py:1090: in _apply_equivalencies
    raise UnitConversionError(f"{unit_str} and {other_str} are not convertible")
E   astropy.units.core.UnitConversionError: '' (dimensionless) and 'Angstrom' (length) are not convertible
------------------------------- Captured stderr --------------------------------
WARNING: AstropyDeprecationWarning: "wave_unit" was deprecated in version 1.4 and will be removed in a future version.
        Use TUNITn as per FITS standards instead. [synphot.specio]
WARNING: AstropyDeprecationWarning: "wave_unit" was deprecated in version 1.4 and will be removed in a future version.
        Use TUNITn as per FITS standards instead. [synphot.specio]
WARNING: AstropyDeprecationWarning: "wave_unit" was deprecated in version 1.4 and will be removed in a future version.
        Use TUNITn as per FITS standards instead. [synphot.specio]
__________ ERROR collecting sbpy/spectroscopy/tests/test_specgrad.py ___________
/gnu/store/5426ln4wv4pxriyp5bw8dg4wssrbr3ji-python-astropy-6.1.1/lib/python3.10/site-packages/astropy/units/quantity.py:987: in to_value
    scale = self.unit._to(unit)
/gnu/store/5426ln4wv4pxriyp5bw8dg4wssrbr3ji-python-astropy-6.1.1/lib/python3.10/site-packages/astropy/units/core.py:1191: in _to
    raise UnitConversionError(f"'{self!r}' is not a scaled version of '{other!r}'")
E   astropy.units.core.UnitConversionError: 'Unit(dimensionless)' is not a scaled version of 'Unit("Angstrom")'

During handling of the above exception, another exception occurred:
sbpy/spectroscopy/tests/test_specgrad.py:9: in <module>
    class TestSpectralGradient():
sbpy/spectroscopy/tests/test_specgrad.py:25: in TestSpectralGradient
    ((bandpass('SDSS g'), bandpass('SDSS r')),
sbpy/photometry/bandpass.py:161: in bandpass
    bp = synphot.SpectralElement.from_file(
/gnu/store/f8i8c159v8p15z2kmg1h8lf8krsa7sys-python-synphot-1.4.0/lib/python3.10/site-packages/synphot/spectrum.py:1951: in from_file
    return cls(Empirical1D, points=wavelengths, lookup_table=throughput,
/gnu/store/f8i8c159v8p15z2kmg1h8lf8krsa7sys-python-synphot-1.4.0/lib/python3.10/site-packages/synphot/spectrum.py:166: in __init__
    pval_wav = self._process_wave_param(kwargs.pop(pname_wav))
/gnu/store/f8i8c159v8p15z2kmg1h8lf8krsa7sys-python-synphot-1.4.0/lib/python3.10/site-packages/synphot/spectrum.py:258: in _process_wave_param
    return self._process_generic_param(
/gnu/store/f8i8c159v8p15z2kmg1h8lf8krsa7sys-python-synphot-1.4.0/lib/python3.10/site-packages/synphot/spectrum.py:251: in _process_generic_param
    outval = pval.to_value(def_unit, equivalencies)
/gnu/store/5426ln4wv4pxriyp5bw8dg4wssrbr3ji-python-astropy-6.1.1/lib/python3.10/site-packages/astropy/units/quantity.py:990: in to_value
    value = self._to_value(unit, equivalencies)
/gnu/store/5426ln4wv4pxriyp5bw8dg4wssrbr3ji-python-astropy-6.1.1/lib/python3.10/site-packages/astropy/units/quantity.py:896: in _to_value
    return self.unit.to(
/gnu/store/5426ln4wv4pxriyp5bw8dg4wssrbr3ji-python-astropy-6.1.1/lib/python3.10/site-packages/astropy/units/core.py:1227: in to
    return self.get_converter(Unit(other), equivalencies)(value)
/gnu/store/5426ln4wv4pxriyp5bw8dg4wssrbr3ji-python-astropy-6.1.1/lib/python3.10/site-packages/astropy/units/core.py:1156: in get_converter
    raise exc
/gnu/store/5426ln4wv4pxriyp5bw8dg4wssrbr3ji-python-astropy-6.1.1/lib/python3.10/site-packages/astropy/units/core.py:1139: in get_converter
    return self._apply_equivalencies(
/gnu/store/5426ln4wv4pxriyp5bw8dg4wssrbr3ji-python-astropy-6.1.1/lib/python3.10/site-packages/astropy/units/core.py:1090: in _apply_equivalencies
    raise UnitConversionError(f"{unit_str} and {other_str} are not convertible")
E   astropy.units.core.UnitConversionError: '' (dimensionless) and 'Angstrom' (length) are not convertible
------------------------------- Captured stderr --------------------------------
WARNING: AstropyDeprecationWarning: "wave_unit" was deprecated in version 1.4 and will be removed in a future version.
        Use TUNITn as per FITS standards instead. [synphot.specio]
WARNING: AstropyDeprecationWarning: "wave_unit" was deprecated in version 1.4 and will be removed in a future version.
        Use TUNITn as per FITS standards instead. [synphot.specio]
WARNING: AstropyDeprecationWarning: "wave_unit" was deprecated in version 1.4 and will be removed in a future version.
        Use TUNITn as per FITS standards instead. [synphot.specio]
=============================== warnings summary ===============================
sbpy/data/names.py:380
  /tmp/guix-build-python-sbpy-0.4.0.drv-0/sbpy-0.4.0/sbpy/data/names.py:380: DeprecationWarning: invalid escape sequence '\('
    """Parse a string as if it were an asteroid name.

sbpy/photometry/iau.py:249
  /tmp/guix-build-python-sbpy-0.4.0.drv-0/sbpy-0.4.0/sbpy/photometry/iau.py:249: DeprecationWarning: invalid escape sequence '\z'
    """Opposition effect amplitude, :math:`\zeta-1`

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
=========================== short test summary info ============================
ERROR sbpy/spectroscopy/tests/test_specgrad.py - astropy.units.core.UnitConve...
ERROR sbpy/spectroscopy/tests/test_specgrad.py - astropy.units.core.UnitConve...
!!!!!!!!!!!!!!!!!!! Interrupted: 2 errors during collection !!!!!!!!!!!!!!!!!!!!
======================== 2 warnings, 2 errors in 4.08s =========================

Provide information on your environment: Guix x86_64-linux

Inputs:

mkelley commented 3 months ago

Thanks for reporting this. The issue is due to a change in one of the package optional dependencies (synphot). I'll have a fix soon.

mkelley commented 3 months ago

@Hellseher I think you can successfully run the tests If you limit the synphot version to <1.4, numpy to <2.0, and scipy<1.14.