Skip to content

DOC: rework documentation for the __astropy_table__ protocol to avoid mingling with numpy 2.0's copy semantics - #16239

Merged
taldcroft merged 1 commit into
astropy:mainfrom
neutrinoceros:table/doc/update__astropy_table__16235
Mar 27, 2024
Merged

taldcroft merged 1 commit into
astropy:mainfrom
neutrinoceros:table/doc/update__astropy_table__16235

Conversation

@neutrinoceros

Copy link
Copy Markdown
Contributor

Description

Fixes #16235

  • By checking this box, the PR author has requested that maintainers do NOT use the "Squash and Merge" button. Maintainers should respect this when possible; however, the final decision is at the discretion of the maintainer that merges the PR.

@github-actions

github-actions Bot commented Mar 26, 2024 •

Copy link
Copy Markdown
Contributor

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.

  • Do the proposed changes actually accomplish desired goals?
  • Do the proposed changes follow the Astropy coding guidelines?
  • Are tests added/updated as required? If so, do they follow the Astropy testing guidelines?
  • Are docs added/updated as required? If so, do they follow the Astropy documentation guidelines?
  • Is rebase and/or squash necessary? If so, please provide the author with appropriate instructions. Also see instructions for rebase and squash.
  • Did the CI pass? If no, are the failures related? If you need to run daily and weekly cron jobs as part of the PR, please apply the "Extra CI" label. Codestyle issues can be fixed by the bot.
  • Is a change log needed? If yes, did the change log check pass? If no, add the "no-changelog-entry-needed" label. If this is a manual backport, use the "skip-changelog-checks" label unless special changelog handling is necessary.
  • Is this a big PR that makes a "What's new?" entry worthwhile and if so, is (1) a "what's new" entry included in this PR and (2) the "whatsnew-needed" label applied?
  • At the time of adding the milestone, if the milestone set requires a backport to release branch(es), apply the appropriate "backport-X.Y.x" label(s) before merge.

Comment thread docs/table/construct_table.rst Outdated
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|

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Missing a trailing period.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

fixed

Comment thread docs/table/construct_table.rst Outdated
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]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Even though this is a toy example, it seems like you should only make cols Masked if need be:

Suggested change
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
]

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

good point, and love that walrus !

@neutrinoceros
neutrinoceros force-pushed the table/doc/update__astropy_table__16235 branch 2 times, most recently from 07738d9 to f666458 Compare March 26, 2024 14:25

@mhvk mhvk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks, looks good, just a further suggestion for shrinkage, and an indentation nitpick.

Comment thread docs/table/construct_table.rst Outdated
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|.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

good call. Fixed

Comment thread docs/table/construct_table.rst Outdated
raise ValueError(f'cannot have copy=False because column {name} is '
'not an ndarray')
if mask_invalid:
cols = [

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Indentation off by 2

@neutrinoceros
neutrinoceros force-pushed the table/doc/update__astropy_table__16235 branch from f666458 to 1fe430c Compare March 27, 2024 06:03
@taldcroft taldcroft added this to the v6.1.0 milestone Mar 27, 2024

@taldcroft taldcroft left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good!

@taldcroft
taldcroft merged commit 4bea6f5 into astropy:main Mar 27, 2024
@neutrinoceros
neutrinoceros deleted the table/doc/update__astropy_table__16235 branch March 27, 2024 10:55
d-giles referenced this pull request in d-giles/astropy-abdufork Jul 26, 2024
… mingling with numpy 2.0's copy semantics (#16239)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DOC: revise __astropy_table__'s documentation ?

3 participants