[Fix] Torch random.shuffle(axis=-1) mishandles negative axes#23119
[Fix] Torch random.shuffle(axis=-1) mishandles negative axes#23119ChiragSW wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the PyTorch backend's random.shuffle implementation to support negative axes by using canonicalize_axis. It also adds a test case in keras/src/random/random_test.py to verify that shuffling works correctly with axis=-1. There are no review comments, and I have no feedback to provide.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
Codecov Report✅ All modified and coverable lines are covered by tests.
Additional details and impacted files@@ Coverage Diff @@
## master #23119 +/- ##
==========================================
- Coverage 84.69% 75.24% -9.46%
==========================================
Files 464 464
Lines 68957 68959 +2
Branches 11331 11331
==========================================
- Hits 58404 51888 -6516
- Misses 7624 14364 +6740
+ Partials 2929 2707 -222
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
I don't know why the one numpy test is failing. It's passing on my machine with numpy backend. PS C:\Users\watta\hive\keras> $env:KERAS_BACKEND='numpy'
PS C:\Users\watta\hive\keras> pytest keras/src/ops/image_test.py::ImageOpsDtypeTest::test_perspective_transform_bfloat16
===================================================== test session starts =====================================================
platform win32 -- Python 3.10.9, pytest-9.0.2, pluggy-1.6.0 -- C:\Users\watta\AppData\Local\Programs\Python\Python310\python.exe
cachedir: .pytest_cache
rootdir: C:\Users\watta\hive\keras
configfile: pyproject.toml
plugins: anyio-4.11.0, langsmith-0.4.38
collected 1 item
keras/src/ops/image_test.py::ImageOpsDtypeTest::test_perspective_transform_bfloat16 PASSED [100%]
====================================================== 1 passed in 2.28s ======================================================@hertschuh please help me out here |
Description
Fixes: #23118
axis now goes through canonicalize_axis(). Added a small test for axis=-1.
Contributor Agreement
Please review our AI-Assisted Contribution Policy and check all boxes below before submitting your PR for review:
Note: Failing to adhere to this agreement may result in your future PRs no longer being reviewed.