Skip to content

TST: (numpy dev) fix return type for a selection of ufuncs applied to Column#15941

Merged
pllim merged 1 commit intoastropy:mainfrom
neutrinoceros:tst/numpy2/test_numpy_boolean_ufuncs
Jan 29, 2024
Merged

TST: (numpy dev) fix return type for a selection of ufuncs applied to Column#15941
pllim merged 1 commit intoastropy:mainfrom
neutrinoceros:tst/numpy2/test_numpy_boolean_ufuncs

Conversation

@neutrinoceros
Copy link
Copy Markdown
Contributor

@neutrinoceros neutrinoceros commented Jan 24, 2024

Description

This pull request is to address part of #15926, specifically fixing astropy/table/tests/test_column.py::TestColumn::test_numpy_boolean_ufuncs (as discussed in #15926 (comment))

The fix is rather inelegant, but I'm not sure there's a better one.

Close #15926

  • 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 added the table label Jan 24, 2024
@github-actions
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?
  • Is a milestone set? Milestone must be set but we cannot check for it on Actions; do not let the green checkmark fool you.
  • 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.

@github-actions
Copy link
Copy Markdown
Contributor

👋 Thank you for your draft pull request! Do you know that you can use [ci skip] or [skip ci] in your commit messages to skip running continuous integration tests until you are ready?

@neutrinoceros
Copy link
Copy Markdown
Contributor Author

I think this is working, but for extra safety, I'll wait until #15929 is merged so I can rebase this one and hopefully see the number of failure going down (I expect 16 remaining failures after this patch, which is 2 less than what is currently seen in #15929)

@neutrinoceros neutrinoceros force-pushed the tst/numpy2/test_numpy_boolean_ufuncs branch from 52d0cc7 to 81acf68 Compare January 25, 2024 08:16
@neutrinoceros
Copy link
Copy Markdown
Contributor Author

Actually rebased onto #15929 so it's clearer what this PR brings.

@neutrinoceros
Copy link
Copy Markdown
Contributor Author

following the success of my experimental merger (#15949), let's rebase on main again so merging order can be left to reviewers.

@neutrinoceros neutrinoceros force-pushed the tst/numpy2/test_numpy_boolean_ufuncs branch from 81acf68 to 8cb9f78 Compare January 25, 2024 10:56
@neutrinoceros neutrinoceros marked this pull request as ready for review January 25, 2024 10:56
Copy link
Copy Markdown
Contributor

@mhvk mhvk left a comment

Choose a reason for hiding this comment

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

Looks like the previous fix we had actually made other things worse... Here is a new suggestion...

# this is consistent with numpy 1.x behaviour for these functions
_function = context[0] if context is not None else None
if _function in (np.isfinite, np.isinf, np.isnan, np.sign, np.signbit):
if isinstance(out_arr, MaskedColumn):
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.

this section can be

if isinstance(out_arr, BaseColumn):
    out_arr = out_arr.data

Actually, never mind... see next comment

view_type = np.ndarray
out_arr = out_arr.view(view_type)

if (NUMPY_LT_2_0 or return_scalar) and (
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.

Actually, the problem is that the previous fix caused a breakage: np.isfinite is in _comparison_functions. So, we need to combine the two, as follows:

if self.shape != out_arr.shape or (
        isinstance(out_arr, BaseColumn)
        and (context is not None and context[0] in _comparison_functions)
    ):
    data = out_arr.data
    return data[()] if NUMPY_LT_2_0 or return_scalar else data
else:
    return out_arr

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.

I'm not sure what breakage you've identified, and see no failing test with this branch (after rebase) locally.
For completion, I also don't see any failures with your suggestion applied.
I'll let CI complete here to see if I'm missing anything.

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.

Ok, all I see is ✅, and it's night time in France, so I'm logging off, but feel free to push your suggestion to my branch if needed ! Thank you !

@neutrinoceros
Copy link
Copy Markdown
Contributor Author

Looks like the previous fix we had actually made other things worse...

What do you mean ? Is it because the number of failure is greater on this branch than you expect ? I'm going to rebase now, which should bring the number of failures to zero. While CI runs I'll also read your other comments.

@neutrinoceros neutrinoceros force-pushed the tst/numpy2/test_numpy_boolean_ufuncs branch from 8cb9f78 to d9253cc Compare January 25, 2024 22:29
@mhvk mhvk force-pushed the tst/numpy2/test_numpy_boolean_ufuncs branch from d9253cc to 402720d Compare January 29, 2024 14:49
@mhvk
Copy link
Copy Markdown
Contributor

mhvk commented Jan 29, 2024

Well, not worse, but broke something that worked before. Anyway, the fix should now be easy -- I pushed a revised version up.

Copy link
Copy Markdown
Contributor

@mhvk mhvk left a comment

Choose a reason for hiding this comment

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

Should be good to go if tests pass!

@mhvk mhvk enabled auto-merge January 29, 2024 14:50
@neutrinoceros
Copy link
Copy Markdown
Contributor Author

@mhvk thank you. I'll be in reply-only until Wednesday, so please feel free to patch up my PRs in the mean time. Also note that auto-merge won't work while CI is unstable (see #15960).

@pllim pllim disabled auto-merge January 29, 2024 20:33
@pllim
Copy link
Copy Markdown
Member

pllim commented Jan 29, 2024

Auto merge didn't work due to pytest 8 (sigh, the timing!). If the failures here are consistent with that I see in main with pytest 8, then I will merge.

@pllim pllim merged commit d0f9bd7 into astropy:main Jan 29, 2024
@pllim
Copy link
Copy Markdown
Member

pllim commented Jan 29, 2024

Thanks, all!

meeseeksmachine pushed a commit to meeseeksmachine/astropy that referenced this pull request Jan 29, 2024
pllim added a commit that referenced this pull request Jan 29, 2024
…941-on-v6.0.x

Backport PR #15941 on branch v6.0.x (TST: (numpy dev) fix return type for a selection of ufuncs applied to Column)
@neutrinoceros neutrinoceros deleted the tst/numpy2/test_numpy_boolean_ufuncs branch January 30, 2024 09:41
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.

TST: (numpy dev) new failing tests

3 participants