Skip to content

Conversation

DanRyanIrish
Copy link
Member

@DanRyanIrish DanRyanIrish commented Aug 15, 2025

To Do

@DanRyanIrish DanRyanIrish added this to the 2.4.0 milestone Aug 15, 2025
Copy link
Member

@wtbarnes wtbarnes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've tried to wrap my head around what's happening here and I don't see anything obviously problematic (though I don't know much about NDData either). My one suggestion would be adding a test that constructs an NDData from a dask array (I think this is possible??) and then apply a these operations (at least add and mul) to that object and ensure that the laziness is preserved in these new codepaths.

@DanRyanIrish
Copy link
Member Author

@wtbarnes: Do these tests satisfy your comment?

@DanRyanIrish
Copy link
Member Author

@Cadair @wtbarnes: Docs on Arithmetic operations are now included in this PR. Please let me know if you have comments. If not, I'd appreciate an approval :)

@DanRyanIrish
Copy link
Member Author

DanRyanIrish commented Oct 5, 2025

@Cadair it looks like NDData(cube, wcs=None) doesn't actually set the wcs to None! https://github.com/sunpy/ndcube/actions/runs/18262220518/job/51991663154?pr=880

@Cadair
Copy link
Member

Cadair commented Oct 6, 2025

Oh, of course it doesn’t. Well balls.

I'm not really sure what the best option is in that case then.

@DanRyanIrish
Copy link
Member Author

Oh, of course it doesn’t. Well balls.

I'm not really sure what the best option is in that case then.

Dare a say it? NDCube.drop_coords() -> NDData?

@nabobalis
Copy link
Member

Oh, of course it doesn’t. Well balls.
I'm not really sure what the best option is in that case then.

Dare a say it? NDCube.drop_coords() -> NDData?

Do it

@DanRyanIrish DanRyanIrish marked this pull request as draft October 7, 2025 10:14
@DanRyanIrish DanRyanIrish marked this pull request as ready for review October 9, 2025 12:17
Comment on lines +221 to +223
>>> import warnings
>>> with warnings.catch_warnings():
... warnings.simplefilter("ignore") # Catching warnings not needed but keeps docs cleaner.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a fan, it makes the warnings surprising for people following along at home. What warnings are we squashing?

Copy link
Member Author

@DanRyanIrish DanRyanIrish Oct 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I remember right, a warning is raised because NDUncertainty.propagate doesn't support power, and so the uncertainties get dropped.

What alternative do you suggest?

where addition, subtraction, multiplication and division are all enabled by the ``+``, ``-``, ``*``, and ``/`` operators, respectively.

Note that `~ndcube.NDCube` attributes not supported by the constructor of the output type employed by `ndcube.NDCube.to_nddata` are dropped by the conversion.
Therefore, since `ndcube.NDCube.to_nddata` converts to `~astropy.nddata.NDData` by default, there was no need in the above example to explicitly set `~ndcube.NDCube.extra_coords` and `~ndcube.NDCube.global_coords` to ``None``.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why would you anyway?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To make sure all coordinates are dropped if you didn't know that NDData didn't support extra_coords and global_coords.

Comment on lines +308 to +314
Note that the output type of `ndcube.NDCube.to_nddata` can be controlled via the ``nddata_type`` kwarg.
For example:

>>> from astropy.nddata import NDDataRef
>>> nddataref2 = cube2.to_nddata(wcs=None, nddata_type=NDDataRef)
>>> print(type(nddataref2) is NDDataRef)
True
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels irrelevant to the narrative here and just documentation of to_nddata, and therefore in the wrong place?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair. Currently, there isn't a section anywhere on to_nddata and this code snippet probably doesn't merit one? So it might as well live here unless/until there is one.

Comment on lines +319 to +327
`ndcube.NDCube.to_nddata` is not limited to changing/removing the WCS.
The value of any input supported by the ``nddata_type``'s constructor can be altered by setting a kwarg for that input, e.g.:

.. code-block:: python
>>> nddata_ones = cube2.to_nddata(data=np.ones(cube2.data.shape))
>>> nddata_ones.data
array([[1., 1., 1.],
[1., 1., 1.]])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as this section, feels like the wrong place for this example? It's not relevant to arithmetic operations?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants