Skip to content

Implement angle function in keras.ops #21200

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

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

shashaka
Copy link
Contributor

@shashaka shashaka commented Apr 22, 2025

Adds keras.ops.angle to compute the element-wise angle of complex numbers. Supported across NumPy, TensorFlow, PyTorch, and JAX backends, except for OpenVINO.

@codecov-commenter
Copy link

codecov-commenter commented Apr 22, 2025

Codecov Report

Attention: Patch coverage is 89.13043% with 5 lines in your changes missing coverage. Please review.

Project coverage is 82.60%. Comparing base (29a95e8) to head (e1d4a70).
Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
keras/src/backend/torch/numpy.py 57.14% 2 Missing and 1 partial ⚠️
keras/api/_tf_keras/keras/ops/__init__.py 0.00% 1 Missing ⚠️
keras/api/_tf_keras/keras/ops/numpy/__init__.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #21200      +/-   ##
==========================================
+ Coverage   82.59%   82.60%   +0.01%     
==========================================
  Files         564      564              
  Lines       54367    54440      +73     
  Branches     8452     8465      +13     
==========================================
+ Hits        44902    44970      +68     
- Misses       7391     7395       +4     
- Partials     2074     2075       +1     
Flag Coverage Δ
keras 82.41% <89.13%> (+0.01%) ⬆️
keras-jax 63.73% <54.34%> (-0.04%) ⬇️
keras-numpy 58.85% <56.52%> (-0.04%) ⬇️
keras-openvino 32.93% <19.56%> (+0.03%) ⬆️
keras-tensorflow 64.14% <54.34%> (-0.05%) ⬇️
keras-torch 63.81% <47.82%> (-0.05%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Collaborator

@fchollet fchollet left a comment

Choose a reason for hiding this comment

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

Nice, thank you for the contribution!

@google-ml-butler google-ml-butler bot added kokoro:force-run ready to pull Ready to be merged into the codebase labels Apr 22, 2025
@fchollet
Copy link
Collaborator

This branch has conflicts that must be resolved

We updated API generation, please resolve the conflict.

@google-ml-butler google-ml-butler bot removed the ready to pull Ready to be merged into the codebase label Apr 23, 2025
@shashaka
Copy link
Contributor Author

shashaka commented Apr 23, 2025

@fchollet

When running pre-commit locally, I encountered the following error.
It seems there may be a conflict between the api_gen and ruff steps.
Additionally, I’m unable to manually edit the init.py files.
At this point, I’m not sure how to resolve the issue.

$ pre-commit run --all-files --hook-stage manual

api_gen..................................................................Passed
ruff.....................................................................Failed
- hook id: ruff
- exit code: 1

keras/api/_tf_keras/keras/__init__.py:36:35: F811 Redefinition of unused `backend` from line 10
   |
34 | from keras import visualization
35 | from keras import wrappers
36 | from keras._tf_keras.keras import backend
   |                                   ^^^^^^^ F811
37 | from keras._tf_keras.keras import layers
38 | from keras._tf_keras.keras import losses
   |
   = help: Remove definition: `backend`

keras/api/_tf_keras/keras/__init__.py:36:35: F811 Redefinition of unused `backend` from line 10
   |
34 | from keras import visualization
35 | from keras import wrappers
36 | from keras._tf_keras.keras import backend
   |                                   ^^^^^^^ F811
37 | from keras._tf_keras.keras import layers
38 | from keras._tf_keras.keras import losses
   |
   = help: Remove definition: `backend`

keras/api/_tf_keras/keras/__init__.py:37:35: F811 Redefinition of unused `layers` from line 19
   |
35 | from keras import wrappers
36 | from keras._tf_keras.keras import backend
37 | from keras._tf_keras.keras import layers
   |                                   ^^^^^^ F811
38 | from keras._tf_keras.keras import losses
39 | from keras._tf_keras.keras import metrics
   |
   = help: Remove definition: `layers`

keras/api/_tf_keras/keras/__init__.py:37:35: F811 Redefinition of unused `layers` from line 19
   |
35 | from keras import wrappers
36 | from keras._tf_keras.keras import backend
37 | from keras._tf_keras.keras import layers
   |                                   ^^^^^^ F811
38 | from keras._tf_keras.keras import losses
39 | from keras._tf_keras.keras import metrics
   |
   = help: Remove definition: `layers`

keras/api/_tf_keras/keras/__init__.py:38:35: F811 Redefinition of unused `losses` from line 21
   |
36 | from keras._tf_keras.keras import backend
37 | from keras._tf_keras.keras import layers
38 | from keras._tf_keras.keras import losses
   |                                   ^^^^^^ F811
39 | from keras._tf_keras.keras import metrics
40 | from keras._tf_keras.keras import preprocessing
   |
   = help: Remove definition: `losses`

keras/api/_tf_keras/keras/__init__.py:38:35: F811 Redefinition of unused `losses` from line 21
   |
36 | from keras._tf_keras.keras import backend
37 | from keras._tf_keras.keras import layers
38 | from keras._tf_keras.keras import losses
   |                                   ^^^^^^ F811
39 | from keras._tf_keras.keras import metrics
40 | from keras._tf_keras.keras import preprocessing
   |
   = help: Remove definition: `losses`

keras/api/_tf_keras/keras/__init__.py:39:35: F811 Redefinition of unused `metrics` from line 22
   |
37 | from keras._tf_keras.keras import layers
38 | from keras._tf_keras.keras import losses
39 | from keras._tf_keras.keras import metrics
   |                                   ^^^^^^^ F811
40 | from keras._tf_keras.keras import preprocessing
41 | from keras.src.backend import Variable
   |
   = help: Remove definition: `metrics`

keras/api/_tf_keras/keras/__init__.py:39:35: F811 Redefinition of unused `metrics` from line 22
   |
37 | from keras._tf_keras.keras import layers
38 | from keras._tf_keras.keras import losses
39 | from keras._tf_keras.keras import metrics
   |                                   ^^^^^^^ F811
40 | from keras._tf_keras.keras import preprocessing
41 | from keras.src.backend import Variable
   |
   = help: Remove definition: `metrics`

keras/api/_tf_keras/keras/__init__.py:40:35: F811 Redefinition of unused `preprocessing` from line 27
   |
38 | from keras._tf_keras.keras import losses
39 | from keras._tf_keras.keras import metrics
40 | from keras._tf_keras.keras import preprocessing
   |                                   ^^^^^^^^^^^^^ F811
41 | from keras.src.backend import Variable
42 | from keras.src.backend import device
   |
   = help: Remove definition: `preprocessing`

keras/api/_tf_keras/keras/__init__.py:40:35: F811 Redefinition of unused `preprocessing` from line 27
   |
38 | from keras._tf_keras.keras import losses
39 | from keras._tf_keras.keras import metrics
40 | from keras._tf_keras.keras import preprocessing
   |                                   ^^^^^^^^^^^^^ F811
41 | from keras.src.backend import Variable
42 | from keras.src.backend import device
   |
   = help: Remove definition: `preprocessing`

keras/api/_tf_keras/keras/layers/__init__.py:269:37: F811 Redefinition of unused `AlphaDropout` from line 236
    |
267 | from keras.src.layers.rnn.stacked_rnn_cells import StackedRNNCells
268 | from keras.src.layers.rnn.time_distributed import TimeDistributed
269 | from keras.src.legacy.layers import AlphaDropout
    |                                     ^^^^^^^^^^^^ F811
270 | from keras.src.legacy.layers import RandomHeight
271 | from keras.src.legacy.layers import RandomWidth
    |
    = help: Remove definition: `AlphaDropout`

keras/api/_tf_keras/keras/layers/__init__.py:269:37: F811 Redefinition of unused `AlphaDropout` from line 236
    |
267 | from keras.src.layers.rnn.stacked_rnn_cells import StackedRNNCells
268 | from keras.src.layers.rnn.time_distributed import TimeDistributed
269 | from keras.src.legacy.layers import AlphaDropout
    |                                     ^^^^^^^^^^^^ F811
270 | from keras.src.legacy.layers import RandomHeight
271 | from keras.src.legacy.layers import RandomWidth
    |
    = help: Remove definition: `AlphaDropout`

Found 12 errors.

ruff-format..............................................................Passed

@shashaka
Copy link
Contributor Author

shashaka commented Apr 25, 2025

After running the following code block, I confirmed that pre-commit is working properly on my local environment:

pip install -r requirements.txt --progress-bar off --upgrade
pip uninstall -y keras keras-nightly
pip install -e "." --progress-bar off --upgrade

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