Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
Hellseher opened this issue Jul 9, 2024 · 2 comments · Fixed by #400
Labels

Comments

@Hellseher
Copy link

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:

  • python-sbpy@0.4.0
    • python-pytest@7.1.3
    • python-pytest-astropy@0.11.0
    • python-pytest-doctestplus@1.2.0
    • python-pytest-remotedata@0.4.1
    • python-pytest-xdist@2.5.0
    • python-setuptools-scm@7.1.0
    • python-ads@0.12.6
    • python-astropy@6.1.1
    • python-astroquery@0.4.7
    • python-ginga@5.1.0
    • python-numpy@1.23.2
    • python-photutils@1.13.0
    • python-pyyaml@6.0
    • python-scipy@1.12.0
    • python-synphot@1.4.0
@Hellseher Hellseher added the potential bug automated label to indicate issue reports label Jul 9, 2024
@mkelley
Copy link
Member

mkelley commented Jul 10, 2024

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
Copy link
Member

mkelley commented Jul 10, 2024

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants