feat: add support for np.isnan and np.isfinite ufuncs#2188
Merged
Conversation
This commit implements the `isnan` and `isfinite` numpy ufuncs in bigframes. The following changes were made: - Added `IsNanOp` and `IsFiniteOp` to `bigframes/operations/numeric_ops.py` - Mapped `np.isnan` and `np.isfinite` to the new ops in `bigframes/operations/numpy_op_maps.py` - Added compilation logic for the new ops to the ibis, polars, and sqlglot compilers - Added tests for the new ops in `tests/system/small/test_numpy.py`
tswast
commented
Oct 22, 2025
This commit implements the `isnan` and `isfinite` numpy ufuncs in bigframes. The following changes were made: - Added `IsNanOrNullOp` and `IsFiniteOp` to `bigframes/operations/numeric_ops.py` - Mapped `np.isnan` and `np.isfinite` to the new ops in `bigframes/operations/numpy_op_maps.py` - Added compilation logic for the new ops to the ibis, polars, and sqlglot compilers - Added tests for the new ops in `tests/system/small/test_numpy.py` - Renamed `IsNanOp` to `IsNanOrNullOp` to match numpy semantics and updated compilers accordingly.
tswast
commented
Oct 22, 2025
tswast
commented
Oct 22, 2025
tswast
commented
Oct 22, 2025
tswast
commented
Oct 22, 2025
bigframes/operations/numeric_ops.py
Outdated
| unsafe_pow_op = UnsafePowOp() | ||
|
|
||
| IsNanOp = base_ops.create_unary_op( | ||
| name="isnanornull", |
| @polars_compiler.register_op(numeric_ops.IsNanOp) | ||
| def is_nan_op_impl( | ||
| compiler: polars_compiler.PolarsExpressionCompiler, | ||
| op: numeric_ops.SqrtOp, # type: ignore |
| @polars_compiler.register_op(numeric_ops.IsFiniteOp) | ||
| def is_finite_op_impl( | ||
| compiler: polars_compiler.PolarsExpressionCompiler, | ||
| op: numeric_ops.SqrtOp, # type: ignore |
jialuoo
approved these changes
Oct 23, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This commit implements the
isnanandisfinitenumpy ufuncs in bigframes.The following changes were made:
IsNanOpandIsFiniteOptobigframes/operations/numeric_ops.pynp.isnanandnp.isfiniteto the new ops inbigframes/operations/numpy_op_maps.pytests/system/small/test_numpy.pyThank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:
Fixes b/454341854🦕