Thanks to visit codestin.com
Credit goes to github.com

Skip to content

BUG: MaskedNDArray.__array_ufunc__ breaks for erfa.atioq #16123

Description

@neutrinoceros

Related to (but independent of) #16116. Also discovered while working on #16070

import erfa
import astropy.units as u

from astropy.coordinates.builtin_frames.altaz import AltAz
from astropy.coordinates.erfa_astrom import erfa_astrom
from astropy.coordinates import EarthLocation
from astropy.utils.masked import Masked

obeserved_frame = AltAz(
    obstime="2024-02-28 10:33:24.505563",
    location=EarthLocation(6378137.0, 0.0, 0.0),
    pressure=0.0 << u.hPa,
    temperature=0.0 << u.deg_C,
    relative_humidity=0.0,
    obswl=1.0 << u.micron,
)

astrom = erfa_astrom.get().apco(obeserved_frame)
inputs = (0, 1, astrom)

r1 = erfa.atioq(*inputs) # this works
r2 = erfa.atioq(*(Masked(_) for _ in inputs)) # this doesn't
Traceback (most recent call last):
  File "/Users/clm/dev/astropy-project/coordinated/astropy/bugs/16116/g.py", line 25, in <module>
    r2 = erfa.atioq(*(Masked(_) for _ in inputs))
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/clm/.pyenv/versions/astropy.dev/lib/python3.12/site-packages/erfa/core.py", line 4058, in atioq
    aob, zob, hob, dob, rob = ufunc.atioq(ri, di, astrom)
                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/clm/dev/astropy-project/coordinated/astropy/astropy/utils/masked/core.py", line 807, in __array_ufunc__
    mask = self._combine_masks(masks, out=out_mask, where=where_unmasked)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/clm/dev/astropy-project/coordinated/astropy/astropy/utils/masked/core.py", line 704, in _combine_masks
    np.logical_or(out, mask, out=out, where=where)
TypeError: Cannot cast array data from dtype([('pmt', '?'), ('eb', '?', (3,)), ('eh', '?', (3,)), ('em', '?'), ('v', '?', (3,)), ('bm1', '?'), ('bpn', '?', (3, 3)), ('along', '?'), ('phi', '?'), ('xpl', '?'), ('ypl', '?'), ('sphi', '?'), ('cphi', '?'), ('diurab', '?'), ('eral', '?'), ('refa', '?'), ('refb', '?')]) to dtype('bool').

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions