question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

BUG: Frame attributes in sky coordinates do not obey Numpy broadcasting rules

See original GitHub issue

Originally prompted by @mhvk in https://github.com/astropy/astropy/pull/8805#discussion_r291744415.

The crux of the issue is this: this doesn’t work:

from astropy import units as u
from astropy.coordinates import FK5
from astropy.time import Time

FK5(0*u.deg, 0*u.deg, equinox=time.Time(['J2000', 'J2001']))

whereas this does:

FK5([0]*2*u.deg, [0]*2*u.deg, equinox=Time(['J2000', 'J2001']))

The latter proves that there’s nothing in the machinery to prevent this all working the way you’d want, but the fact that the former fails is a sign that the broadcasting is not working the way you’d expect - e.g. 1 + np.random.randn(2) works just fine so it seems like the former example here should.

I consider this a bug because it was always the intent for broadcasting to work naturally in places like this.

cc @adrn

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:1
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
lpsingercommented, Apr 15, 2021

A question that arises is what to do with setting an attribute after the fact. It may not be crazy to insist that for that case the attribute must still be broadcastable to the instance’s shape, so that we can guarantee that the instances shape does not change.

I agree with that.

0reactions
mhvkcommented, Jul 27, 2022

See also discussion following https://github.com/astropy/astropy/pull/13398#discussion_r929752132, which showed that even the person who wrote the initial code continues to think that broadcasting works, when it at present does not. EDIT: see in particular some failures described in https://github.com/astropy/astropy/pull/13398#discussion_r931151751

Read more comments on GitHub >

github_iconTop Results From Across the Web

Broadcasting — NumPy v1.24 Manual
When the trailing dimensions of the arrays are unequal, broadcasting fails because it is impossible to align the values in the rows of...
Read more >
astropy/CHANGES.rst at main - GitHub
Fixed a bug due to which naxis , pixel_shape , and pixel_bounds attributes of astropy.wcs.WCS were not restored when an astropy.wcs.WCS object was...
Read more >
pyuvdata.utils — pyuvdata 2.2.9 documentation - Read the Docs
List standard FITS header items that are still should not be included in ... of float numpy array, shape (Npts, 3), with ECEF...
Read more >
Tutorial maputils module — Kapteyn Package 2.3b6 ...
Module maputils provides methods to draw a graticule in a plot showing the world coordinates in the given projection and sky system. One...
Read more >
Astropy Documentation - The University of Texas at Austin
If Numpy is not already installed in your Python environment, ... celestial coordinates, see the astropy.coordinates package.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found