Skip to content

[Data] Compute Expressions - Expr Trigonometric#59712

Merged
alexeykudinkin merged 6 commits intoray-project:masterfrom
zzchun:trigonometric
Jan 2, 2026
Merged

[Data] Compute Expressions - Expr Trigonometric#59712
alexeykudinkin merged 6 commits intoray-project:masterfrom
zzchun:trigonometric

Conversation

@zzchun
Copy link
Contributor

@zzchun zzchun commented Dec 27, 2025

Description

Completing the Expr trigonometic operations (sin, cos, tan, asin, acos, atan)

for example:

import ray
from ray.data.expressions import col
import math

ds = ray.data.from_items([
    {"angle": 0.0},
    {"angle": math.pi / 4},
    {"angle": math.pi / 2}
])

ds = ds.with_column("sin_value", col("angle").sin())
ds = ds.with_column("cos_value", col("angle").cos())
ds = ds.with_column("tan_value", col("angle").tan())

ds2 = ray.data.from_items([{"value": -1.0}, {"value": 0.0}, {"value": 1.0}])
ds2 = ds2.with_column("asin_result", col("value").asin())
ds2 = ds2.with_column("acos_result", col("value").acos())
ds2 = ds2.with_column("atan_result", col("value").atan())

Related issues

Related to ##58674

@zzchun zzchun requested a review from a team as a code owner December 27, 2025 05:55
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request adds trigonometric operations (sin, cos, tan, asin, acos, atan) to Ray Data Expressions. The implementation is clean and follows existing patterns. The tests cover the new functionality, but I've suggested a refactoring to improve their clarity, efficiency, and coverage by using a more explicit parameterization strategy.

@ray-gardener ray-gardener bot added data Ray Data-related issues community-contribution Contributed by the community labels Dec 27, 2025
Copy link
Member

@owenowenisme owenowenisme left a comment

Choose a reason for hiding this comment

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

Hi @zzchun, CI is failing. Could you run pre-commit locally to fix the tests and push the updates?

Completing the Expr trigonometic operations (sin, cos, tan,
asin, acos, atan)

for example:
```
import ray
from ray.data.expressions import col
import math

ds = ray.data.from_items([
    {"angle": 0.0},
    {"angle": math.pi / 4},
    {"angle": math.pi / 2}
])

ds = ds.with_column("sin_value", col("angle").sin())
ds = ds.with_column("cos_value", col("angle").cos())
ds = ds.with_column("tan_value", col("angle").tan())

ds2 = ray.data.from_items([{"value": -1.0}, {"value": 0.0}, {"value": 1.0}])
ds2 = ds2.with_column("asin_result", col("value").asin())
ds2 = ds2.with_column("acos_result", col("value").acos())
ds2 = ds2.with_column("atan_result", col("value").atan())
```

Signed-off-by: will <zzchun8@gmail.com>
@zzchun
Copy link
Contributor Author

zzchun commented Dec 30, 2025

Hi @owenowenisme @goutamvenkat-anyscale , could you please review this PR when you have a moment, thanks.

@goutamvenkat-anyscale goutamvenkat-anyscale added the go add ONLY when ready to merge, run all tests label Dec 30, 2025
@richardliaw richardliaw enabled auto-merge (squash) December 30, 2025 23:33
Signed-off-by: Will Zhang <zzchun8@gmail.com>
auto-merge was automatically disabled December 31, 2025 02:29

Head branch was pushed to by a user without write access

Comment on lines +705 to +711
# For inverse trigonometric functions, we need to handle domain restrictions
# asin and acos require input in [-1, 1]
if expected_fn in (math.asin, math.acos):
# Use values in the valid domain for inverse trig functions
values = [-1.0, -0.5, 0.0, 0.5, 1.0]
ds = ray.data.from_items([{"value": v} for v in values])

Copy link
Member

Choose a reason for hiding this comment

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

Nit: To improve the readability of this test, I think it might be clearer if we move this out into a separate test_with_column_inverse_trigonometric_operations test

@alexeykudinkin alexeykudinkin merged commit 1b50670 into ray-project:master Jan 2, 2026
6 checks passed
AYou0207 pushed a commit to AYou0207/ray that referenced this pull request Jan 13, 2026
## Description
Completing the Expr trigonometic operations (sin, cos, tan, asin, acos,
atan)

for example:
```
import ray
from ray.data.expressions import col
import math

ds = ray.data.from_items([
    {"angle": 0.0},
    {"angle": math.pi / 4},
    {"angle": math.pi / 2}
])

ds = ds.with_column("sin_value", col("angle").sin())
ds = ds.with_column("cos_value", col("angle").cos())
ds = ds.with_column("tan_value", col("angle").tan())

ds2 = ray.data.from_items([{"value": -1.0}, {"value": 0.0}, {"value": 1.0}])
ds2 = ds2.with_column("asin_result", col("value").asin())
ds2 = ds2.with_column("acos_result", col("value").acos())
ds2 = ds2.with_column("atan_result", col("value").atan())
```

# Related issues
Related to #ray-project#58674

Signed-off-by: will <zzchun8@gmail.com>
Signed-off-by: Will Zhang <zzchun8@gmail.com>
Signed-off-by: jasonwrwang <jasonwrwang@tencent.com>
lee1258561 pushed a commit to pinterest/ray that referenced this pull request Feb 3, 2026
## Description
Completing the Expr trigonometic operations (sin, cos, tan, asin, acos,
atan)

for example:
```
import ray
from ray.data.expressions import col
import math

ds = ray.data.from_items([
    {"angle": 0.0},
    {"angle": math.pi / 4},
    {"angle": math.pi / 2}
])

ds = ds.with_column("sin_value", col("angle").sin())
ds = ds.with_column("cos_value", col("angle").cos())
ds = ds.with_column("tan_value", col("angle").tan())

ds2 = ray.data.from_items([{"value": -1.0}, {"value": 0.0}, {"value": 1.0}])
ds2 = ds2.with_column("asin_result", col("value").asin())
ds2 = ds2.with_column("acos_result", col("value").acos())
ds2 = ds2.with_column("atan_result", col("value").atan())
```

# Related issues
Related to #ray-project#58674

Signed-off-by: will <zzchun8@gmail.com>
Signed-off-by: Will Zhang <zzchun8@gmail.com>
ryanaoleary pushed a commit to ryanaoleary/ray that referenced this pull request Feb 3, 2026
## Description
Completing the Expr trigonometic operations (sin, cos, tan, asin, acos,
atan)

for example:
```
import ray
from ray.data.expressions import col
import math

ds = ray.data.from_items([
    {"angle": 0.0},
    {"angle": math.pi / 4},
    {"angle": math.pi / 2}
])

ds = ds.with_column("sin_value", col("angle").sin())
ds = ds.with_column("cos_value", col("angle").cos())
ds = ds.with_column("tan_value", col("angle").tan())

ds2 = ray.data.from_items([{"value": -1.0}, {"value": 0.0}, {"value": 1.0}])
ds2 = ds2.with_column("asin_result", col("value").asin())
ds2 = ds2.with_column("acos_result", col("value").acos())
ds2 = ds2.with_column("atan_result", col("value").atan())
```

# Related issues
Related to #ray-project#58674

Signed-off-by: will <zzchun8@gmail.com>
Signed-off-by: Will Zhang <zzchun8@gmail.com>
peterxcli pushed a commit to peterxcli/ray that referenced this pull request Feb 25, 2026
## Description
Completing the Expr trigonometic operations (sin, cos, tan, asin, acos,
atan)

for example:
```
import ray
from ray.data.expressions import col
import math

ds = ray.data.from_items([
    {"angle": 0.0},
    {"angle": math.pi / 4},
    {"angle": math.pi / 2}
])

ds = ds.with_column("sin_value", col("angle").sin())
ds = ds.with_column("cos_value", col("angle").cos())
ds = ds.with_column("tan_value", col("angle").tan())

ds2 = ray.data.from_items([{"value": -1.0}, {"value": 0.0}, {"value": 1.0}])
ds2 = ds2.with_column("asin_result", col("value").asin())
ds2 = ds2.with_column("acos_result", col("value").acos())
ds2 = ds2.with_column("atan_result", col("value").atan())
```

# Related issues
Related to #ray-project#58674

Signed-off-by: will <zzchun8@gmail.com>
Signed-off-by: Will Zhang <zzchun8@gmail.com>
Signed-off-by: peterxcli <peterxcli@gmail.com>
peterxcli pushed a commit to peterxcli/ray that referenced this pull request Feb 25, 2026
## Description
Completing the Expr trigonometic operations (sin, cos, tan, asin, acos,
atan)

for example:
```
import ray
from ray.data.expressions import col
import math

ds = ray.data.from_items([
    {"angle": 0.0},
    {"angle": math.pi / 4},
    {"angle": math.pi / 2}
])

ds = ds.with_column("sin_value", col("angle").sin())
ds = ds.with_column("cos_value", col("angle").cos())
ds = ds.with_column("tan_value", col("angle").tan())

ds2 = ray.data.from_items([{"value": -1.0}, {"value": 0.0}, {"value": 1.0}])
ds2 = ds2.with_column("asin_result", col("value").asin())
ds2 = ds2.with_column("acos_result", col("value").acos())
ds2 = ds2.with_column("atan_result", col("value").atan())
```

# Related issues
Related to #ray-project#58674

Signed-off-by: will <zzchun8@gmail.com>
Signed-off-by: Will Zhang <zzchun8@gmail.com>
Signed-off-by: peterxcli <peterxcli@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community-contribution Contributed by the community data Ray Data-related issues go add ONLY when ready to merge, run all tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants