Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GH-44952: [C++][Python] Add Hyperbolic Trig functions #44630

Merged
merged 18 commits into from
Dec 9, 2024

Conversation

khwilson
Copy link
Contributor

@khwilson khwilson commented Nov 3, 2024

Rationale for this change

Hyperbolic trigonometric functions are a common transformation for dealing with skewed data. And they are built into the core C++ libraries so require minimal change.

What changes are included in this PR?

Adding a?(sin|cos|tan)h to the base C++ library and substrait and tests for these functions in pyarrow.

Are these changes tested?

Yes, in the same style as the trigonometric functions.

Are there any user-facing changes?

Yes. Additional compute functions are added.

@khwilson khwilson requested a review from westonpace as a code owner November 3, 2024 20:35
Copy link

github-actions bot commented Nov 3, 2024

⚠️ GitHub issue #44376 has been automatically assigned in GitHub to PR creator.

@khwilson
Copy link
Contributor Author

Hi @amoeba just wanted to check in if you had a chance to review this commit. The test failure is very strange (on an encryption test?!), but I can look into it!

@adamreeve
Copy link
Contributor

The test failure is very strange (on an encryption test?!), but I can look into it!

This test is known to be flaky (#43057), the failure is unrelated to the changes in this PR.

@amoeba
Copy link
Member

amoeba commented Nov 29, 2024

Hi @khwilson, thanks for the ping. I'll take a look in the next couple of days.

Copy link
Member

@amoeba amoeba left a comment

Choose a reason for hiding this comment

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

Thanks for contributing this. I left some notes inline.

Beyond that, can you please update the Python API docs to list these new functions?

(See dfb0928#diff-ce5b94577014735990903d3d03bd4ea4b8c8e6d32f5227592e60b7dd6a912d59R342 for an example.)

cpp/src/arrow/compute/kernels/scalar_arithmetic.cc Outdated Show resolved Hide resolved
cpp/src/arrow/compute/kernels/scalar_arithmetic.cc Outdated Show resolved Hide resolved
@github-actions github-actions bot added awaiting committer review Awaiting committer review and removed awaiting review Awaiting review labels Dec 5, 2024
@amoeba
Copy link
Member

amoeba commented Dec 5, 2024

@felipecrv do you have any time to give this a second review?

Copy link
Contributor

@felipecrv felipecrv left a comment

Choose a reason for hiding this comment

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

This is very well done. I found a simple range check error and suggested documentation improvements.

cpp/src/arrow/compute/api_scalar.cc Show resolved Hide resolved
cpp/src/arrow/compute/kernels/scalar_arithmetic.cc Outdated Show resolved Hide resolved
cpp/src/arrow/compute/kernels/scalar_arithmetic.cc Outdated Show resolved Hide resolved
cpp/src/arrow/compute/kernels/scalar_arithmetic.cc Outdated Show resolved Hide resolved
cpp/src/arrow/compute/kernels/scalar_arithmetic.cc Outdated Show resolved Hide resolved
cpp/src/arrow/compute/kernels/scalar_arithmetic.cc Outdated Show resolved Hide resolved
cpp/src/arrow/compute/kernels/scalar_arithmetic_test.cc Outdated Show resolved Hide resolved
@github-actions github-actions bot added awaiting changes Awaiting changes and removed awaiting committer review Awaiting committer review labels Dec 5, 2024
@felipecrv felipecrv changed the title GH-44376: [C++][Python] Add Hyperbolic Trig functions GH-44952: [C++][Python] Add Hyperbolic Trig functions Dec 5, 2024
Copy link

github-actions bot commented Dec 5, 2024

⚠️ GitHub issue #44952 has been automatically assigned in GitHub to PR creator.

@khwilson
Copy link
Contributor Author

khwilson commented Dec 5, 2024

Thanks for the reviews. I can:

  • Fix up the Python docs;
  • Update the C++ docs for all the trig functions to reflect their domains instead of just "invalid inputs."
  • Sort the code as suggested.

Remaining question for reviewers. In C++, atanh(1) = + infinity (and sets a divide by zero error). In Python atanh(1) is a domain error.

Which behaviour should this library (which spans both C++ and Python) utilize?

@felipecrv
Copy link
Contributor

Remaining question for reviewers. In C++, atanh(1) = + infinity (and sets a divide by zero error). In Python atanh(1) is a domain error.

Which behaviour should this library (which spans both C++ and Python) utilize?

Answered in the respective threads. Summary: -Inf/Inf on the unchecked version, range error on the checked version.

@khwilson
Copy link
Contributor Author

khwilson commented Dec 5, 2024

Makes sense. Will implement.

@github-actions github-actions bot added Component: Documentation awaiting change review Awaiting change review and removed awaiting changes Awaiting changes labels Dec 5, 2024
@khwilson
Copy link
Contributor Author

khwilson commented Dec 6, 2024

OK, I believe all the comments were addressed. Now to wait for tests and likely rebase :-)

Copy link
Contributor

@felipecrv felipecrv left a comment

Choose a reason for hiding this comment

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

I can merge soon if no one has more changes to request.

@felipecrv felipecrv added this to the 19.0.0 milestone Dec 6, 2024
@github-actions github-actions bot removed the awaiting change review Awaiting change review label Dec 6, 2024
@khwilson
Copy link
Contributor Author

khwilson commented Dec 8, 2024

Also rebased onto main as a bunch of tests seem to be failing for reasons I'm guessing are due to being slightly out of date :-)

@khwilson
Copy link
Contributor Author

khwilson commented Dec 8, 2024

Huh, looks like azurite is currently 404-ing, which is why some of the tests are failing. Seems to be due to a scheduled maintenance window as react is also 404-ing. Will rerun tests later.

@amoeba
Copy link
Member

amoeba commented Dec 8, 2024

I'm keeping an eye on them and will re-run the unrelated failures as needed.

@amoeba
Copy link
Member

amoeba commented Dec 8, 2024

@khwilson: This looks like a real failure: https://github.com/apache/arrow/actions/runs/12224231650/job/34096726088?pr=44630#step:6:3100. I think that can be fixed by adding a \n.

@khwilson
Copy link
Contributor Author

khwilson commented Dec 8, 2024

Added. Ran the main tests locally, but didn't run the doc tests it seems.

Copy link
Member

@amoeba amoeba left a comment

Choose a reason for hiding this comment

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

LGTM and CI is green. I'll let @felipecrv merge.

@felipecrv felipecrv merged commit 104b040 into apache:main Dec 9, 2024
38 of 39 checks passed
@felipecrv felipecrv removed the awaiting change review Awaiting change review label Dec 9, 2024
Copy link

After merging your PR, Conbench analyzed the 3 benchmarking runs that have been run so far on merge-commit 104b040.

There were no benchmark performance regressions. 🎉

The full Conbench report has more details.

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.

5 participants