Repository navigation
DOC: rework documentation for the __astropy_table__ protocol to avoid mingling with numpy 2.0's copy semantics - #16239
Conversation
|
Thank you for your contribution to Astropy! 🌌 This checklist is meant to remind the package maintainers who will review this pull request of some common things to look for.
|
| of the implementation. The implementation might choose to allow an additional | ||
| keyword argument (e.g., ``strict_copy`` which gets passed via ``**kwargs``) to | ||
| control the behavior in this case. | ||
| The ``copy`` argument should follow the conventions used by |Table| |
| raise ValueError(f'cannot have copy=False because column {name} is ' | ||
| 'not an ndarray') | ||
| if mask_invalid: | ||
| cols = [Masked(col, mask=np.isnan(col)) for col in cols] |
There was a problem hiding this comment.
Even though this is a toy example, it seems like you should only make cols Masked if need be:
| cols = [Masked(col, mask=np.isnan(col)) for col in cols] | |
| cols = [ | |
| Masked(col, mask=mask) if np.any(mask := np.isnan(col)) else col | |
| for col in cols | |
| ] |
There was a problem hiding this comment.
good point, and love that walrus !
07738d9 to
f666458
Compare
mhvk
left a comment
There was a problem hiding this comment.
Thanks, looks good, just a further suggestion for shrinkage, and an indentation nitpick.
| of the implementation. The implementation might choose to allow an additional | ||
| keyword argument (e.g., ``strict_copy`` which gets passed via ``**kwargs``) to | ||
| control the behavior in this case. | ||
| The ``copy`` argument should follow the conventions used by |Table|. |
There was a problem hiding this comment.
I think we should just delete the paragraph altogether (i.e., also delete 1251-1253 now). We already say copy is passed through, and have just mentioned that mask_invalid ends up in **kwargs.
There was a problem hiding this comment.
good call. Fixed
| raise ValueError(f'cannot have copy=False because column {name} is ' | ||
| 'not an ndarray') | ||
| if mask_invalid: | ||
| cols = [ |
… mingling with numpy 2.0's copy semantics
f666458 to
1fe430c
Compare
… mingling with numpy 2.0's copy semantics (#16239)
Description
Fixes #16235