Skip to content

make_omegascan broken under astropy 4

=================================== FAILURES ===================================
__________________________ test_make_omegascan_worked __________________________

self = <Index [[ 20.        ],
        [ 20.        ],
        [ 20.        ],
        ...,
        [645.52652608],
        [645.52652608],
        [645.52652608]] Hz>
unit = Unit("s"), equivalencies = []

    def to_value(self, unit=None, equivalencies=[]):
        """
        The numerical value, possibly in a different unit.
    
        Parameters
        ----------
        unit : `~astropy.units.UnitBase` instance or str, optional
            The unit in which the value should be given. If not given or `None`,
            use the current unit.
    
        equivalencies : list of equivalence pairs, optional
            A list of equivalence pairs to try if the units are not directly
            convertible (see :ref:`unit_equivalencies`). If not provided or
            ``[]``, class default equivalencies will be used (none for
            `~astropy.units.Quantity`, but may be set for subclasses).
            If `None`, no equivalencies will be applied at all, not even any
            set globally or within a context.
    
        Returns
        -------
        value : `~numpy.ndarray` or scalar
            The value in the units specified. For arrays, this will be a view
            of the data if no unit conversion was necessary.
    
        See also
        --------
        to : Get a new instance in a different unit.
        """
        if unit is None or unit is self.unit:
            value = self.view(np.ndarray)
        else:
            unit = Unit(unit)
            # We want a view if the unit does not change.  One could check
            # with "==", but that calculates the scale that we need anyway.
            # TODO: would be better for `unit.to` to have an in-place flag.
            try:
>               scale = self.unit._to(unit)

/usr/local/lib/python3.7/site-packages/astropy/units/quantity.py:731: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = Unit("Hz"), other = Unit("s")

    def _to(self, other):
        """
        Returns the scale to the specified unit.
    
        See `to`, except that a Unit object should be given (i.e., no
        string), and that all defaults are used, i.e., no
        equivalencies and value=1.
        """
        # There are many cases where we just want to ensure a Quantity is
        # of a particular unit, without checking whether it's already in
        # a particular unit.  If we're being asked to convert from a unit
        # to itself, we can short-circuit all of this.
        if self is other:
            return 1.0
    
        # Don't presume decomposition is possible; e.g.,
        # conversion to function units is through equivalencies.
        if isinstance(other, UnitBase):
            self_decomposed = self.decompose()
            other_decomposed = other.decompose()
    
            # Check quickly whether equivalent.  This is faster than
            # `is_equivalent`, because it doesn't generate the entire
            # physical type list of both units.  In other words it "fails
            # fast".
            if(self_decomposed.powers == other_decomposed.powers and
               all(self_base is other_base for (self_base, other_base)
                   in zip(self_decomposed.bases, other_decomposed.bases))):
                return self_decomposed.scale / other_decomposed.scale
    
        raise UnitConversionError(
>           f"'{self!r}' is not a scaled version of '{other!r}'")
E       astropy.units.core.UnitConversionError: 'Unit("Hz")' is not a scaled version of 'Unit("s")'

/usr/local/lib/python3.7/site-packages/astropy/units/core.py:951: UnitConversionError

During handling of the above exception, another exception occurred:

mock_create_cache = <MagicMock name='create_cache' id='140587859778768'>
scan_strainname = None

    @patch('gwcelery.tasks.detchar.create_cache', return_value=[resource_filename(
        __name__, 'data/llhoft/omegascan/scanme.gwf')])
    def test_make_omegascan_worked(mock_create_cache, scan_strainname):
        durs = [1, 1, 1]
        t0 = 1126259463
>       png = detchar.make_omegascan('H1', t0, durs)

gwcelery/tests/test_tasks_detchar.py:93: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/usr/local/lib/python3.7/site-packages/celery/app/task.py:392: in __call__
    return self.run(*args, **kwargs)
gwcelery/tasks/detchar.py:145: in make_omegascan
    np.transpose(qgram))
/usr/local/lib/python3.7/site-packages/gwpy/plot/axes.py:92: in wrapped_func
    return func(self, *args, **kwargs)
/usr/local/lib/python3.7/site-packages/gwpy/plot/axes.py:60: in decorated_func
    return func(*args, **kwargs)
/usr/local/lib/python3.7/site-packages/gwpy/plot/axes.py:281: in pcolormesh
    return super(Axes, self).pcolormesh(*args, **kwargs)
/usr/local/lib/python3.7/site-packages/matplotlib/__init__.py:1599: in inner
    return func(ax, *map(sanitize_sequence, args), **kwargs)
/usr/local/lib/python3.7/site-packages/matplotlib/axes/_axes.py:6176: in pcolormesh
    coords = np.column_stack((X, Y)).astype(float, copy=False)
<__array_function__ internals>:6: in column_stack
    ???
/usr/local/lib/python3.7/site-packages/astropy/units/quantity.py:1493: in __array_function__
    return super().__array_function__(function, types, args, kwargs)
/usr/local/lib/python3.7/site-packages/numpy/lib/shape_base.py:641: in column_stack
    return _nx.concatenate(arrays, 1)
<__array_function__ internals>:6: in concatenate
    ???
/usr/local/lib/python3.7/site-packages/astropy/units/quantity.py:1498: in __array_function__
    args, kwargs, unit, out = function_helper(*args, **kwargs)
/usr/local/lib/python3.7/site-packages/astropy/units/quantity_helper/function_helpers.py:377: in concatenate
    arrays, kwargs, unit, out = _iterable_helper(*arrays, out=out, axis=axis)
/usr/local/lib/python3.7/site-packages/astropy/units/quantity_helper/function_helpers.py:369: in _iterable_helper
    arrays, unit = _quantities2arrays(*args)
/usr/local/lib/python3.7/site-packages/astropy/units/quantity_helper/function_helpers.py:350: in _quantities2arrays
    arrays = tuple((q._to_own_unit(arg)) for arg in args)
/usr/local/lib/python3.7/site-packages/astropy/units/quantity_helper/function_helpers.py:350: in <genexpr>
    arrays = tuple((q._to_own_unit(arg)) for arg in args)
/usr/local/lib/python3.7/site-packages/astropy/units/quantity.py:1332: in _to_own_unit
    _value = value.to_value(self.unit)
/usr/local/lib/python3.7/site-packages/astropy/units/quantity.py:734: in to_value
    value = self._to_value(unit, equivalencies)
/usr/local/lib/python3.7/site-packages/astropy/units/quantity.py:665: in _to_value
    equivalencies=equivalencies)
/usr/local/lib/python3.7/site-packages/astropy/units/core.py:987: in to
    return self._get_converter(other, equivalencies=equivalencies)(value)
/usr/local/lib/python3.7/site-packages/astropy/units/core.py:918: in _get_converter
    raise exc
/usr/local/lib/python3.7/site-packages/astropy/units/core.py:904: in _get_converter
    self, other, self._normalize_equivalencies(equivalencies))
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = Unit("Hz"), unit = Unit("Hz"), other = Unit("s"), equivalencies = []

    def _apply_equivalencies(self, unit, other, equivalencies):
        """
        Internal function (used from `_get_converter`) to apply
        equivalence pairs.
        """
        def make_converter(scale1, func, scale2):
            def convert(v):
                return func(_condition_arg(v) / scale1) * scale2
            return convert
    
        for funit, tunit, a, b in equivalencies:
            if tunit is None:
                try:
                    ratio_in_funit = (other.decompose() /
                                      unit.decompose()).decompose([funit])
                    return make_converter(ratio_in_funit.scale, a, 1.)
                except UnitsError:
                    pass
            else:
                try:
                    scale1 = funit._to(unit)
                    scale2 = tunit._to(other)
                    return make_converter(scale1, a, scale2)
                except UnitsError:
                    pass
                try:
                    scale1 = tunit._to(unit)
                    scale2 = funit._to(other)
                    return make_converter(scale1, b, scale2)
                except UnitsError:
                    pass
    
        def get_err_str(unit):
            unit_str = unit.to_string('unscaled')
            physical_type = unit.physical_type
            if physical_type != 'unknown':
                unit_str = "'{}' ({})".format(
                    unit_str, physical_type)
            else:
                unit_str = f"'{unit_str}'"
            return unit_str
    
        unit_str = get_err_str(unit)
        other_str = get_err_str(other)
    
        raise UnitConversionError(
            "{} and {} are not convertible".format(
>               unit_str, other_str))
E       astropy.units.core.UnitConversionError: 'Hz' (frequency) and 's' (time) are not convertible

/usr/local/lib/python3.7/site-packages/astropy/units/core.py:888: UnitConversionError
=============================== warnings summary ===============================
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information